diff options
author | eleonorali <eleonoral@amdocs.com> | 2018-04-22 15:04:20 +0300 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-04-30 19:28:09 +0000 |
commit | d0f6cb3ef9600846358a0e7f849759be6f9d917e (patch) | |
tree | 7f2db92566de3c2ee47a5aa576e52a836a274170 /openecomp-be/lib/openecomp-sdc-translator-lib | |
parent | a6c79101b3ae522b83f9bef17deec3e543bf42ca (diff) |
SIROV - add parent heat name for volume
Refactoring - handle Static Analysis Errors/Warnings
Change-Id: I66abb24a1f7a2c5bfe018320560a0010e4afd277
Issue-ID: SDC-996
Signed-off-by: eleonorali <eleonoral@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib')
2 files changed, 23 insertions, 22 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/ResourceTranslationNeutronPortHelper.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/ResourceTranslationNeutronPortHelper.java index 386ee7b94e..712a1a21d2 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/ResourceTranslationNeutronPortHelper.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/ResourceTranslationNeutronPortHelper.java @@ -1,7 +1,4 @@ package org.openecomp.sdc.translator.services.heattotosca.helper; - -import org.apache.commons.collections4.CollectionUtils; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaParameterConverter.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaParameterConverter.java index 9ed95bf084..da6677ac16 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaParameterConverter.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaParameterConverter.java @@ -30,19 +30,24 @@ import org.onap.sdc.tosca.datatypes.model.*; import org.onap.sdc.tosca.datatypes.model.heatextend.AnnotationDefinition; import org.onap.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt; import org.openecomp.sdc.tosca.services.ToscaConstants; -import org.openecomp.sdc.tosca.services.ToscaUtil; import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext; import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslationFactory; import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil; import java.util.*; - public class TranslatorHeatToToscaParameterConverter { private static Map<String, String> parameterTypeMapping; private static Map<String, String> parameterEntrySchemaTypeMapping; + private static final String RANGE = "range"; + private static final String LENGTH = "length"; + private static final String MIN = "min"; + private static final String MAX = "max"; + private static final String ALLOWED_VALUES = "allowed_values"; + private static final String ALLOWED_PATTERN = "allowed_pattern"; + static { parameterEntrySchemaTypeMapping = new HashMap<>(); @@ -134,20 +139,20 @@ public class TranslatorHeatToToscaParameterConverter { toscaParameter.setHidden(heatParameter.isHidden()); toscaParameter.setImmutable(heatParameter.isImmutable()); toscaParameter.setConstraints(getToscaConstrains(heatParameter.getConstraints())); - Optional<Map<String, AnnotationDefinition>> annotations = getToscaAnnotations(context, serviceTemplate, heatFileName, parentHeatFileName, heatParameterName); + Optional<Map<String, AnnotationDefinition>> annotations = getToscaAnnotations(context, heatFileName, parentHeatFileName, heatParameterName); annotations.ifPresent(ant->toscaParameter.setAnnotations(annotations.get())); return toscaParameter; } - private static Optional<Map<String, AnnotationDefinition> > getToscaAnnotations (TranslationContext context, ServiceTemplate serviceTemplate, String heatFileName, String parentHeatFileName, String heatParameterName){ + private static Optional<Map<String, AnnotationDefinition> > getToscaAnnotations (TranslationContext context, String heatFileName, String parentHeatFileName, String heatParameterName){ if(parentHeatFileName != null){ heatFileName = parentHeatFileName; } - if(!isAnnotationRequired(context, serviceTemplate, heatFileName)){ + if(!isAnnotationRequired(context, heatFileName)){ return Optional.empty(); } @@ -165,12 +170,11 @@ public class TranslatorHeatToToscaParameterConverter { } - private static boolean isAnnotationRequired(TranslationContext context, ServiceTemplate serviceTemplate, String heatFileName){ - return HeatToToscaUtil.shouldAnnotationsToBeAdded() && !isNestedServiceTemplate(context, serviceTemplate, heatFileName); + private static boolean isAnnotationRequired(TranslationContext context, String heatFileName){ + return HeatToToscaUtil.shouldAnnotationsToBeAdded() && !isNestedServiceTemplate(context, heatFileName); } - private static boolean isNestedServiceTemplate(TranslationContext context, ServiceTemplate serviceTemplate, String heatFileName) { - String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate.getMetadata()); + private static boolean isNestedServiceTemplate(TranslationContext context, String heatFileName) { return HeatToToscaUtil.isHeatFileNested(context, heatFileName); } @@ -276,16 +280,16 @@ public class TranslatorHeatToToscaParameterConverter { List<Constraint> convertedConstraintList = new ArrayList<>(); Constraint convertedConstraint; - if (constraint.containsKey("range")) { + if (constraint.containsKey(RANGE)) { convertedConstraint = new Constraint(); convertedConstraintList.add(convertedConstraint); - Integer min = (Integer) ((Map) constraint.get("range")).get("min"); - Integer max = (Integer) ((Map) constraint.get("range")).get("max"); + Integer min = (Integer) ((Map) constraint.get(RANGE)).get(MIN); + Integer max = (Integer) ((Map) constraint.get(RANGE)).get(MAX); convertedConstraint.setIn_range(new Integer[]{min, max}); - } else if (constraint.containsKey("length")) { - Integer min = (Integer) ((Map) constraint.get("length")).get("min"); - Integer max = (Integer) ((Map) constraint.get("length")).get("max"); + } else if (constraint.containsKey(LENGTH)) { + Integer min = (Integer) ((Map) constraint.get(LENGTH)).get(MIN); + Integer max = (Integer) ((Map) constraint.get(LENGTH)).get(MAX); if (max != null) { convertedConstraint = new Constraint(); convertedConstraintList.add(convertedConstraint); @@ -296,14 +300,14 @@ public class TranslatorHeatToToscaParameterConverter { convertedConstraintList.add(convertedConstraint); convertedConstraint.setMin_length(min); } - } else if (constraint.containsKey("allowed_values")) { + } else if (constraint.containsKey(ALLOWED_VALUES)) { convertedConstraint = new Constraint(); convertedConstraintList.add(convertedConstraint); - convertedConstraint.setValid_values((List) constraint.get("allowed_values")); - } else if (constraint.containsKey("allowed_pattern")) { + convertedConstraint.setValid_values((List) constraint.get(ALLOWED_VALUES)); + } else if (constraint.containsKey(ALLOWED_PATTERN)) { convertedConstraint = new Constraint(); convertedConstraintList.add(convertedConstraint); - convertedConstraint.setPattern(constraint.get("allowed_pattern")); + convertedConstraint.setPattern(constraint.get(ALLOWED_PATTERN)); } return convertedConstraintList; |