Add is_include to parameter 45/24345/1
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Wed, 4 Oct 2017 04:57:42 +0000 (10:27 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Tue, 14 Nov 2017 09:09:54 +0000 (14:39 +0530)
Issue-Id: CLI-66

Change-Id: I91c513709c40808f720ace049b28e8e1ba798e33
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
framework/src/main/java/org/onap/cli/fw/conf/Constants.java
framework/src/main/java/org/onap/cli/fw/input/OnapCommandParameter.java
framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
framework/src/test/resources/sample-test-schema.yaml

index 64747bf..c379a87 100644 (file)
@@ -109,6 +109,7 @@ public class Constants {
     public static final String IS_OPTIONAL = "is_optional";
     public static final String DEFAULT_VALUE = "default_value";
     public static final String IS_SECURED = "is_secured";
+    public static final String IS_INCLUDE = "is_include";
 
     public static final String DIRECTION = "direction";
     public static final String ATTRIBUTES = "attributes";
index 3ba15ff..2a91f8d 100644 (file)
@@ -87,9 +87,17 @@ public class OnapCommandParameter {
 
     /*
      * raw value, get stored as its without processing it.
+     * it will have same value as stored in yaml template
      */
     private Object rawValue = null;
 
+    /*
+     * to support include concepts of templates, new variable
+     * called is_include is introduced and default its always
+     * true.
+     */
+    private boolean isInclude = true;
+
     public String getName() {
         return cmdName;
     }
@@ -236,6 +244,14 @@ public class OnapCommandParameter {
         this.isSecured = isSecured;
     }
 
+    public boolean isInclude() {
+        return isInclude;
+    }
+
+    public void setInclude(boolean isInclude) {
+        this.isInclude = isInclude;
+    }
+
     public static String printShortOption(String option) {
         return "-" + option;
     }
index 2261766..29e00b0 100644 (file)
@@ -64,6 +64,7 @@ import static org.onap.cli.fw.conf.Constants.INPUT_PARAMS_LIST;
 import static org.onap.cli.fw.conf.Constants.INPUT_PARAMS_MANDATORY_LIST;
 import static org.onap.cli.fw.conf.Constants.IS_OPTIONAL;
 import static org.onap.cli.fw.conf.Constants.IS_SECURED;
+import static org.onap.cli.fw.conf.Constants.IS_INCLUDE;
 import static org.onap.cli.fw.conf.Constants.LONG_OPTION;
 import static org.onap.cli.fw.conf.Constants.METHOD;
 import static org.onap.cli.fw.conf.Constants.METHOD_TYPE;
@@ -674,6 +675,21 @@ public class OnapCommandUtils {
                                             param.setSecured(false);
                                         }
                                         break;
+
+                                    case IS_INCLUDE:
+                                        if (validate) {
+                                            if (!validateBoolean(String.valueOf(parameter.get(key2)))) {
+                                                exceptionList.add(invalidBooleanValueMessage(parameter.get(NAME),
+                                                        IS_INCLUDE, parameter.get(key2)));
+                                            }
+                                        }
+
+                                        if ("true".equalsIgnoreCase(String.valueOf(parameter.get(key2)))) {
+                                            param.setInclude(true);
+                                        } else {
+                                            param.setInclude(false);
+                                        }
+                                        break;
                                 }
                             }
 
index d77cb11..37623dd 100644 (file)
@@ -14,6 +14,7 @@ parameters:
     long_option: bool
     is_optional: true
     default_value: false
+    is_include: true
   - name: secure-param
     type: string
     description: Onap secure param such as password