summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-09-29 11:37:47 +0100
committerS�bastien Determe <sebastien.determe@intl.att.com>2020-10-23 14:53:39 +0000
commit378b6774ddad25d74ba7f05d173bc794b3963c7c (patch)
tree5589524ef8f29550ebcdc08fdb178a408b12f213
parenta5a46f26d043b70cd9a44fed05b0e8ba184318fb (diff)
Fix substitution_mapping property mapping
Currently the properties in substitution_mapping are being generated as property definition, copying the inputs. They should be property mappings referring inputs. Change-Id: I0b3b056adeab79915db1b42218364c22f07a079f Issue-ID: SDC-3307 Signed-off-by: andre.schmid <andre.schmid@est.tech>
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java26
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/SubstitutionMapping.java2
2 files changed, 17 insertions, 11 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 0907dd1f9b..d0c14f77c5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -28,6 +28,7 @@ import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.addInterf
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -367,9 +368,10 @@ public class ToscaExportHandler {
return Either.right(requirements.right().value());
}
substitutionMapping = requirements.left().value();
-
- final Optional<Map<String, ToscaProperty>> proxyInputProperties = getProxyNodeTypeInputProperties(component, dataTypes);
- proxyInputProperties.ifPresent(substitutionMapping::setProperties);
+ final Map<String, String[]> propertyMappingMap = buildSubstitutionMappingPropertyMapping(component);
+ if (!propertyMappingMap.isEmpty()) {
+ substitutionMapping.setProperties(propertyMappingMap);
+ }
topologyTemplate.setSubstitution_mappings(substitutionMapping);
@@ -1735,14 +1737,18 @@ public class ToscaExportHandler {
}
- private Optional<Map<String, ToscaProperty>> getProxyNodeTypeInputProperties(final Component proxyComponent,
- final Map<String, DataTypeDefinition> dataTypes) {
- if (Objects.isNull(proxyComponent)) {
- return Optional.empty();
+ private Map<String, String[]> buildSubstitutionMappingPropertyMapping(final Component component) {
+ if (component == null || CollectionUtils.isEmpty(component.getInputs())) {
+ return Collections.emptyMap();
}
- final Map<String, ToscaProperty> proxyInputProperties = new HashMap<>();
- addInputsToProperties(dataTypes, proxyComponent.getInputs(), proxyInputProperties);
- return MapUtils.isNotEmpty(proxyInputProperties) ? Optional.of(proxyInputProperties) : Optional.empty();
+ return component.getInputs().stream()
+ .map(PropertyDataDefinition::getName)
+ .collect(
+ Collectors.toMap(
+ inputName -> inputName,
+ inputName -> new String[]{inputName},
+ (inputName1, inputName2) -> inputName1)
+ );
}
Optional<Map<String, ToscaProperty>> getProxyNodeTypeProperties(Component proxyComponent,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/SubstitutionMapping.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/SubstitutionMapping.java
index 13a28db038..1a2a13817b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/SubstitutionMapping.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/SubstitutionMapping.java
@@ -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;
+ private Map<String, String[]> properties;
}