diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-03-27 11:39:49 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-03-27 11:39:49 +0530 |
commit | f5609349ba12f9bcdccc202c57a9438f22996c26 (patch) | |
tree | a71f56fdf034214819848541c7b42328a1153510 /framework/src | |
parent | b2fe6db81ec2893d671fb02eb473f747885e40c8 (diff) |
Discover command state and persist
Issue-ID: CLI-100
Change-Id: I828f860ab5994796ceb692dbf12a7323ebd4d07a
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src')
7 files changed, 37 insertions, 2 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java index 6f1741e5..7ea4ddaa 100644 --- a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java +++ b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java @@ -58,6 +58,7 @@ public class OnapCommandConstants { public static final String INFO_TYPE = "type"; public static final String INFO_AUTHOR = "author"; public static final String INFO_IGNORE = "ignore"; + public static final String INFO_STATE = "state"; //parameters public static final String PARAMETERS = "parameters"; diff --git a/framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java b/framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java index 1496bcbb..55009a49 100644 --- a/framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java +++ b/framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java @@ -31,6 +31,8 @@ public class OnapCommandInfo { private OnapCommandType type = OnapCommandType.CMD; + private OnapCommandState state = OnapCommandState.STABLE; + private boolean ignore = false; public String getProduct() { @@ -73,5 +75,12 @@ public class OnapCommandInfo { this.ignore = ignore; } + public OnapCommandState getState() { + return state; + } + + public void setState(OnapCommandState state) { + this.state = state; + } }
\ No newline at end of file diff --git a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java index af444b8f..df30a240 100644 --- a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java +++ b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java @@ -18,6 +18,7 @@ package org.onap.cli.fw.schema; import org.onap.cli.fw.cmd.OnapCommandType; import org.onap.cli.fw.conf.OnapCommandConstants; +import org.onap.cli.fw.info.OnapCommandState; import java.util.ArrayList; import java.util.List; @@ -55,6 +56,8 @@ public class OnapCommandSchemaInfo { private String ignore = OnapCommandConstants.BOOLEAN_FALSE; + private String state = OnapCommandState.STABLE.name(); + public String getSchemaName() { return schemaName; } @@ -126,4 +129,14 @@ public class OnapCommandSchemaInfo { public List<String> getSampleFiles() { return sampleFiles; } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + } diff --git a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java index 628ddf3a..06d688b4 100644 --- a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java +++ b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java @@ -30,6 +30,7 @@ import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_PARAMS_LIST; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_PARAMS_MANDATORY_LIST; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_PRODUCT; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_SERVICE; +import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_STATE; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_TYPE; import static org.onap.cli.fw.conf.OnapCommandConstants.INPUT_PARAMS_LIST; import static org.onap.cli.fw.conf.OnapCommandConstants.INPUT_PARAMS_MANDATORY_LIST; @@ -67,7 +68,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.commons.io.FileUtils; import org.onap.cli.fw.cmd.OnapCommand; import org.onap.cli.fw.cmd.OnapCommandType; import org.onap.cli.fw.conf.OnapCommandConfig; @@ -79,6 +79,7 @@ import org.onap.cli.fw.error.OnapCommandParameterNameConflict; import org.onap.cli.fw.error.OnapCommandParameterOptionConflict; import org.onap.cli.fw.error.OnapCommandSchemaNotFound; import org.onap.cli.fw.info.OnapCommandInfo; +import org.onap.cli.fw.info.OnapCommandState; import org.onap.cli.fw.input.OnapCommandParameter; import org.onap.cli.fw.input.OnapCommandParameterType; import org.onap.cli.fw.output.OnapCommandPrintDirection; @@ -248,6 +249,11 @@ public class OnapCommandSchemaLoader { info.setCommandType(OnapCommandType.get(obj.toString())); break; + case INFO_STATE: + Object state = infoMap.get(key1); + info.setState(OnapCommandState.get(state.toString())); + break; + case INFO_AUTHOR: Object mode = infoMap.get(key1); info.setAuthor(mode.toString()); diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java index d0789d74..9bdd8a51 100644 --- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java +++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java @@ -278,6 +278,11 @@ public class OnapCommandDiscoveryUtils { if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_IGNORE) != null) { schema.setIgnore(infoMap.get(OnapCommandConstants.INFO_IGNORE).toString()); } + + if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_STATE) != null) { + schema.setState(infoMap.get(OnapCommandConstants.INFO_STATE).toString()); + } + schema.setSchemaProfile(identitySchemaProfileType(resourceMap)); extSchemas.add(schema); diff --git a/framework/src/main/resources/open-cli.properties b/framework/src/main/resources/open-cli.properties index 79800fbc..cdb6dd12 100644 --- a/framework/src/main/resources/open-cli.properties +++ b/framework/src/main/resources/open-cli.properties @@ -6,7 +6,7 @@ cli.discover_always=false cli.schema.base.sections=open_cli_schema_version,name,description,parameters,results,info cli.schema.base.sections.mandatory=open_cli_schema_version -cli.schema.base.info.sections=product,service,type,author,ignore +cli.schema.base.info.sections=product,service,type,author,ignore,state cli.schema.base.info.sections.mandatory=product,service cli.schema.base.parameters.sections=name,description,type,short_option,long_option, is_optional,default_value,is_secured,is_include,is_default_param diff --git a/framework/src/test/resources/open-cli-schema/sample-test-schema.yaml b/framework/src/test/resources/open-cli-schema/sample-test-schema.yaml index f4894b3f..2ab2127a 100644 --- a/framework/src/test/resources/open-cli-schema/sample-test-schema.yaml +++ b/framework/src/test/resources/open-cli-schema/sample-test-schema.yaml @@ -6,6 +6,7 @@ info: service: test type: cmd author: Kanagaraj Manickam kanagaraj.manickam@huawei.com + state: experimental parameters: - name: bool-param type: bool |