From 4d0dbee1a1ac7c58c665cdd0e8576bfa9edd1e0e Mon Sep 17 00:00:00 2001 From: talig Date: Wed, 30 May 2018 16:15:50 +0300 Subject: Add minimum to number questionnaire fields In case of compute validation error - display its name (same as other entities) Change-Id: Ie3f0190a3b30d1ed6210f50958f61d8a883d5bef Issue-ID: SDC-1387 Signed-off-by: talig --- .../impl/CompositionEntityDataManagerImpl.java | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'openecomp-be/backend') diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java index faa53862ef..db6a63a2ba 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java @@ -66,6 +66,7 @@ import org.openecomp.sdc.versioning.dao.types.Version; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -85,7 +86,8 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa private static final Logger logger = LoggerFactory.getLogger(CompositionEntityDataManagerImpl.class); private Map entities = new HashMap<>(); - private Map nonDynamicSchemas = new HashMap<>(); + private Map nonDynamicSchemas = + new EnumMap<>(CompositionEntityType.class); private List roots = new ArrayList<>(); private VendorSoftwareProductInfoDao vspInfoDao; @@ -175,10 +177,10 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa @Override public Map> validateEntitiesQuestionnaire() { Map> errorsByEntityId = new HashMap<>(); - entities.entrySet().forEach(entry -> { - Collection errors = validateQuestionnaire(entry.getValue()); + entities.forEach((key, value) -> { + Collection errors = validateQuestionnaire(value); if (errors != null) { - errorsByEntityId.put(entry.getKey(), errors); + errorsByEntityId.put(key, errors); } }); return errorsByEntityId; @@ -191,9 +193,8 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa public void buildTrees() { Map entitiesValidationData = new HashMap<>(); - entities.entrySet().forEach( - entry -> addValidationDataEntity(entitiesValidationData, entry.getKey(), - entry.getValue().entity)); + entities.forEach((key, value) -> addValidationDataEntity(entitiesValidationData, key, + value.entity)); } public Collection getTrees() { @@ -225,7 +226,7 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa return entitiesWithErrors; } - return null; + return new HashSet<>(); } private boolean isThereErrorsInSubTree(CompositionEntityValidationData entity) { @@ -445,6 +446,10 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa Image image = JsonUtil.json2Object(compositionData, Image.class); return image.getFileName(); + case compute: + ComputeData compute = JsonUtil.json2Object(compositionData, ComputeData.class); + return compute.getName(); + case vsp: CompositionEntityData vspEntity = getCompositionEntityDataById(entity); if (Objects.isNull(vspEntity)) { @@ -455,9 +460,9 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa vspInfoDao.get(new VspDetails(vspQuestionnaireEntity.getId(), vspQuestionnaireEntity.getVersion())); return vspDetails.getName(); + default: + return null; } - - return null; } private void removeNodesWithoutErrors(CompositionEntityValidationData node, -- cgit 1.2.3-korg