From 81a0c6fd575fcb32be259383766ab53ce947d702 Mon Sep 17 00:00:00 2001 From: Bogumil Zebek Date: Tue, 12 Jan 2021 11:57:59 +0100 Subject: Fix OnapCommand class model - No Metadata in OnapCommand Info section - Optional parameters with default values are lost after overriding selected parameter Issue-ID: CLI-349 CLI-348 Signed-off-by: Zebek Bogumil Change-Id: I893bb01809737b4262a99f355d6c7681c8c275bb --- framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java | 4 +++- .../main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'framework/src/main/java') diff --git a/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java b/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java index 74e488b4..167379d7 100644 --- a/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java +++ b/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java @@ -1,5 +1,6 @@ /* * Copyright 2017 Huawei Technologies Co., Ltd. + * Copyright 2020 Nokia * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,7 +126,7 @@ public abstract class OnapCommand { } public void setParameters(Set parameters) { - this.cmdParameters = parameters; + this.cmdParameters.addAll(parameters); } public Set getParameters() { @@ -200,6 +201,7 @@ public abstract class OnapCommand { } public List initializeSchema(OnapCommandSchemaInfo schema) throws OnapCommandException { + this.getInfo().setMetadata(schema.getMetadata()); return this.initializeSchema(schema.getSchemaName(), false); } diff --git a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java index aa45f58e..e051d5dd 100644 --- a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java +++ b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java @@ -1,5 +1,6 @@ /* * Copyright 2017 Huawei Technologies Co., Ltd. + * Copyright 2020 Nokia * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +27,7 @@ import static org.onap.cli.fw.conf.OnapCommandConstants.DIRECTION; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_AUTHOR; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_IGNORE; +import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_METADATA; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_PARAMS_LIST; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_PARAMS_MANDATORY_LIST; import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_PRODUCT; @@ -262,6 +264,11 @@ public class OnapCommandSchemaLoader { info.setAuthor(mode.toString()); break; + case INFO_METADATA: + Object metadata = infoMap.get(key1); + info.setMetadata((Map)metadata); + break; + case INFO_IGNORE: Object ignore = infoMap.get(key1); info.setIgnore(ignore.toString().equalsIgnoreCase(OnapCommandConstants.BOOLEAN_TRUE)); -- cgit 1.2.3-korg