diff options
author | 2018-04-16 09:45:17 +0300 | |
---|---|---|
committer | 2018-04-17 10:13:52 +0000 | |
commit | 7dae646e5b5f1168fa395394254664f27a3493f3 (patch) | |
tree | 7d69e76300daf0b9709562b984fa1b2684d91cae /openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp | |
parent | 04783c44c22de7ef4abe183c5f19b4136305e5f8 (diff) |
SIROV - add parent heat name for volume
SIROV - add parent heat name for parameter came from volume HEAT
Change-Id: I5592dc8b292037e740a1d7ac11e7ee0576cc2ec8
Issue-ID: SDC-996
Signed-off-by: eleonorali <eleonoral@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp')
3 files changed, 44 insertions, 20 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java index c84ed22011..7ca4f78b37 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ public class TranslationService { if (fileDataCollection.getBaseFile() != null) { for (FileData fileData : fileDataCollection.getBaseFile()) { - translateHeatFile(mainServiceTemplate, fileData, translationContext); + translateHeatFile(mainServiceTemplate, fileData, translationContext); } } if (fileDataCollection.getAddOnFiles() != null) { @@ -132,12 +132,25 @@ public class TranslationService { */ public void translateHeatFile(ServiceTemplate serviceTemplate, FileData heatFileData, TranslationContext context) { + translateHeatFile(serviceTemplate, heatFileData, null, context); + } + + /** + * Translate heat file. + * + * @param serviceTemplate the service template + * @param heatFileData the current heat file data + * @param parentHeatFileName the main heat to which associated current heat file (e.g. volume heat) + * @param context the context + */ + public void translateHeatFile(ServiceTemplate serviceTemplate, FileData heatFileData, String parentHeatFileName, + TranslationContext context) { String heatFileName = heatFileData.getFile(); HeatOrchestrationTemplate heatOrchestrationTemplate = new YamlUtil() .yamlToObject(context.getFileContent(heatFileName), HeatOrchestrationTemplate.class); translateInputParameters(serviceTemplate, heatOrchestrationTemplate, heatFileData, context, - heatFileName); + heatFileName, parentHeatFileName); translateResources(heatFileName, serviceTemplate, heatOrchestrationTemplate, context); translateOutputParameters(serviceTemplate, heatOrchestrationTemplate, heatFileData, heatFileName, context); @@ -146,7 +159,7 @@ public class TranslationService { if (Objects.nonNull(heatFileData.getData())) { heatFileData.getData().stream().filter(data -> data.getType() == FileData.Type.HEAT_VOL) - .forEach(data -> translateHeatFile(serviceTemplate, data, context)); + .forEach(data -> translateHeatFile(serviceTemplate, data, heatFileData.getFile(), context)); } } @@ -232,7 +245,7 @@ public class TranslationService { private void translateInputParameters(ServiceTemplate serviceTemplate, HeatOrchestrationTemplate heatOrchestrationTemplate, FileData heatFileData, TranslationContext context, - String heatFileName) { + String heatFileName, String parentHeatFileName) { if (heatOrchestrationTemplate.getParameters() == null) { return; } @@ -240,7 +253,7 @@ public class TranslationService { Map<String, ParameterDefinition> parameterDefinitionMap = TranslatorHeatToToscaParameterConverter .parameterConverter(serviceTemplate, heatOrchestrationTemplate.getParameters(), - heatOrchestrationTemplate, heatFileName, context); + heatOrchestrationTemplate, heatFileName, parentHeatFileName, context); Environment heatEnvFile = getHeatEnvFile(heatFileData, context); Map<String, Object> parameters = heatEnvFile.getParameters(); Object parameterValue; @@ -276,13 +289,19 @@ public class TranslationService { private void updateAnnotations(Map<String, ParameterDefinition> inputParameters, Map<String, ParameterDefinition> newParameters) { - if (Objects.nonNull(newParameters.entrySet())) { newParameters.entrySet().stream().filter(stringParameterDefinitionEntry -> inputParameters.containsKey(stringParameterDefinitionEntry.getKey()) && - isHasAnnotation(inputParameters, stringParameterDefinitionEntry)). - forEach(stringParameterDefinitionEntry -> getVFModulesList(stringParameterDefinitionEntry.getValue()). - addAll(getVFModulesList(inputParameters.get(stringParameterDefinitionEntry.getKey())))); - } + isHasAnnotation(inputParameters, stringParameterDefinitionEntry)). + forEach(stringParameterDefinitionEntry -> { + List inputParamVFModuleList = getVFModulesList(inputParameters.get(stringParameterDefinitionEntry.getKey())); + List newParamVFModuleList = getVFModulesList(stringParameterDefinitionEntry.getValue()); + if(inputParamVFModuleList.contains(newParamVFModuleList.get(0))){ + newParamVFModuleList.remove(0); + } + newParamVFModuleList.addAll(inputParamVFModuleList); + + }); + } private boolean isHasAnnotation(Map<String, ParameterDefinition> inputParameters, Map.Entry<String, ParameterDefinition> newParameterSet) { diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNestedImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNestedImpl.java index 00acb66706..1da1738101 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNestedImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNestedImpl.java @@ -181,8 +181,8 @@ public class ResourceTranslationNestedImpl extends ResourceTranslationBase { translateTo.getContext() .addNestedHeatFileName(ToscaUtil.getServiceTemplateFileName(templateName), translateTo.getResource().getType()); - new TranslationService().translateHeatFile(nestedSubstitutionServiceTemplate, nestedFileData, - translateTo.getContext()); + new TranslationService().translateHeatFile(nestedSubstitutionServiceTemplate, + nestedFileData, translateTo.getContext()); return nestedSubstitutionServiceTemplate; } 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 930a2dee58..3b9497644c 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 @@ -1,5 +1,5 @@ /* - * Copyright © 2018 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,14 +65,14 @@ public class TranslatorHeatToToscaParameterConverter { */ public static Map<String, ParameterDefinition> parameterConverter(ServiceTemplate serviceTemplate, Map<String, Parameter> parameters, HeatOrchestrationTemplate heatOrchestrationTemplate, - String heatFileName, TranslationContext context) { + String heatFileName, String parentHeatFileName, TranslationContext context) { Map<String, ParameterDefinition> parameterDefinitionMap = new HashMap<>(); for (Map.Entry<String, Parameter> entry : parameters.entrySet()) { String heatParamName = entry.getKey(); parameterDefinitionMap.put(heatParamName, getToscaParameter(serviceTemplate,heatParamName, entry.getValue(), heatOrchestrationTemplate, - heatFileName, context)); + heatFileName, parentHeatFileName, context)); } return parameterDefinitionMap; } @@ -110,12 +110,13 @@ public class TranslatorHeatToToscaParameterConverter { * @param context the context * @return the tosca parameter */ - public static ParameterDefinitionExt getToscaParameter(ServiceTemplate serviceTemplate, + private static ParameterDefinitionExt getToscaParameter(ServiceTemplate serviceTemplate, String heatParameterName, Parameter heatParameter, HeatOrchestrationTemplate heatOrchestrationTemplate, String heatFileName, + String parentHeatFileName, TranslationContext context) { ParameterDefinitionExt toscaParameter = new ParameterDefinitionExt(); @@ -129,14 +130,18 @@ 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, heatParameterName); + Optional<Map<String, AnnotationDefinition>> annotations = getToscaAnnotations(context, serviceTemplate, 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 heatParameterName){ + private static Optional<Map<String, AnnotationDefinition> > getToscaAnnotations (TranslationContext context, ServiceTemplate serviceTemplate, String heatFileName, String parentHeatFileName, String heatParameterName){ + + if(parentHeatFileName != null){ + heatFileName = parentHeatFileName; + } if(!isAnnotationRequired(context, serviceTemplate, heatFileName)){ return Optional.empty(); @@ -162,7 +167,7 @@ public class TranslatorHeatToToscaParameterConverter { private static boolean isNestedServiceTemplate(TranslationContext context, ServiceTemplate serviceTemplate, String heatFileName) { String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate.getMetadata()); - return HeatToToscaUtil.isHeatFileNested(context, heatFileName) || context.getNestedHeatFileName().containsKey(serviceTemplateFileName); + return HeatToToscaUtil.isHeatFileNested(context, heatFileName); } |