Allows custom property type names 55/126155/5
authoraribeiro <anderson.ribeiro@est.tech>
Wed, 8 Dec 2021 11:27:37 +0000 (11:27 +0000)
committerMichael Morris <michael.morris@est.tech>
Fri, 17 Dec 2021 09:37:57 +0000 (09:37 +0000)
When onboarding a VSP with private data types SDC shall allow
custom property type name on its declaration.

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

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

index d228db5..cdd5d60 100644 (file)
@@ -814,8 +814,8 @@ public class ToscaExportHandler {
                     toscaDataType.setProperties(dataType.getProperties().stream()
                         .collect(Collectors.toMap(
                             PropertyDataDefinition::getName,
-                            s -> propertyConvertor
-                                .convertProperty(dataTypes, s, PropertyType.PROPERTY)
+                            s -> propertyConvertor.convertProperty(dataTypes, s, PropertyType.PROPERTY),
+                            (toscaPropertyTobeValidated, toscaProperty) -> validateToscaProperty(privateDataTypes, toscaPropertyTobeValidated, toscaProperty)
                         )));
                 }
                 toscaDataTypeMap.put(dataType.getName(), toscaDataType);
@@ -827,6 +827,13 @@ public class ToscaExportHandler {
         return convertReqCapAndTypeName(componentsCache, component, toscaNode, nodeTypes, toscaNodeType, dataTypes);
     }
 
+    private ToscaProperty validateToscaProperty(final List<DataTypeDefinition> privateDataTypes, final ToscaProperty toscaPropertyTobeValidated,
+                                                final ToscaProperty toscaProperty) {
+        final Optional<DataTypeDefinition> match = privateDataTypes.stream()
+            .filter(dataType -> dataType.getName().equals(toscaPropertyTobeValidated.getType())).findFirst();
+        return match.isPresent() ? toscaPropertyTobeValidated : toscaProperty;
+    }
+
     private Map<String, ToscaAttribute> convertToToscaAttributes(final List<AttributeDefinition> attributeList,
                                                                  final Map<String, DataTypeDefinition> dataTypes) {
         if (CollectionUtils.isEmpty(attributeList)) {