Improve readability
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -54,20 +54,14 @@ final class MgmtDistributionSetTypeMapper {
|
|||||||
final DistributionSetType result = entityFactory.generateDistributionSetType(smsRest.getKey(),
|
final DistributionSetType result = entityFactory.generateDistributionSetType(smsRest.getKey(),
|
||||||
smsRest.getName(), smsRest.getDescription());
|
smsRest.getName(), smsRest.getDescription());
|
||||||
|
|
||||||
// Add mandatory
|
addMandatoryModules(softwareManagement, smsRest, result);
|
||||||
if (!CollectionUtils.isEmpty(smsRest.getMandatorymodules())) {
|
addOptionalModules(softwareManagement, smsRest, result);
|
||||||
smsRest.getMandatorymodules().stream().map(mand -> {
|
|
||||||
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeById(mand.getId());
|
|
||||||
|
|
||||||
if (smType == null) {
|
return result;
|
||||||
throw new EntityNotFoundException("SoftwareModuleType with ID " + mand.getId() + " not found");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return smType;
|
private static void addOptionalModules(final SoftwareManagement softwareManagement,
|
||||||
}).forEach(result::addMandatoryModuleType);
|
final MgmtDistributionSetTypeRequestBodyPost smsRest, final DistributionSetType result) {
|
||||||
}
|
|
||||||
|
|
||||||
// Add optional
|
|
||||||
if (!CollectionUtils.isEmpty(smsRest.getOptionalmodules())) {
|
if (!CollectionUtils.isEmpty(smsRest.getOptionalmodules())) {
|
||||||
smsRest.getOptionalmodules().stream().map(opt -> {
|
smsRest.getOptionalmodules().stream().map(opt -> {
|
||||||
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeById(opt.getId());
|
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeById(opt.getId());
|
||||||
@@ -79,8 +73,21 @@ final class MgmtDistributionSetTypeMapper {
|
|||||||
return smType;
|
return smType;
|
||||||
}).forEach(result::addOptionalModuleType);
|
}).forEach(result::addOptionalModuleType);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
private static void addMandatoryModules(final SoftwareManagement softwareManagement,
|
||||||
|
final MgmtDistributionSetTypeRequestBodyPost smsRest, final DistributionSetType result) {
|
||||||
|
if (!CollectionUtils.isEmpty(smsRest.getMandatorymodules())) {
|
||||||
|
smsRest.getMandatorymodules().stream().map(mand -> {
|
||||||
|
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeById(mand.getId());
|
||||||
|
|
||||||
|
if (smType == null) {
|
||||||
|
throw new EntityNotFoundException("SoftwareModuleType with ID " + mand.getId() + " not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
return smType;
|
||||||
|
}).forEach(result::addMandatoryModuleType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<MgmtDistributionSetType> toTypesResponse(final List<DistributionSetType> types) {
|
static List<MgmtDistributionSetType> toTypesResponse(final List<DistributionSetType> types) {
|
||||||
|
|||||||
Reference in New Issue
Block a user