From 124caf6d7e77a1e8253eccfa6b6971644ca01317 Mon Sep 17 00:00:00 2001 From: "priyanka.akhade" Date: Fri, 17 Jul 2020 23:47:09 +0530 Subject: code improvements- incorporating comments Signed-off-by: priyanka.akhade Issue-ID: CLI-270 Change-Id: I656eab21336ba224917ac5df022f59697330b132 --- .../cli/fw/schema/OnapCommandSchemaLoader.java | 2 +- .../cli/fw/schema/OnapCommandSchemaMerger.java | 30 ++++---- .../cli/fw/utils/OnapCommandDiscoveryUtils.java | 90 +++++++++++----------- 3 files changed, 61 insertions(+), 61 deletions(-) (limited to 'framework') 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 7de56025..aa45f58e 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 @@ -160,7 +160,7 @@ public class OnapCommandSchemaLoader { errors.addAll(parseSchema(cmd, defaultParameterMap, validateSchema)); } - Map commandYamlMap = validateSchemaVersion(schemaName, cmd.getSchemaVersion()); + Map commandYamlMap = validateSchemaVersion(schemaName, cmd.getSchemaVersion()); errors.addAll(parseSchema(cmd, commandYamlMap, validateSchema)); diff --git a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaMerger.java b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaMerger.java index 6ad0274e..c2ae189b 100644 --- a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaMerger.java +++ b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaMerger.java @@ -116,26 +116,26 @@ public class OnapCommandSchemaMerger { //Name should be existing in the map, otherwise continue as don't know how to compare if (nameN != null) { - boolean existing = false; - for (Object e: originalList) { - Map oE = (Map) e; - String nameE = (String)oE.getOrDefault(OnapCommandConstants.NAME, null); - - //Name should be existing in the map, otherwise continue as don't know how to compare - if (nameN.equals(nameE)) { - for (Entry oNe : oN.entrySet()) { - oE.put(oNe.getKey(), oNe.getValue()); + boolean existing = false; + for (Object e: originalList) { + Map oE = (Map) e; + String nameE = (String)oE.getOrDefault(OnapCommandConstants.NAME, null); + + //Name should be existing in the map, otherwise continue as don't know how to compare + if (nameN.equals(nameE)) { + for (Entry oNe : oN.entrySet()) { + oE.put(oNe.getKey(), oNe.getValue()); + } + existing = true; + break; } - existing = true; - break; } - } - if (!existing) { - originalList.add(o); + if (!existing) { + originalList.add(o); + } } } - } } } 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 b866db09..614eb2a9 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 @@ -337,65 +337,65 @@ public class OnapCommandDiscoveryUtils { OnapCommandUtils.log.info("Invalid Schema yaml {}" + schema.getSchemaURI()); } else{ - schema.setVersion(obj.toString()); + schema.setVersion(obj.toString()); - if (!schema.getVersion().equalsIgnoreCase(OnapCommandConstants.OPEN_CLI_SCHEMA_VERSION_VALUE_1_0)) { - OnapCommandUtils.log.info("Unsupported Schema version found {} " + schema.getSchemaURI()); - } - else{ + if (!schema.getVersion().equalsIgnoreCase(OnapCommandConstants.OPEN_CLI_SCHEMA_VERSION_VALUE_1_0)) { + OnapCommandUtils.log.info("Unsupported Schema version found {} " + schema.getSchemaURI()); + } + else{ - //There are schema like default input parameters and does not have command name - if (resourceMap.get(NAME) != null) { - schema.setSchemaName(resource.getFilename()); - schema.setCmdName((String) resourceMap.get(NAME)); + //There are schema like default input parameters and does not have command name + if (resourceMap.get(NAME) != null) { + schema.setSchemaName(resource.getFilename()); + schema.setCmdName((String) resourceMap.get(NAME)); - schema.setDescription((String) resourceMap.get(DESCRIPTION)); + schema.setDescription((String) resourceMap.get(DESCRIPTION)); - Map infoMap = (Map) resourceMap.get(OnapCommandConstants.INFO); - if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_TYPE) != null) { - schema.setType(infoMap.get(OnapCommandConstants.INFO_TYPE).toString()); - } + Map infoMap = (Map) resourceMap.get(OnapCommandConstants.INFO); + if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_TYPE) != null) { + schema.setType(infoMap.get(OnapCommandConstants.INFO_TYPE).toString()); + } - if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_PRODUCT) != null) { - schema.setProduct(infoMap.get(OnapCommandConstants.INFO_PRODUCT).toString()); - } + if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_PRODUCT) != null) { + schema.setProduct(infoMap.get(OnapCommandConstants.INFO_PRODUCT).toString()); + } - if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_IGNORE) != null) { - schema.setIgnore(infoMap.get(OnapCommandConstants.INFO_IGNORE).toString()); - } + if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_IGNORE) != null) { + schema.setIgnore(infoMap.get(OnapCommandConstants.INFO_IGNORE).toString()); + } - if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_STATE) != null) { - schema.setState(infoMap.get(OnapCommandConstants.INFO_STATE).toString()); - } + if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_STATE) != null) { + schema.setState(infoMap.get(OnapCommandConstants.INFO_STATE).toString()); + } - if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_SERVICE) != null) { - schema.setService(infoMap.get(OnapCommandConstants.INFO_SERVICE).toString()); - } + if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_SERVICE) != null) { + schema.setService(infoMap.get(OnapCommandConstants.INFO_SERVICE).toString()); + } - if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_AUTHOR) != null) { - schema.setAuthor(infoMap.get(OnapCommandConstants.INFO_AUTHOR).toString()); - } + if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_AUTHOR) != null) { + schema.setAuthor(infoMap.get(OnapCommandConstants.INFO_AUTHOR).toString()); + } - if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_METADATA) != null) { - schema.setMetadata((Map)infoMap.get(OnapCommandConstants.INFO_METADATA)); - } + if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_METADATA) != null) { + schema.setMetadata((Map)infoMap.get(OnapCommandConstants.INFO_METADATA)); + } - schema.setSchemaProfile(identitySchemaProfileType(resourceMap)); + schema.setSchemaProfile(identitySchemaProfileType(resourceMap)); - if (resourceMap.containsKey(PARAMETERS)) { - schema.setInputs((List)resourceMap.get(PARAMETERS)); - if (defaultInputs.get(schema.getSchemaProfile()) != null) { - schema.getInputs().addAll(defaultInputs.get(schema.getSchemaProfile())); - } - } + if (resourceMap.containsKey(PARAMETERS)) { + schema.setInputs((List)resourceMap.get(PARAMETERS)); + if (defaultInputs.get(schema.getSchemaProfile()) != null) { + schema.getInputs().addAll(defaultInputs.get(schema.getSchemaProfile())); + } + } - if (resourceMap.containsKey(RESULTS)) { - schema.setOutputs((List)((Map)resourceMap.get(RESULTS)).get(ATTRIBUTES)); - } + if (resourceMap.containsKey(RESULTS)) { + schema.setOutputs((List)((Map)resourceMap.get(RESULTS)).get(ATTRIBUTES)); + } - extSchemas.add(schema); - } - } + extSchemas.add(schema); + } + } } } } -- cgit 1.2.3-korg