Fix policy property type issue 03/102003/3
authorDmitry Puzikov <dmitry.puzikov@tieto.com>
Wed, 19 Feb 2020 15:06:51 +0000 (16:06 +0100)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Thu, 5 Mar 2020 08:10:12 +0000 (08:10 +0000)
When VF is exported as csar, policy properties
are typed regardless types in the related shemas.
This patch fixes this issue.

Change-Id: Ib34f329888d454283c89a8a1aec6349069ea7234
Issue-ID: SDC-2773
Signed-off-by: Dmitry Puzikov <d.puzikov2@partner.samsung.com>
catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java

index 5bbd38e..163d59a 100644 (file)
@@ -122,24 +122,22 @@ public class ToscaMapValueConverter extends ToscaValueBaseConverter implements T
         }
     }
 
-    private void convertEntry(String innerType, Map<String, DataTypeDefinition> dataTypes, List<PropertyDefinition> allPropertiesRecursive, Map<String, Object> toscaMap, final boolean isScalarF, final ToscaValueConverter innerConverterFinal,
-            Entry<String, JsonElement> e) {
+    private void convertEntry(final String innerType, final Map<String, DataTypeDefinition> dataTypes,
+            final List<PropertyDefinition> allPropertiesRecursive, final Map<String, Object> toscaMap, final boolean isScalarF,
+            final ToscaValueConverter innerConverterFinal, final Entry<String, JsonElement> e) {
         log.debug("try convert element ");
-        boolean scalar = false;
-        String propType = null;
+        boolean scalar = isScalarF;
+        String propType = innerType;
         ToscaValueConverter innerConverterProp = innerConverterFinal;
-        if ( isScalarF ){
-            scalar = isScalarF;
-            propType = innerType;
-        }else{
-            for ( PropertyDefinition pd : allPropertiesRecursive ){
-                if ( pd.getName().equals(e.getKey()) ){
+        if (!scalar) {
+            for (PropertyDefinition pd : allPropertiesRecursive) {
+                if (pd.getName().equals(e.getKey())) {
                     propType = pd.getType();
-                    DataTypeDefinition pdDataType = dataTypes.get(propType);
-                    ToscaPropertyType toscaPropType = isScalarType(pdDataType);
-                    if ( toscaPropType == null ){
+                    final DataTypeDefinition pdDataType = dataTypes.get(propType);
+                    final ToscaPropertyType toscaPropType = isScalarType(pdDataType);
+                    if (toscaPropType == null) {
                         scalar = false;
-                    }else{
+                    } else {
                         scalar = true;
                         propType = toscaPropType.getType();
                         innerConverterProp = toscaPropType.getValueConverter();
@@ -148,7 +146,8 @@ public class ToscaMapValueConverter extends ToscaValueBaseConverter implements T
                 }
             }
         }
-        Object convertedValue = convertDataTypeToToscaObject(propType, dataTypes, innerConverterProp, scalar, e.getValue(), false);
+        final Object convertedValue =
+                convertDataTypeToToscaObject(propType, dataTypes, innerConverterProp, scalar, e.getValue(), false);
         toscaMap.put(e.getKey(), convertedValue);
     }