From 33538725267c361efe813f1a4e6eff8b69c09c9f Mon Sep 17 00:00:00 2001 From: franciscovila Date: Thu, 11 Aug 2022 11:33:01 +0100 Subject: Error Importing node filter with multiple capability properties Fix importing NF with multiple Capability properties Issue-ID: SDC-4117 Signed-off-by: franciscovila Change-Id: I84fc245ddb40440d4909f5ae896b57ddf8b3740a --- .../jsonjanusgraph/operations/NodeFilterOperation.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'catalog-model/src/main/java/org') 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 existingCap = capabilities + .getListToscaDataDefinition().stream() + .filter(def -> def.getName().equals(requirementNodeFilterCapabilityDataDefinition.getName())).findAny(); + + if (existingCap.isPresent()) { + final ListDataDefinition newProperties = requirementNodeFilterCapabilityDataDefinition.getProperties(); + final ListDataDefinition 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); } -- cgit 1.2.3-korg