From de805023e2d1c8565efc9a707a82c9fc3903ab38 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Fri, 28 Aug 2020 19:11:59 +0100 Subject: Retrieve node_filter capabilities Issue-ID: SDC-3270 Signed-off-by: aribeiro Change-Id: Ieb1b3c4d31a50e73112fc34cdd8d5fd9ba9e6a30 --- .../sdc/be/tosca/utils/NodeFilterConverter.java | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'catalog-be/src/main') 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 cab7d53cd7..d1e22f9fa2 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 @@ -21,6 +21,9 @@ import java.util.Map; import java.util.stream.Collectors; import org.openecomp.sdc.be.datamodel.utils.ConstraintConvertor; import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterCapabilityDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterPropertyDataDefinition; import org.openecomp.sdc.be.ui.model.UIConstraint; import org.openecomp.sdc.be.ui.model.UINodeFilter; @@ -31,17 +34,31 @@ public class NodeFilterConverter { return inMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, o -> convertToUi(o.getValue()))); } - public UINodeFilter convertToUi(CINodeFilterDataDefinition inNodeFilter) { - UINodeFilter retVal = new UINodeFilter(); + public UINodeFilter convertToUi(final CINodeFilterDataDefinition inNodeFilter) { + final UINodeFilter uiNodeFilter = new UINodeFilter(); final ConstraintConvertor constraintConvertor = new ConstraintConvertor(); - if (inNodeFilter.getProperties() == null || inNodeFilter.getProperties().isEmpty()) { - return retVal; + final ListDataDefinition nodeFilterProperties = + inNodeFilter.getProperties(); + if (nodeFilterProperties != null && !nodeFilterProperties.isEmpty()) { + final List propertiesConstraint = nodeFilterProperties.getListToscaDataDefinition() + .stream() + .map(property -> property.getConstraints().iterator().next()) + .map(constraintConvertor::convert) + .collect(Collectors.toList()); + uiNodeFilter.setProperties(propertiesConstraint); } - List constraints = inNodeFilter.getProperties().getListToscaDataDefinition().stream() - .map(property -> property.getConstraints().iterator().next()) - .map(constraintConvertor::convert) - .collect(Collectors.toList()); - retVal.setProperties(constraints); - return retVal; + final ListDataDefinition nodeFilterCapabilities = + inNodeFilter.getCapabilities(); + if (nodeFilterCapabilities != null && !nodeFilterCapabilities.isEmpty()) { + final List capabilitiesConstraint = nodeFilterCapabilities.getListToscaDataDefinition() + .stream() + .map(capabilities -> capabilities.getProperties().getListToscaDataDefinition().iterator().next()) + .map(property -> property.getConstraints().iterator().next()) + .map(constraintConvertor::convert) + .collect(Collectors.toList()); + uiNodeFilter.setCapabilities(capabilitiesConstraint); + } + + return uiNodeFilter; } } -- cgit 1.2.3-korg