diff options
author | siddharth0905 <siddharth.singh4@amdocs.com> | 2017-12-27 13:54:27 +0530 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2017-12-27 13:36:26 +0000 |
commit | fdc412457583b29f68ca81069c53bcd96684d20d (patch) | |
tree | 1a2e42dbb475b71ded89bfbfabb5e19eab850d44 | |
parent | a80a6e4fca573de7a90e099c697945383a70493e (diff) |
Fix sonar issues - TranslationContext
Code refactor and variable name change
Change-Id: I528be906feb5255d1b34ed30c7a287ae0d6bb29c
Issue-ID: SDC-343
Signed-off-by: siddharth0905 <siddharth.singh4@amdocs.com>
-rw-r--r-- | openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java | 88 |
1 files changed, 38 insertions, 50 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java index d2ad6daba1..6f77f22625 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java @@ -23,7 +23,6 @@ import org.openecomp.core.utilities.CommonMethods; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.common.utils.SdcCommon; import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration; import org.openecomp.sdc.heat.datatypes.manifest.FileData; import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile; @@ -60,38 +59,7 @@ public class TranslationContext { private static Map<String, ImplementationConfiguration> supportedConsolidationComputeResources; private static Map<String, ImplementationConfiguration> supportedConsolidationPortResources; private static List<String> enrichPortResourceProperties; - - static { - Configuration config = ConfigurationManager.lookup(); - String propertyFileName = SdcCommon.HEAT_TO_TOSCA_MAPPING_CONF; - translationMapping = - config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY); - try { - globalServiceTemplates = - GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.ZIP); - } catch (Exception exc) { - throw new RuntimeException("Failed to load GlobalTypes", exc); - } - nameExtractorImplMap = config.populateMap(ConfigConstants.TRANSLATOR_NAMESPACE, - ConfigConstants.NAMING_CONVENTION_EXTRACTOR_IMPL_KEY, ImplementationConfiguration.class); - supportedConsolidationComputeResources = config.populateMap(ConfigConstants - .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants - .SUPPORTED_CONSOLIDATION_COMPUTE_RESOURCES_KEY, ImplementationConfiguration.class); - supportedConsolidationPortResources = config.populateMap(ConfigConstants - .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants - .SUPPORTED_CONSOLIDATION_PORT_RESOURCES_KEY, ImplementationConfiguration.class); - enrichPortResourceProperties = config.getAsStringValues(ConfigConstants - .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants - .ENRICH_PORT_RESOURCE_PROP); - - } - private ManifestFile manifest; - - public static List<String> getEnrichPortResourceProperties() { - return enrichPortResourceProperties; - } - private FileContentHandler files = new FileContentHandler(); private Map<String, FileData.Type> manifestFiles = new HashMap<>(); //Key - file name, value - file type @@ -124,6 +92,33 @@ public class TranslationContext { private Set<String> nodeTemplateIdsPointingToStWithoutNodeTemplates = new HashSet<>(); + static { + Configuration config = ConfigurationManager.lookup(); + translationMapping = + config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY); + try { + globalServiceTemplates = + GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.ZIP); + } catch (Exception exc) { + throw new RuntimeException("Failed to load GlobalTypes", exc); + } + nameExtractorImplMap = config.populateMap(ConfigConstants.TRANSLATOR_NAMESPACE, + ConfigConstants.NAMING_CONVENTION_EXTRACTOR_IMPL_KEY, ImplementationConfiguration.class); + supportedConsolidationComputeResources = config.populateMap(ConfigConstants + .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants + .SUPPORTED_CONSOLIDATION_COMPUTE_RESOURCES_KEY, ImplementationConfiguration.class); + supportedConsolidationPortResources = config.populateMap(ConfigConstants + .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants + .SUPPORTED_CONSOLIDATION_PORT_RESOURCES_KEY, ImplementationConfiguration.class); + enrichPortResourceProperties = config.getAsStringValues(ConfigConstants + .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants + .ENRICH_PORT_RESOURCE_PROP); + } + + public static List<String> getEnrichPortResourceProperties() { + return enrichPortResourceProperties; + } + public static Map<String, ImplementationConfiguration> getSupportedConsolidationComputeResources() { return supportedConsolidationComputeResources; @@ -265,14 +260,14 @@ public class TranslationContext { } public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String - nestedHeatFileNameToSkip){ + nestedHeatFileNameToSkip) { Set<String> allTranslatedResourceIds = new HashSet<>(); this.translatedIds.entrySet().stream().filter( heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey() - .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> { - allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet()); - }); + .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> + allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet()) + ); return allTranslatedResourceIds; } @@ -442,9 +437,9 @@ public class TranslationContext { */ public String getUnifiedAbstractNodeTemplateId(ServiceTemplate serviceTemplate, String nodeTemplateId) { - UnifiedSubstitutionData unifiedSubstitutionData = + UnifiedSubstitutionData unifiedSubsData = this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate)); - return unifiedSubstitutionData.getNodesRelatedAbstractNode().get(nodeTemplateId); + return unifiedSubsData.getNodesRelatedAbstractNode().get(nodeTemplateId); } /** @@ -456,9 +451,9 @@ public class TranslationContext { */ public String getUnifiedSubstitutionNodeTemplateId(ServiceTemplate serviceTemplate, String nodeTemplateId) { - UnifiedSubstitutionData unifiedSubstitutionData = + UnifiedSubstitutionData unifiedSubsData = this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate)); - return unifiedSubstitutionData.getNodesRelatedSubstitutionServiceTemplateNode() + return unifiedSubsData.getNodesRelatedSubstitutionServiceTemplateNode() .get(nodeTemplateId); } @@ -496,13 +491,6 @@ public class TranslationContext { .isComputeTypeHandledInServiceTemplate(computeType); } - public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName, - String nestedServiceTemplateName, - String computeType){ - return this.unifiedSubstitutionData.get(serviceTemplateName) - .getHandledNestedComputeNodeTemplateIndex(computeType); - } - public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName, String nestedServiceTemplateFileName) { if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) { @@ -512,10 +500,10 @@ public class TranslationContext { .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName); } - public Set<String> getAllRelatedNestedNodeTypeIds(){ + public Set<String> getAllRelatedNestedNodeTypeIds() { String globalName = "GlobalSubstitutionTypes"; - if(Objects.isNull(this.unifiedSubstitutionData) || - Objects.isNull(this.unifiedSubstitutionData.get(globalName))){ + if (Objects.isNull(this.unifiedSubstitutionData) + || Objects.isNull(this.unifiedSubstitutionData.get(globalName))) { return new HashSet<>(); } |