aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceFilterServlet.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java34
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 {