aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java
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 /catalog-model/src/main/java
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
Diffstat (limited to 'catalog-model/src/main/java')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java14
1 files changed, 13 insertions, 1 deletions
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);
}