summaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2023-03-21 16:54:46 +0000
committerMichael Morris <michael.morris@est.tech>2023-05-25 09:26:35 +0000
commit468d0770593e167990df815e45cde717bd845d18 (patch)
treef4f6fd1838bdca5afa60295726acdd41de677980 /catalog-model
parent871b9813322801509a566b49a1cdcc65c052de29 (diff)
Support TOSCA functions in operation inputs
Issue-ID: SDC-4442 Signed-off-by: franciscovila <javier.paradela.vila@est.tech> Change-Id: I1e6135da6f41d512a7758d5494df12da874d7146
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();
}