add type name to mgmt api responses (#1298)

Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>

Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>
This commit is contained in:
Stefan Klotz
2023-01-10 12:54:50 +01:00
committed by GitHub
parent 68a57f69f0
commit 27872282f5
11 changed files with 104 additions and 56 deletions

View File

@@ -109,6 +109,7 @@ public final class MgmtDistributionSetMapper {
response.setVersion(distributionSet.getVersion());
response.setComplete(distributionSet.isComplete());
response.setType(distributionSet.getType().getKey());
response.setTypeName(distributionSet.getType().getName());
response.setDeleted(distributionSet.isDeleted());
response.setValid(distributionSet.isValid());

View File

@@ -106,6 +106,7 @@ public final class MgmtSoftwareModuleMapper {
response.setModuleId(softwareModule.getId());
response.setVersion(softwareModule.getVersion());
response.setType(softwareModule.getType().getKey());
response.setTypeName(softwareModule.getType().getName());
response.setVendor(softwareModule.getVendor());
response.setDeleted(softwareModule.isDeleted());
response.setEncrypted(softwareModule.isEncrypted());

View File

@@ -17,7 +17,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.mgmt.json.model.MgmtMaintenanceWindow;
@@ -82,8 +81,8 @@ public final class MgmtTargetMapper {
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE,
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("metadata"));
if (response.getTargetType() != null) {
response.add(linkTo(methodOn(MgmtTargetTypeRestApi.class)
.getTargetType(response.getTargetType())).withRel(MgmtRestConstants.TARGET_V1_ASSIGNED_TARGET_TYPE));
response.add(linkTo(methodOn(MgmtTargetTypeRestApi.class).getTargetType(response.getTargetType()))
.withRel(MgmtRestConstants.TARGET_V1_ASSIGNED_TARGET_TYPE));
}
}
@@ -159,8 +158,9 @@ public final class MgmtTargetMapper {
if (installationDate != null) {
targetRest.setInstalledAt(installationDate);
}
if (target.getTargetType() != null){
if (target.getTargetType() != null) {
targetRest.setTargetType(target.getTargetType().getId());
targetRest.setTargetTypeName(target.getTargetType().getName());
}
targetRest.add(linkTo(methodOn(MgmtTargetRestApi.class).getTarget(target.getControllerId())).withSelfRel());
@@ -226,12 +226,12 @@ public final class MgmtTargetMapper {
result.setStatus(MgmtAction.ACTION_FINISHED);
}
Rollout rollout = action.getRollout();
final Rollout rollout = action.getRollout();
if (rollout != null) {
result.setRollout(rollout.getId());
result.setRolloutName(rollout.getName());
}
if (action.hasMaintenanceSchedule()) {
final MgmtMaintenanceWindow maintenanceWindow = new MgmtMaintenanceWindow();
maintenanceWindow.setSchedule(action.getMaintenanceWindowSchedule());
@@ -270,7 +270,7 @@ public final class MgmtTargetMapper {
result.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRollout(rollout.getId()))
.withRel(MgmtRestConstants.TARGET_V1_ROLLOUT));
}
return result;
}