[#1509] Sync Target type with SW and DS types (REST Layer) (#1514)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2023-12-13 14:33:32 +02:00
committed by GitHub
parent 4b5a7d6e7d
commit 767a7e6b11
11 changed files with 117 additions and 154 deletions

View File

@@ -80,11 +80,8 @@ final class MgmtDistributionSetTypeMapper {
static MgmtDistributionSetType toResponse(final DistributionSetType type) {
final MgmtDistributionSetType result = new MgmtDistributionSetType();
MgmtRestModelMapper.mapNamedToNamed(result, type);
result.setKey(type.getKey());
MgmtRestModelMapper.mapTypeToType(result, type);
result.setModuleId(type.getId());
result.setDeleted(type.isDeleted());
result.setColour(type.getColour());
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId()))
.withSelfRel().expand());

View File

@@ -11,12 +11,14 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtCancelationType;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.DistributionSetInvalidation.CancelationType;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import org.eclipse.hawkbit.repository.model.Type;
/**
* A mapper which maps repository model to RESTful model representation and
@@ -48,6 +50,14 @@ public final class MgmtRestModelMapper {
response.setDescription(base.getDescription());
}
static void mapTypeToType(final MgmtTypeEntity response, final Type base) {
mapNamedToNamed(response, base);
response.setKey(base.getKey());
response.setColour(base.getColour());
response.setDeleted(base.isDeleted());
}
/**
* Convert the given {@link MgmtActionType} into a corresponding repository
* {@link ActionType}.

View File

@@ -65,12 +65,9 @@ final class MgmtSoftwareModuleTypeMapper {
static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) {
final MgmtSoftwareModuleType result = new MgmtSoftwareModuleType();
MgmtRestModelMapper.mapNamedToNamed(result, type);
result.setKey(type.getKey());
MgmtRestModelMapper.mapTypeToType(result, type);
result.setMaxAssignments(type.getMaxAssignments());
result.setModuleId(type.getId());
result.setDeleted(type.isDeleted());
result.setColour(type.getColour());
result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId()))
.withSelfRel().expand());

View File

@@ -29,9 +29,7 @@ import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.rest.data.ResponseList;
/**
* A mapper which maps repository model to RESTful model representation and
* back.
*
* A mapper which maps repository model to RESTful model representation and back.
*/
public final class MgmtTargetTypeMapper {
@@ -50,8 +48,9 @@ public final class MgmtTargetTypeMapper {
private static TargetTypeCreate fromRequest(final EntityFactory entityFactory,
final MgmtTargetTypeRequestBodyPost targetTypesRest) {
return entityFactory.targetType().create().name(targetTypesRest.getName())
.description(targetTypesRest.getDescription()).colour(targetTypesRest.getColour())
return entityFactory.targetType().create()
.name(targetTypesRest.getName()).description(targetTypesRest.getDescription())
.key(targetTypesRest.getKey()).colour(targetTypesRest.getColour())
.compatible(getDistributionSets(targetTypesRest));
}
@@ -70,9 +69,9 @@ public final class MgmtTargetTypeMapper {
static MgmtTargetType toResponse(final TargetType type) {
final MgmtTargetType result = new MgmtTargetType();
MgmtRestModelMapper.mapNamedToNamed(result, type);
MgmtRestModelMapper.mapTypeToType(result, type);
result.setTypeId(type.getId());
result.setColour(type.getColour());
result.add(
linkTo(methodOn(MgmtTargetTypeRestApi.class).getTargetType(result.getTypeId())).withSelfRel().expand());
return result;