Map topology inputs to properties in substitution mapping 40/111640/4
authoraribeiro <anderson.ribeiro@est.tech>
Fri, 21 Aug 2020 08:17:56 +0000 (09:17 +0100)
committerJulien Bertozzi <julien.bertozzi@intl.att.com>
Mon, 7 Sep 2020 09:24:34 +0000 (09:24 +0000)
Allows to map properties of the node_type to inputs of
the topology template for a service

Issue-ID: SDC-3254
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Change-Id: Iee49fe0ac29a39b98d8dc8185401f4d1c4aeffbb

catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/SubstitutionMapping.java

index 45db4f7..b59930e 100644 (file)
@@ -367,6 +367,9 @@ public class ToscaExportHandler {
         }
         substitutionMapping = requirements.left().value();
 
+        final Optional<Map<String, ToscaProperty>> proxyInputProperties = getProxyNodeTypeInputProperties(component, dataTypes);
+        proxyInputProperties.ifPresent(substitutionMapping::setProperties);
+
         topologyTemplate.setSubstitution_mappings(substitutionMapping);
 
         toscaNode.setTopology_template(topologyTemplate);
@@ -1726,6 +1729,16 @@ public class ToscaExportHandler {
 
     }
 
+    private Optional<Map<String, ToscaProperty>> getProxyNodeTypeInputProperties(final Component proxyComponent,
+                                                                                 final Map<String, DataTypeDefinition> dataTypes) {
+        if (Objects.isNull(proxyComponent)) {
+            return Optional.empty();
+        }
+        final Map<String, ToscaProperty> proxyInputProperties = new HashMap<>();
+        addInputsToProperties(dataTypes, proxyComponent.getInputs(), proxyInputProperties);
+        return MapUtils.isNotEmpty(proxyInputProperties) ? Optional.of(proxyInputProperties) : Optional.empty();
+    }
+
     Optional<Map<String, ToscaProperty>> getProxyNodeTypeProperties(Component proxyComponent,
                                                                     Map<String, DataTypeDefinition>
                                                                         dataTypes) {
index 376f211..13a28db 100644 (file)
@@ -38,5 +38,5 @@ public class SubstitutionMapping {
     private Map<String, String[]> capabilities;
     private Map<String, String[]> requirements;
     private NodeFilter substitution_filter;
-
+    private Map<String, ToscaProperty> properties;
 }