From 7cf506ee2b43dccd08c3d1159485e6f6729d31ed Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Wed, 13 Dec 2017 14:39:55 +0530 Subject: Add yaml format support for printing result Issue-ID: CLI-66 Change-Id: I38cee498c98b78a1767a700c029dbcb310a6f727 Signed-off-by: Kanagaraj Manickam k00365106 --- .../onap/cli/fw/output/print/OnapCommandPrint.java | 29 ++++++++++++++++------ .../cli/fw/schema/OnapCommandSchemaLoader.java | 10 ++++---- 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'framework/src/main/java') diff --git a/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java b/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java index 389aee36..0c0c5a12 100644 --- a/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java +++ b/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java @@ -28,12 +28,16 @@ import java.util.StringTokenizer; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; +import org.onap.cli.fw.conf.OnapCommandConstants; import org.onap.cli.fw.error.OnapCommandOutputPrintingFailed; import org.onap.cli.fw.output.OnapCommandPrintDirection; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; + import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; - /** * Oclip Command Table print. * @@ -249,19 +253,30 @@ public class OnapCommandPrint { JSONArray array = new JSONArray(); //skip first row title + List titleRow = rows.get(0); + for (int i=1; i values = OnapCommandSchemaLoader.loadSchema(inputStream, schemaName); + Map values = loadSchema(inputStream, schemaName); String schemaVersion = ""; if (values.keySet().contains(OPEN_CLI_SCHEMA_VERSION)) { Object obj = values.get(OPEN_CLI_SCHEMA_VERSION); @@ -151,13 +151,13 @@ public class OnapCommandSchemaLoader { defaultParameterMap.remove(OnapCommandConstants.INFO); } - errors.addAll(OnapCommandSchemaLoader.parseSchema(cmd, defaultParameterMap, validateSchema)); + errors.addAll(parseSchema(cmd, defaultParameterMap, validateSchema)); } Map>> commandYamlMap = (Map>>)validateSchemaVersion(schemaName, cmd.getSchemaVersion()); - errors.addAll(OnapCommandSchemaLoader.parseSchema(cmd, commandYamlMap, validateSchema)); + errors.addAll(parseSchema(cmd, commandYamlMap, validateSchema)); return errors; } catch (OnapCommandException e) { @@ -521,7 +521,7 @@ public class OnapCommandSchemaLoader { */ public static Map loadSchema(Resource resource) throws OnapCommandInvalidSchema { try { - return OnapCommandSchemaLoader.loadSchema(resource.getInputStream(), resource.getFilename()); + return loadSchema(resource.getInputStream(), resource.getFilename()); } catch (IOException e) { throw new OnapCommandInvalidSchema(resource.getFilename(), e); } -- cgit 1.2.3-korg