[SDC-39] filter nt props values by operator
authorPavel Aharoni <pa0916@att.com>
Mon, 26 Jun 2017 14:16:37 +0000 (17:16 +0300)
committerPavel Aharoni <pa0916@att.com>
Mon, 26 Jun 2017 14:17:02 +0000 (17:17 +0300)
Change-Id: I5ac27ba682923960d5dfa9f5f770afdb7fac6ae1
Signed-off-by: Pavel Aharoni <pa0916@att.com>
README.md
pom.xml
src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java
src/main/java/org/openecomp/sdc/toscaparser/api/functions/GetInput.java

index 2c0f5e0..6913f03 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
 # OpenECOMP JTOSCA
-\r
+
 
 ---
 ---
@@ -26,3 +26,16 @@ SDC Javadoc and Maven site
  
 *** to be completed on rrelease ***
 
+# Release notes for versions
+
+1.1.0-SNAPSHOT
+
+Initial after separating into separate repo
+
+-------------------------------
+
+1.1.1-SNAPSHOT
+
+Added toString of Function (GetInput, etc.)
+
+Allowed two arguments for GetInput - name of list input and index in list
diff --git a/pom.xml b/pom.xml
index 61a504b..d092e57 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
 
        <groupId>org.openecomp.sdc.jtosca</groupId>
        <artifactId>jtosca</artifactId>
-       <version>1.1.0-SNAPSHOT</version>\r
+       <version>1.1.1-SNAPSHOT</version>\r
 \r
        <properties>\r
 \r
index 102fbc0..5e5f31f 100644 (file)
@@ -113,24 +113,29 @@ public abstract class Function {
                                }
                                else if(funcType.equals("GetAttribute")) {
                                        return new GetAttribute(ttpl,context,funcName,funcArgs);
-                               } 
+                               }
                                else if(funcType.equals("GetProperty")) {
                                        return new GetProperty(ttpl,context,funcName,funcArgs);
-                               } 
+                               }
                                else if(funcType.equals("GetOperationOutput")) {
                                        return new GetOperationOutput(ttpl,context,funcName,funcArgs);
-                               } 
+                               }
                                else if(funcType.equals("Concat")) {
                                        return new Concat(ttpl,context,funcName,funcArgs);
-                               } 
+                               }
                                else if(funcType.equals("Token")) {
                                        return new Token(ttpl,context,funcName,funcArgs);
-                               } 
+                               }
                        }
                }
            }
            return rawFunctionObj;
        }
+
+       @Override
+       public String toString() {
+               return name + ":" + args.toString();
+       }
 }
 
 /*python
index 4332f70..62f2b39 100644 (file)
@@ -18,12 +18,17 @@ public class GetInput extends Function {
 
        @Override
        void validate() {
-           if(args.size() != 1) {
-               //PA - changed to WARNING from CRITICAL after talking to Renana, 22/05/2017
-               ThreadLocalsHolder.getCollector().appendWarning(String.format(
-                   "ValueError: Expected one argument for function \"get_input\" but received \"%s\"",
-                   args.toString()));
-           }
+//         if(args.size() != 1) {
+//             //PA - changed to WARNING from CRITICAL after talking to Renana, 22/05/2017
+//             ThreadLocalsHolder.getCollector().appendWarning(String.format(
+//                 "ValueError: Expected one argument for function \"get_input\" but received \"%s\"",
+//                 args.toString()));
+//         }
+               if(args.size() > 2) {
+                       ThreadLocalsHolder.getCollector().appendWarning(String.format(
+                                       "ValueError: Expected max 2 arguments for function \"get_input\" but received \"%s\"",
+                                       args.size()));
+               }
            boolean bFound = false;
            for(Input inp: toscaTpl.getInputs()) {
                if(inp.getName().equals(args.get(0))) {
@@ -56,6 +61,11 @@ public class GetInput extends Function {
                        }
                }
                if(inputDef != null) {
+                       if (args.size() == 2 && args.get(1) instanceof Integer) {
+                               if (inputDef.getDefault() != null && inputDef.getDefault() instanceof ArrayList) {
+                                       return ((ArrayList) inputDef.getDefault()).get(((Integer)args.get(1)).intValue());
+                               }
+                       }
                        return inputDef.getDefault();
                }
                return null;