diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-09-25 21:05:58 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-11-14 14:38:03 +0530 |
commit | 92075994f7a2a399f2dced6fb207ebb4e717d8f0 (patch) | |
tree | 771e213ceeb2342138287879cfed442df9fd1aaf /framework/src/main/java/org/onap | |
parent | 4b04eaa325a972ec38a7d317a60faff1664c8d39 (diff) |
Make input parameter available in output value
Issue-Id: CLI-66
Change-Id: Ib7dc22352932294b485b1239dbb56e4092ef6644
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/main/java/org/onap')
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java | 1 | ||||
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java | 37 |
2 files changed, 38 insertions, 0 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java b/framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java index 90ac961e..9f4840cc 100644 --- a/framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java +++ b/framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java @@ -95,6 +95,7 @@ public class OnapHttpCommand extends OnapCommand { } Map<String, ArrayList<String>> results = OnapCommandUtils.populateOutputs(this.getResultMap(), output); + results = OnapCommandUtils.populateOutputsFromInputParameters(results, this.getParametersMap()); for (OnapCommandResultAttribute attr : this.getResult().getRecords()) { attr.setValues(results.get(attr.getName())); diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java index 9c4306c1..131b5209 100644 --- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java +++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java @@ -1585,6 +1585,43 @@ public class OnapCommandUtils { } /** + * Populate result from input parameters. + * + * @param resultMap + * map + * @param params + * Map<String, OnapCommandParameter> + * @return map + * @throws OnapCommandHttpHeaderNotFound + * header not found exception + * @throws OnapCommandHttpInvalidResponseBody + * invalid response body exception + * @throws OnapCommandResultMapProcessingFailed + * map processing failed exception + */ + public static Map<String, ArrayList<String>> populateOutputsFromInputParameters( + Map<String, ArrayList<String>> resultMap, + Map<String, OnapCommandParameter> params) + throws OnapCommandException { + Map<String, ArrayList<String>> resultsProcessed = new HashMap<>(); + + for (Entry<String, ArrayList<String>> entry : resultMap.entrySet()) { + String key = entry.getKey(); + resultsProcessed.put(key, new ArrayList<>()); + for (String value: entry.getValue()) { + try { + value = replaceLineFromInputParameters(value, params); + } catch(OnapCommandResultEmpty e) { + // pass // NOSONAR + } + resultsProcessed.get(key).add(value); + } + } + + return resultsProcessed; + } + + /** * Find external schema files. * * @return list ExternalSchema |