aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-02-28 12:29:27 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-02-28 13:18:35 +0530
commit9f26a5983e007f8e888af3dd8d1382c83fce446b (patch)
tree686c04eee27689a2d3cf75f5948fa99f4d393529 /framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java
parentc9f4e87e86c166ca5ba641dbb99d8a6a5f759e3a (diff)
CMD: Enhace command profile with additional macros
Issue-ID: CLI-129 Change-Id: I612ecfe2c25f73714a8759ce87fdc373c8d5a7f0 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java73
1 files changed, 43 insertions, 30 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java b/framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java
index 0b9f9be7..ca0f04e7 100644
--- a/framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java
+++ b/framework/src/main/java/org/onap/cli/fw/output/OnapCommandResult.java
@@ -42,7 +42,7 @@ public class OnapCommandResult {
*
* if type=TEXT, then it holds the result in text format such as help message
*/
- private Object output;
+ private Object output = new String("");
/*
* Type requested by user
@@ -84,6 +84,13 @@ public class OnapCommandResult {
*/
private boolean isDebug = false;
+ /**
+ * Command passed/failed
+ * @return
+ */
+
+ private boolean passed = true;
+
public OnapCommandPrintDirection getPrintDirection() {
return printDirection;
}
@@ -192,43 +199,41 @@ public class OnapCommandResult {
* exception
*/
public String print() throws OnapCommandException {
- if (this.getRecords().isEmpty()) {
- return "";
- } else if (this.getType().equals(OnapCommandResultType.TEXT)) {
- return this.getOutput().toString();
+ if (this.getType().equals(OnapCommandResultType.TEXT)) {
+ return this.getOutput().toString();
}
OnapCommandPrint print = new OnapCommandPrint();
print.setPrintTitle(this.isIncludeTitle());
- if (this.getPrintDirection().equals(OnapCommandPrintDirection.LANDSCAPE)) {
- for (OnapCommandResultAttribute record : this.getScopedRecords()) {
- if (record.getType().equals(OnapCommandParameterType.JSON)) {
- print.addColumn(record.getName(), OnapCommandUtils.jsonFlatten(record.getValues()));
- } else {
+ print.setDirection(this.printDirection);
+
+ if (!this.getRecords().isEmpty()) {
+ if (this.getPrintDirection().equals(OnapCommandPrintDirection.LANDSCAPE)) {
+ for (OnapCommandResultAttribute record : this.getScopedRecords()) {
print.addColumn(record.getName(), record.getValues());
}
- }
- } else {
- // Add property column
- OnapCommandResultAttribute prp = new OnapCommandResultAttribute();
- prp.setName(OnapCommandConstants.PORTRAINT_COLUMN_NAME_PROPERTY);
- prp.setScope(OnapCommandResultAttributeScope.SHORT);
- // Add value column
- OnapCommandResultAttribute val = new OnapCommandResultAttribute();
- val.setName(OnapCommandConstants.PORTRAINT_COLUMN_NAME_VALUE);
- val.setScope(OnapCommandResultAttributeScope.SHORT);
-
- for (OnapCommandResultAttribute record : this.getScopedRecords()) {
- prp.getValues().add(record.getName());
- if (record.getValues().size() == 1) {
- val.getValues().add(record.getValues().get(0));
- } else {
- val.getValues().add(record.getValues().toString());
+ } else {
+ // Add property column
+ OnapCommandResultAttribute prp = new OnapCommandResultAttribute();
+ prp.setName(OnapCommandConstants.PORTRAINT_COLUMN_NAME_PROPERTY);
+ prp.setScope(OnapCommandResultAttributeScope.SHORT);
+ // Add value column
+ OnapCommandResultAttribute val = new OnapCommandResultAttribute();
+ val.setName(OnapCommandConstants.PORTRAINT_COLUMN_NAME_VALUE);
+ val.setScope(OnapCommandResultAttributeScope.SHORT);
+
+ for (OnapCommandResultAttribute record : this.getScopedRecords()) {
+ prp.getValues().add(record.getName());
+ if (record.getValues().size() == 1) {
+ val.getValues().add(record.getValues().get(0));
+ } else {
+ val.getValues().add(record.getValues().toString());
+ }
}
- }
- print.addColumn(prp.getName(), prp.getValues());
- print.addColumn(val.getName(), val.getValues());
+ print.addColumn(prp.getName(), prp.getValues());
+ print.addColumn(val.getName(), val.getValues());
+ }
}
if (this.getType().equals(OnapCommandResultType.JSON)) {
@@ -255,4 +260,12 @@ public class OnapCommandResult {
return recordList;
}
+
+ public boolean isPassed() {
+ return passed;
+ }
+
+ public void setPassed(boolean passed) {
+ this.passed = passed;
+ }
}