summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java10
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java14
2 files changed, 19 insertions, 5 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java
index 63093ebd9a..48932fefd7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java
@@ -59,10 +59,12 @@ public class NodeFilterConverter {
private void convertCapabilityConstraint(final RequirementNodeFilterCapabilityDataDefinition requirementNodeFilterCapabilityDataDefinition,
final List<UIConstraint> capabilitiesConstraint) {
- final UIConstraint uiConstraint = new UIConstraint();
final ConstraintConvertor constraintConvertor = new ConstraintConvertor();
- uiConstraint.setCapabilityName(requirementNodeFilterCapabilityDataDefinition.getName());
- requirementNodeFilterCapabilityDataDefinition.getProperties().getListToscaDataDefinition().forEach(
- property -> capabilitiesConstraint.add(constraintConvertor.getUiConstraint(property.getConstraints().iterator().next(), uiConstraint)));
+ requirementNodeFilterCapabilityDataDefinition.getProperties().getListToscaDataDefinition().forEach(property -> {
+ final UIConstraint uiConstraint = new UIConstraint();
+ uiConstraint.setCapabilityName(requirementNodeFilterCapabilityDataDefinition.getName());
+ capabilitiesConstraint.add(
+ constraintConvertor.getUiConstraint(property.getConstraints().iterator().next(), uiConstraint));
+ });
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java
index bcc005e6e3..2d0693af76 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java
@@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableSet;
import fj.data.Either;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.Set;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -117,7 +118,18 @@ public class NodeFilterOperation extends BaseOperation {
capabilities = new ListDataDefinition<>();
nodeFilterDataDefinition.setCapabilities(capabilities);
}
- capabilities.getListToscaDataDefinition().add(requirementNodeFilterCapabilityDataDefinition);
+
+ final Optional<RequirementNodeFilterCapabilityDataDefinition> existingCap = capabilities
+ .getListToscaDataDefinition().stream()
+ .filter(def -> def.getName().equals(requirementNodeFilterCapabilityDataDefinition.getName())).findAny();
+
+ if (existingCap.isPresent()) {
+ final ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> newProperties = requirementNodeFilterCapabilityDataDefinition.getProperties();
+ final ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> existingProperties = existingCap.get().getProperties();
+ newProperties.getListToscaDataDefinition().stream().forEach((prop -> existingProperties.add(prop))) ;
+ } else {
+ capabilities.getListToscaDataDefinition().add(requirementNodeFilterCapabilityDataDefinition);
+ }
nodeFilterDataDefinition.setCapabilities(capabilities);
return addOrUpdateNodeFilter(true, componentId, componentInstanceId, nodeFilterDataDefinition);
}