[SDC-426] get_input fix
authorPavel Aharoni <pa0916@att.com>
Mon, 2 Oct 2017 13:27:22 +0000 (16:27 +0300)
committerPavel Aharoni <pa0916@att.com>
Mon, 2 Oct 2017 13:27:22 +0000 (16:27 +0300)
Change-Id: I86e8f9d7bfe4f34ef305c81e82af818f661f6ddb
Signed-off-by: Pavel Aharoni <pa0916@att.com>
pom.xml
src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java

diff --git a/pom.xml b/pom.xml
index cf28b14..f94da34 100644 (file)
--- 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>
 
index 0278508..3437735 100644 (file)
@@ -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;