aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2020-08-28 19:11:59 +0100
committerSébastien Determe <sebastien.determe@intl.att.com>2020-09-07 10:05:25 +0000
commitde805023e2d1c8565efc9a707a82c9fc3903ab38 (patch)
tree2062200adf5cef5fb6526d735291e07247516dd7 /catalog-be/src/main
parent81c04901ba03a1b696c5198ec84cda767101aa3c (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/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java37
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;
}
}