diff options
author | aribeiro <anderson.ribeiro@est.tech> | 2020-08-28 19:11:59 +0100 |
---|---|---|
committer | Sébastien Determe <sebastien.determe@intl.att.com> | 2020-09-07 10:05:25 +0000 |
commit | de805023e2d1c8565efc9a707a82c9fc3903ab38 (patch) | |
tree | 2062200adf5cef5fb6526d735291e07247516dd7 /catalog-be | |
parent | 81c04901ba03a1b696c5198ec84cda767101aa3c (diff) |
Retrieve node_filter capabilities
Issue-ID: SDC-3270
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Change-Id: Ieb1b3c4d31a50e73112fc34cdd8d5fd9ba9e6a30
Diffstat (limited to 'catalog-be')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java | 37 |
1 files changed, 27 insertions, 10 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 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<RequirementNodeFilterPropertyDataDefinition> nodeFilterProperties = + inNodeFilter.getProperties(); + if (nodeFilterProperties != null && !nodeFilterProperties.isEmpty()) { + final List<UIConstraint> propertiesConstraint = nodeFilterProperties.getListToscaDataDefinition() + .stream() + .map(property -> property.getConstraints().iterator().next()) + .map(constraintConvertor::convert) + .collect(Collectors.toList()); + uiNodeFilter.setProperties(propertiesConstraint); } - List<UIConstraint> constraints = inNodeFilter.getProperties().getListToscaDataDefinition().stream() - .map(property -> property.getConstraints().iterator().next()) - .map(constraintConvertor::convert) - .collect(Collectors.toList()); - retVal.setProperties(constraints); - return retVal; + final ListDataDefinition<RequirementNodeFilterCapabilityDataDefinition> nodeFilterCapabilities = + inNodeFilter.getCapabilities(); + if (nodeFilterCapabilities != null && !nodeFilterCapabilities.isEmpty()) { + final List<UIConstraint> 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; } } |