summaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java17
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverter.java6
3 files changed, 17 insertions, 9 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
index af1749fb34..42781b21d8 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
@@ -1669,10 +1669,11 @@ public class ToscaOperationFacade {
GraphVertex vertex = getVertexEither.left().value();
Map<String, MapInterfaceDataDefinition> instInterfacesMap = new HashMap<>();
if (instInterfaces != null) {
- MapInterfaceDataDefinition interfacesMap = new MapInterfaceDataDefinition();
+
for (Map.Entry<String, Map<String, InterfaceDefinition>> entryInstances : instInterfaces.entrySet()) {
Map<String, InterfaceDataDefinition> incomingInterfacesMap = entryInstances.getValue().entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
+ MapInterfaceDataDefinition interfacesMap = new MapInterfaceDataDefinition();
interfacesMap.setMapToscaDataDefinition(incomingInterfacesMap);
instInterfacesMap.put(entryInstances.getKey(), interfacesMap);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java
index 5edd08237d..0ea73711a7 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java
@@ -131,12 +131,13 @@ public class ToscaMapValueConverter extends ToscaValueBaseConverter implements T
}
}
}
- final Object convertedValue = convertDataTypeToToscaObject(propType, dataTypes, innerConverterProp, scalar, e.getValue(), false);
+ final Object convertedValue = convertDataTypeToToscaObject(propType, dataTypes, innerConverterProp, scalar, e.getValue(), false, false);
toscaMap.put(e.getKey(), convertedValue);
}
public Object convertDataTypeToToscaObject(String innerType, Map<String, DataTypeDefinition> dataTypes, ToscaValueConverter innerConverter,
- final boolean isScalarF, JsonElement entryValue, boolean preserveEmptyValue) {
+ final boolean isScalarF, JsonElement entryValue, boolean preserveEmptyValue,
+ final boolean isToscaFunction) {
Object convertedValue;
if (isScalarF && isJsonElementAJsonPrimitive(entryValue)) {
return innerConverter.convertToToscaValue(entryValue.getAsString(), innerType, dataTypes);
@@ -149,25 +150,29 @@ public class ToscaMapValueConverter extends ToscaValueBaseConverter implements T
ArrayList<Object> toscaObjectPresentationArray = new ArrayList<>();
JsonArray jsonArray = entryValue.getAsJsonArray();
for (JsonElement jsonElement : jsonArray) {
- Object convertedDataTypeToToscaMap = convertDataTypeToToscaMap(innerType, dataTypes, isScalarF, jsonElement, preserveEmptyValue);
+ Object convertedDataTypeToToscaMap = convertDataTypeToToscaMap(innerType, dataTypes, isScalarF, jsonElement, preserveEmptyValue,
+ isToscaFunction);
toscaObjectPresentationArray.add(convertedDataTypeToToscaMap);
}
convertedValue = toscaObjectPresentationArray;
} else {
- convertedValue = convertDataTypeToToscaMap(innerType, dataTypes, isScalarF, entryValue, preserveEmptyValue);
+ convertedValue = convertDataTypeToToscaMap(innerType, dataTypes, isScalarF, entryValue, preserveEmptyValue, isToscaFunction);
}
}
return convertedValue;
}
private Object convertDataTypeToToscaMap(String innerType, Map<String, DataTypeDefinition> dataTypes, final boolean isScalarF,
- JsonElement entryValue, boolean preserveEmptyValue) {
+ JsonElement entryValue, boolean preserveEmptyValue, final boolean isToscaFunction) {
Object convertedValue;
if (entryValue.isJsonPrimitive()) {
return json2JavaPrimitive(entryValue.getAsJsonPrimitive());
}
JsonObject asJsonObjectIn = entryValue.getAsJsonObject();
- DataTypePropertyConverter.getInstance().mergeDataTypeDefaultValuesWithPropertyValue(asJsonObjectIn, innerType, dataTypes);
+ if (!isToscaFunction) {
+ DataTypePropertyConverter.getInstance()
+ .mergeDataTypeDefaultValuesWithPropertyValue(asJsonObjectIn, innerType, dataTypes);
+ }
Map<String, Object> toscaObjectPresentation = new HashMap<>();
Set<Entry<String, JsonElement>> entrySetIn = asJsonObjectIn.entrySet();
for (Entry<String, JsonElement> entry : entrySetIn) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverter.java
index c9b5db8e87..e8d342aaec 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverter.java
@@ -34,6 +34,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import org.apache.commons.lang3.math.NumberUtils;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
@@ -134,10 +135,11 @@ public class ToscaValueBaseConverter {
if (jsonPrimitive.isBoolean()) {
return jsonPrimitive.getAsBoolean();
}
- if (jsonPrimitive.isString()) {
+ if (jsonPrimitive.isString() && !NumberUtils.isCreatable(jsonPrimitive.getAsString())) {
return jsonPrimitive.getAsString();
}
- if (jsonPrimitive.isNumber()) {
+ if (jsonPrimitive.isNumber() ||
+ (jsonPrimitive.isString() && NumberUtils.isCreatable(jsonPrimitive.getAsString()))) {
if (jsonPrimitive.getAsString().contains(".")) {
return jsonPrimitive.getAsDouble();
}