Add type to schema-refresh command 77/24377/7
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Thu, 12 Oct 2017 08:40:30 +0000 (14:10 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Mon, 20 Nov 2017 08:37:05 +0000 (14:07 +0530)
Issue-Id: CLI-66

Change-Id: I2f6ff7b2eb0584aedb796dc814f6294e26f1f407
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
framework/src/main/java/org/onap/cli/fw/OnapCommandSchema.java
framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommand.java
framework/src/main/java/org/onap/cli/fw/conf/Constants.java
framework/src/main/resources/open-cli-schema/schema-refresh.yaml

index d7254fb..16b53ea 100644 (file)
@@ -20,8 +20,6 @@ import java.lang.annotation.Documented;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
-import org.onap.cli.fw.cmd.CommandType;
-
 /**
  * Provide command name and schema file location, which is placed in the main resources folder (in classpath). It is
  * recommended to keep the name for schema, in the form of oclip-[command-name]-schema.yaml, considered this format as
index 0ea4ef0..53d01a5 100644 (file)
 
 package org.onap.cli.fw.cmd;
 
+import java.util.List;
+
 import org.onap.cli.fw.OnapCommand;
 import org.onap.cli.fw.OnapCommandSchema;
 import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.output.OnapCommandResultAttribute;
-import org.onap.cli.fw.utils.SchemaInfo;
 import org.onap.cli.fw.utils.OnapCommandUtils;
-
-import java.util.ArrayList;
-import java.util.List;
+import org.onap.cli.fw.utils.SchemaInfo;
 
 /**
  * Refresh external schema.
@@ -40,32 +38,14 @@ public class OnapSchemaRefreshCommand extends OnapCommand {
         // Will override the existing json file
         OnapCommandUtils.persistSchemaInfo(schemas);
 
-        List<String> slNumbers = new ArrayList<>();
-        List<String> cmdNames = new ArrayList<>();
-        List<String> cmdFiles = new ArrayList<>();
-        List<String> versions = new ArrayList<>();
-        List<String> cmdVersions = new ArrayList<>();
-
         for (int i = 0; i < schemas.size(); i++) {
             SchemaInfo schema = schemas.get(i);
-            slNumbers.add(String.valueOf(i + 1));
-            cmdNames.add(schema.getCmdName());
-            cmdFiles.add(schema.getSchemaName());
-            versions.add(schema.getVersion());
-            cmdVersions.add(schema.getProduct());
-        }
-        for (OnapCommandResultAttribute attribute : this.getResult().getRecords()) {
-            if ("sl-no".equals(attribute.getName())) {
-                attribute.setValues(slNumbers);
-            } else if ("command".equals(attribute.getName())) {
-                attribute.setValues(cmdNames);
-            } else if ("product".equals(attribute.getName())) {
-                attribute.setValues(cmdVersions);
-            } else if ("schema".equals(attribute.getName())) {
-                attribute.setValues(cmdFiles);
-            } else if ("ocs-version".equals(attribute.getName())) {
-                attribute.setValues(versions);
-            }
+            this.getResult().getRecordsMap().get("sr.no").getValues().add(String.valueOf(i + 1));
+            this.getResult().getRecordsMap().get("command").getValues().add(schema.getCmdName());
+            this.getResult().getRecordsMap().get("schema").getValues().add(schema.getSchemaName());
+            this.getResult().getRecordsMap().get("ocs-version").getValues().add(schema.getVersion());
+            this.getResult().getRecordsMap().get("product").getValues().add(schema.getProduct());
+            this.getResult().getRecordsMap().get("type").getValues().add(schema.getSchemaProfile());
         }
     }
 
index a013340..a43dec2 100644 (file)
@@ -134,8 +134,8 @@ public class Constants {
     public static final String PARAM_CACHE_FILE_NAME = "global-profile";
 
     //normal
-    public static final String BASIC_SCHEMA_PROFILE = "basic-schema";
-    public static final String HTTP_SCHEMA_PROFILE = "http-schema";
+    public static final String BASIC_SCHEMA_PROFILE = "basic";
+    public static final String HTTP_SCHEMA_PROFILE = "http";
 
     //http
     public static final String HTTP = "http";
index 349554b..8682953 100644 (file)
@@ -11,7 +11,7 @@ info:
 results:
   direction: landscape
   attributes:
-    - name: sl-no
+    - name: sr.no
       description: Serial Number
       scope: short
       type: string
@@ -30,4 +30,8 @@ results:
     - name: ocs-version
       description: Schema version
       scope: short
+      type: string
+    - name: type
+      description: Command type
+      scope: short
       type: string
\ No newline at end of file