diff options
author | talio <tali.orenbach@amdocs.com> | 2019-06-24 09:49:23 +0300 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2019-06-24 07:40:17 +0000 |
commit | 8da6ea990a89b752e0e40d7dbf82b6761850f4e7 (patch) | |
tree | 29879e8c0b0863dcc69134871f32b885b0c4ba09 /catalog-be/src/main/java/org | |
parent | b7a38592f4b665780b0ec048d6abddb89bfe3a62 (diff) |
Fix node filter properties value
fix node filter properties value to be list<map<string, list>>
Change-Id: Iafb31c4f94f10d0493ef2bce622019958a995639
Issue-ID: SDC-2381
Signed-off-by: talio <tali.orenbach@amdocs.com>
Diffstat (limited to 'catalog-be/src/main/java/org')
3 files changed, 30 insertions, 11 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java index 2c0af5fec5..df56ccc1e4 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java @@ -2862,7 +2862,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { } public Either<CINodeFilterDataDefinition, ResponseFormat> addOrDeleteServiceFilter(String serviceId, String componentInstanceId, - NodeFilterConstraintAction action, String constraint, int position, User inUser, boolean lock) { + NodeFilterConstraintAction action, String propertyName, String constraint, int position, User inUser, boolean lock) { String errorContext = "createIfNotAlreadyExistServiceFilter"; User user = validateUserExists(inUser, errorContext, true); validateUserRole(user, Arrays.asList(Role.DESIGNER, Role.ADMIN)); @@ -2913,6 +2913,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { switch (action) { case ADD: RequirementNodeFilterPropertyDataDefinition newProperty = new RequirementNodeFilterPropertyDataDefinition(); + newProperty.setName(propertyName); newProperty.setConstraints(Collections.singletonList(constraint)); result = serviceFilterOperation.addNewProperty(serviceId, componentInstanceId,serviceFilter,newProperty); break; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceFilterServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceFilterServlet.java index 3daca3f28c..b539265721 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceFilterServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceFilterServlet.java @@ -101,7 +101,7 @@ public class ServiceFilterServlet extends AbstractValidationsServlet { Either<CINodeFilterDataDefinition, ResponseFormat> actionResponse; String constraint = new ConstraintConvertor().convert(uiConstraint); actionResponse = businessLogic - .addOrDeleteServiceFilter(serviceIdLower, ciId, NodeFilterConstraintAction.ADD, + .addOrDeleteServiceFilter(serviceIdLower, ciId, NodeFilterConstraintAction.ADD, uiConstraint.getServicePropertyName(), constraint, -1, modifier, true); if (actionResponse.isRight()) { @@ -224,7 +224,7 @@ public class ServiceFilterServlet extends AbstractValidationsServlet { Either<CINodeFilterDataDefinition, ResponseFormat> actionResponse; actionResponse = businessLogic .addOrDeleteServiceFilter(serviceIdLower, ciId, NodeFilterConstraintAction.DELETE, - null, index, modifier, true); + null, null, index, modifier, true); if (actionResponse.isRight()) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java index 603da09a1d..0d3836b1c9 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java @@ -1324,25 +1324,43 @@ public class ToscaExportHandler { origProperties.isEmpty()) { return; } + Map<String, List<Object>> propertyMapCopy = new HashMap<>(); for(RequirementNodeFilterPropertyDataDefinition propertyDataDefinition : origProperties.getListToscaDataDefinition()) { - Map<String, List<Object>> propertyMapCopy = new HashMap<>(); for(String propertyInfoEntry : propertyDataDefinition.getConstraints()) { Map propertyValObj = new YamlUtil().yamlToObject(propertyInfoEntry, Map.class); - if (propertyMapCopy.containsKey(propertyDataDefinition.getName())){ - propertyMapCopy.get(propertyDataDefinition.getName()).add(propertyValObj); + String propertyName = propertyDataDefinition.getName(); + if (propertyMapCopy.containsKey(propertyName)){ + addPropertyConstraintValueToList(propertyName, propertyValObj, propertyMapCopy.get(propertyName)); } else { - if (propertyDataDefinition.getName() != null) { - List propsList =new ArrayList(); - propsList.add(propertyValObj); - propertyMapCopy.put(propertyDataDefinition.getName(), propsList); + if (propertyName != null) { + List propsList = new ArrayList(); + addPropertyConstraintValueToList(propertyName, propertyValObj, propsList); + propertyMapCopy.put(propertyName, propsList); } else { propertyMapCopy.putAll(propertyValObj); } } } - propertiesCopy.add(propertyMapCopy); } + propertyMapCopy.entrySet().stream().forEach(entry -> + addCalculatedConstraintsIntoPropertiesList(propertiesCopy, entry)); + } + + private void addPropertyConstraintValueToList(String propertyName, Map propertyValObj, List propsList) { + if(propertyValObj.containsKey(propertyName)) { + propsList.add(propertyValObj.get(propertyName)); + } else { + propsList.add(propertyValObj); + } + } + + + private void addCalculatedConstraintsIntoPropertiesList(List<Map<String, List<Object>>> propertiesCopy, + Entry<String, List<Object>> entry) { + Map<String, List<Object>> tempMap = new HashMap<>(); + tempMap.put(entry.getKey(), entry.getValue()); + propertiesCopy.add(tempMap); } private static class CustomRepresenter extends Representer { |