summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
authorKanagaraj Manickam <mkr1481@gmail.com>2019-03-15 16:27:33 +0800
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-03-15 16:28:19 +0800
commita044525ed8cae5ec7e0a7c2f76551a4f09059ab7 (patch)
treece1ae97d5f355664514fd114c3ce5f8e545d0325 /framework
parent72e01174faa3376fb5c095715b3e4cca037ff969 (diff)
Add metadata support in info
Issue-ID: CLI-129 Change-Id: Icf12f0ef03645b91ff6236b4812663dc0828d5d9 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java1
-rw-r--r--framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java13
-rw-r--r--framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java12
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java11
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));