aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2022-08-11 11:33:01 +0100
committerMichael Morris <michael.morris@est.tech>2022-08-11 12:23:06 +0000
commit33538725267c361efe813f1a4e6eff8b69c09c9f (patch)
tree67413a8f483a26b8e7d7562b9a4e278b2694d883
parent0f6ae59460165381a8b5da2eea58c2c2efa75f2f (diff)
Error Importing node filter with multiple capability properties
Fix importing NF with multiple Capability properties Issue-ID: SDC-4117 Signed-off-by: franciscovila <javier.paradela.vila@est.tech> Change-Id: I84fc245ddb40440d4909f5ae896b57ddf8b3740a
-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);
}