aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Aharoni <pa0916@att.com>2017-10-02 16:27:22 +0300
committerPavel Aharoni <pa0916@att.com>2017-10-02 16:27:22 +0300
commit1cbc7e2fd5a9c743f6ddd51e003a7e1ddb03ae43 (patch)
tree420723b70a597fc48319df256226b77c09afd73e
parent098f0718bc90415be59cfbb5bbd7aed17e3d6fb7 (diff)
[SDC-426] get_input fix
Change-Id: I86e8f9d7bfe4f34ef305c81e82af818f661f6ddb Signed-off-by: Pavel Aharoni <pa0916@att.com>
-rw-r--r--pom.xml2
-rw-r--r--src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java41
2 files changed, 26 insertions, 17 deletions
diff --git a/pom.xml b/pom.xml
index cf28b14..f94da34 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<groupId>org.openecomp.sdc.jtosca</groupId>
<artifactId>jtosca</artifactId>
- <version>1.1.12-SNAPSHOT</version>
+ <version>1.1.13-SNAPSHOT</version>
<name>sdc-jtosca</name>
<properties>
diff --git a/src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java b/src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java
index 0278508..3437735 100644
--- a/src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java
+++ b/src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java
@@ -98,31 +98,40 @@ public abstract class Function {
if (rawFunctionObj instanceof LinkedHashMap) { // In map type case
LinkedHashMap rawFunction = ((LinkedHashMap) rawFunctionObj);
- if(rawFunction.size() == 1) { // End point
+ if(rawFunction.size() == 1 &&
+ !(rawFunction.values().iterator().next() instanceof LinkedHashMap)) { // End point
return getFunctionForObjectItem(ttpl, context, rawFunction, resolveGetInput);
} else {
- // iterate over map nested properties in recursion, convert leaves to function,
- // and collect them in the same hierarchy as the original map.
- LinkedHashMap rawFunctionObjMap = new LinkedHashMap();
- for (Object rawFunctionObjItem: rawFunction.entrySet()) {
- Object itemValue = getFunction(ttpl, context, ((Map.Entry)rawFunctionObjItem).getValue(), resolveGetInput);
- rawFunctionObjMap.put(((Map.Entry)rawFunctionObjItem).getKey(), itemValue);
- }
- return rawFunctionObjMap;
+ return getFunctionForMap(ttpl, context, rawFunction, resolveGetInput);
}
} else if (rawFunctionObj instanceof ArrayList) { // In list type case
- // iterate over list properties in recursion, convert leaves to function,
- // and collect them in the same hierarchy as the original list.
- ArrayList<Object> rawFunctionObjList = new ArrayList<>();
- for (Object rawFunctionObjItem: (ArrayList) rawFunctionObj) {
- rawFunctionObjList.add(getFunction(ttpl, context, rawFunctionObjItem, resolveGetInput));
- }
- return rawFunctionObjList;
+ return getFunctionForList(ttpl, context, (ArrayList) rawFunctionObj, resolveGetInput);
}
return rawFunctionObj;
}
+ private static Object getFunctionForList(TopologyTemplate ttpl, Object context, ArrayList rawFunctionObj, boolean resolveGetInput) {
+ // iterate over list properties in recursion, convert leaves to function,
+ // and collect them in the same hierarchy as the original list.
+ ArrayList<Object> rawFunctionObjList = new ArrayList<>();
+ for (Object rawFunctionObjItem: rawFunctionObj) {
+ rawFunctionObjList.add(getFunction(ttpl, context, rawFunctionObjItem, resolveGetInput));
+ }
+ return rawFunctionObjList;
+ }
+
+ private static Object getFunctionForMap(TopologyTemplate ttpl, Object context, LinkedHashMap rawFunction, boolean resolveGetInput) {
+ // iterate over map nested properties in recursion, convert leaves to function,
+ // and collect them in the same hierarchy as the original map.
+ LinkedHashMap rawFunctionObjMap = new LinkedHashMap();
+ for (Object rawFunctionObjItem: rawFunction.entrySet()) {
+ Object itemValue = getFunction(ttpl, context, ((Map.Entry)rawFunctionObjItem).getValue(), resolveGetInput);
+ rawFunctionObjMap.put(((Map.Entry)rawFunctionObjItem).getKey(), itemValue);
+ }
+ return rawFunctionObjMap;
+ }
+
private static Object getFunctionForObjectItem(TopologyTemplate ttpl, Object context, Object rawFunctionObjItem, boolean resolveGetInput) {
if(isFunction(rawFunctionObjItem)) {
LinkedHashMap<String, Object> rawFunction = (LinkedHashMap<String, Object>) rawFunctionObjItem;