From 7ed4d73221126eeb6d02f8f577123c8362b0afd7 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Thu, 12 Oct 2017 14:10:30 +0530 Subject: Add type to schema-refresh command Issue-Id: CLI-66 Change-Id: I2f6ff7b2eb0584aedb796dc814f6294e26f1f407 Signed-off-by: Kanagaraj Manickam k00365106 --- .../java/org/onap/cli/fw/OnapCommandSchema.java | 2 -- .../onap/cli/fw/cmd/OnapSchemaRefreshCommand.java | 38 +++++----------------- .../main/java/org/onap/cli/fw/conf/Constants.java | 4 +-- .../resources/open-cli-schema/schema-refresh.yaml | 6 +++- 4 files changed, 16 insertions(+), 34 deletions(-) diff --git a/framework/src/main/java/org/onap/cli/fw/OnapCommandSchema.java b/framework/src/main/java/org/onap/cli/fw/OnapCommandSchema.java index d7254fb2..16b53ea6 100644 --- a/framework/src/main/java/org/onap/cli/fw/OnapCommandSchema.java +++ b/framework/src/main/java/org/onap/cli/fw/OnapCommandSchema.java @@ -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 diff --git a/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommand.java b/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommand.java index 0ea4ef08..53d01a50 100644 --- a/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommand.java +++ b/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommand.java @@ -16,15 +16,13 @@ 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 slNumbers = new ArrayList<>(); - List cmdNames = new ArrayList<>(); - List cmdFiles = new ArrayList<>(); - List versions = new ArrayList<>(); - List 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()); } } diff --git a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java index a0133404..a43dec2b 100644 --- a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java +++ b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java @@ -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"; diff --git a/framework/src/main/resources/open-cli-schema/schema-refresh.yaml b/framework/src/main/resources/open-cli-schema/schema-refresh.yaml index 349554b0..86829534 100644 --- a/framework/src/main/resources/open-cli-schema/schema-refresh.yaml +++ b/framework/src/main/resources/open-cli-schema/schema-refresh.yaml @@ -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 -- cgit 1.2.3-korg