diff options
author | 2019-03-15 09:26:08 +0000 | |
---|---|---|
committer | 2019-03-15 09:26:08 +0000 | |
commit | 9958588b9888ab00f9b2b7d71cb2e0c301cd73dc (patch) | |
tree | 2ab2c6c8dac8ecbbd3f9e4fdc90cfbe823f7d31d | |
parent | 0431db467f37ae5414d04c9cd5ba4090b1cf3d65 (diff) | |
parent | a044525ed8cae5ec7e0a7c2f76551a4f09059ab7 (diff) |
Merge "Add metadata support in info"
4 files changed, 34 insertions, 3 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 7d169d5e..56183399 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 @@ -62,6 +62,7 @@ public class OnapCommandConstants { public static final String INFO_AUTHOR = "author"; public static final String INFO_IGNORE = "ignore"; public static final String INFO_STATE = "state"; + public static final String INFO_METADATA = "metadata"; //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 55009a49..3d13020b 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 @@ -16,6 +16,9 @@ package org.onap.cli.fw.info; +import java.util.HashMap; +import java.util.Map; + import org.onap.cli.fw.cmd.OnapCommandType; /** @@ -33,6 +36,8 @@ public class OnapCommandInfo { private OnapCommandState state = OnapCommandState.STABLE; + private Map<String, String> metadata = new HashMap<>(); + private boolean ignore = false; public String getProduct() { @@ -83,4 +88,12 @@ public class OnapCommandInfo { this.state = state; } + public Map<String, String> getMetadata() { + return metadata; + } + + public void setMetadata(Map<String, String> metadata) { + this.metadata = metadata; + } + }
\ 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 c1a6412e..ff8d85f1 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 @@ -17,7 +17,9 @@ package org.onap.cli.fw.schema; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import org.onap.cli.fw.cmd.OnapCommandType; @@ -71,6 +73,8 @@ public class OnapCommandSchemaInfo implements Comparable<OnapCommandSchemaInfo> private List<Object> outputs = new ArrayList<>(); + private Map<String, String> metadata = new HashMap(); + private String description; private String service; @@ -244,4 +248,12 @@ public class OnapCommandSchemaInfo implements Comparable<OnapCommandSchemaInfo> public void setAuthor(String author) { this.author = author; } + + public Map<String, String> getMetadata() { + return metadata; + } + + public void setMetadata(Map<String, String> metadata) { + this.metadata = metadata; + } } 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 34b82212..7c1f18f6 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 @@ -17,8 +17,11 @@ package org.onap.cli.fw.utils; import static org.onap.cli.fw.conf.OnapCommandConstants.ATTRIBUTES; +import static org.onap.cli.fw.conf.OnapCommandConstants.DEAFULT_INPUT_PARAMETERS_NAME; +import static org.onap.cli.fw.conf.OnapCommandConstants.DEFAULT_SCHEMA_PATH_PATERN; import static org.onap.cli.fw.conf.OnapCommandConstants.DESCRIPTION; import static org.onap.cli.fw.conf.OnapCommandConstants.DISCOVERY_FILE; +import static org.onap.cli.fw.conf.OnapCommandConstants.IS_DEFAULT_PARAM; import static org.onap.cli.fw.conf.OnapCommandConstants.NAME; import static org.onap.cli.fw.conf.OnapCommandConstants.OPEN_CLI_SAMPLE_VERSION; import static org.onap.cli.fw.conf.OnapCommandConstants.OPEN_CLI_SCHEMA_VERSION; @@ -26,9 +29,6 @@ import static org.onap.cli.fw.conf.OnapCommandConstants.PARAMETERS; import static org.onap.cli.fw.conf.OnapCommandConstants.RESULTS; import static org.onap.cli.fw.conf.OnapCommandConstants.SCHEMA_DIRECTORY; import static org.onap.cli.fw.conf.OnapCommandConstants.SCHEMA_PATH_PATERN; -import static org.onap.cli.fw.conf.OnapCommandConstants.DEFAULT_SCHEMA_PATH_PATERN; -import static org.onap.cli.fw.conf.OnapCommandConstants.DEAFULT_INPUT_PARAMETERS_NAME; -import static org.onap.cli.fw.conf.OnapCommandConstants.IS_DEFAULT_PARAM; import java.io.File; import java.io.IOException; @@ -59,6 +59,7 @@ import org.springframework.core.io.support.ResourcePatternResolver; import org.yaml.snakeyaml.Yaml; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; public class OnapCommandDiscoveryUtils { @@ -189,6 +190,7 @@ public class OnapCommandDiscoveryUtils { File file = new File(dataDir + File.separator + DISCOVERY_FILE); ObjectMapper mapper = new ObjectMapper(); + mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); mapper.writerWithDefaultPrettyPrinter().writeValue(file, schemas); } catch (IOException e1) { throw new OnapCommandDiscoveryFailed(dataDir, @@ -374,6 +376,9 @@ public class OnapCommandDiscoveryUtils { schema.setAuthor(infoMap.get(OnapCommandConstants.INFO_AUTHOR).toString()); } + if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_METADATA) != null) { + schema.setMetadata((Map<String, String>)infoMap.get(OnapCommandConstants.INFO_METADATA)); + } schema.setSchemaProfile(identitySchemaProfileType(resourceMap)); |