2 * Copyright © 2016-2017 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.translator.datatypes.heattotosca;
19 import org.apache.commons.collections.MapUtils;
20 import org.openecomp.config.api.Configuration;
21 import org.openecomp.config.api.ConfigurationManager;
22 import org.openecomp.core.utilities.CommonMethods;
23 import org.openecomp.core.utilities.file.FileContentHandler;
24 import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
25 import org.openecomp.sdc.common.errors.CoreException;
26 import org.openecomp.sdc.common.utils.SdcCommon;
27 import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
28 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
29 import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
30 import org.openecomp.sdc.heat.datatypes.model.Resource;
31 import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
32 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
33 import org.openecomp.sdc.tosca.services.ToscaUtil;
34 import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
35 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionEntity;
36 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedSubstitutionData;
37 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
38 import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
39 import org.openecomp.sdc.translator.services.heattotosca.Constants;
40 import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
41 import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
42 import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
44 import java.io.InputStream;
45 import java.util.HashMap;
46 import java.util.HashSet;
47 import java.util.List;
49 import java.util.Objects;
50 import java.util.Optional;
54 public class TranslationContext {
57 private static Map<String, Map<String, Map<String, String>>> translationMapping;
58 private static Map<String, ServiceTemplate> globalServiceTemplates;
59 private static Map<String, ImplementationConfiguration> nameExtractorImplMap;
60 private static Map<String, ImplementationConfiguration> supportedConsolidationComputeResources;
61 private static Map<String, ImplementationConfiguration> supportedConsolidationPortResources;
62 private static List<String> enrichPortResourceProperties;
65 Configuration config = ConfigurationManager.lookup();
66 String propertyFileName = SdcCommon.HEAT_TO_TOSCA_MAPPING_CONF;
68 config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY);
70 globalServiceTemplates =
71 GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.ZIP);
72 } catch (Exception exc) {
73 throw new RuntimeException("Failed to load GlobalTypes", exc);
75 nameExtractorImplMap = config.populateMap(ConfigConstants.TRANSLATOR_NAMESPACE,
76 ConfigConstants.NAMING_CONVENTION_EXTRACTOR_IMPL_KEY, ImplementationConfiguration.class);
77 supportedConsolidationComputeResources = config.populateMap(ConfigConstants
78 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
79 .SUPPORTED_CONSOLIDATION_COMPUTE_RESOURCES_KEY, ImplementationConfiguration.class);
80 supportedConsolidationPortResources = config.populateMap(ConfigConstants
81 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
82 .SUPPORTED_CONSOLIDATION_PORT_RESOURCES_KEY, ImplementationConfiguration.class);
83 enrichPortResourceProperties = config.getAsStringValues(ConfigConstants
84 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
85 .ENRICH_PORT_RESOURCE_PROP);
89 private ManifestFile manifest;
91 public static List<String> getEnrichPortResourceProperties() {
92 return enrichPortResourceProperties;
95 private FileContentHandler files = new FileContentHandler();
96 private Map<String, FileData.Type> manifestFiles = new HashMap<>();
97 //Key - file name, value - file type
98 private Set<String> nestedHeatsFiles = new HashSet<>();
99 private FileContentHandler externalArtifacts = new FileContentHandler();
100 // Key - heat file name,value - set of heat resource ids which were translated
101 private Map<String, Set<String>> translatedResources = new HashMap<>();
102 // Key - heat file name, value - translated Node template id
103 private Map<String, Set<String>> heatStackGroupMembers = new HashMap<>();
104 // Key - heat file name, value - Map with Key - heat resource Id, Value - tosca entity template id
105 private Map<String, Map<String, String>> translatedIds = new HashMap<>();
106 // key - service template type, value - translated service templates
107 private Map<String, ServiceTemplate> translatedServiceTemplates = new HashMap<>();
108 //key - heat param name, value - shared resource data
109 private Map<String, TranslatedHeatResource> heatSharedResourcesByParam = new HashMap<>();
110 //key - translated substitute service template file name, value - source nested heat file name
111 private Map<String, String> nestedHeatFileName = new HashMap<>();
112 //Key - heat file name,value - Map eith key - heat pseudo param name,
113 // value - translated tosca parameter name
114 private Map<String, Map<String, String>> usedHeatPseudoParams = new HashMap<>();
115 //Consolidation data gathered for Unified TOSCA model
116 private ConsolidationData consolidationData = new ConsolidationData();
117 private Map<String, UnifiedSubstitutionData> unifiedSubstitutionData = new HashMap<>();
118 private Set<String> unifiedHandledServiceTemplates = new HashSet<>();
120 private Map<String, Map<String, Map<String, Integer>>>
121 requirementIdAppearanceInNodeTemplate = new HashMap<>();
123 private Set<String> serviceTemplatesWithoutNodeTemplateSection = new HashSet<>();
125 private Set<String> nodeTemplateIdsPointingToStWithoutNodeTemplates = new HashSet<>();
127 public static Map<String, ImplementationConfiguration>
128 getSupportedConsolidationComputeResources() {
129 return supportedConsolidationComputeResources;
132 public static void setSupportedConsolidationComputeResources(
133 Map<String, ImplementationConfiguration> supportedConsolidationComputeResources) {
134 TranslationContext.supportedConsolidationComputeResources =
135 supportedConsolidationComputeResources;
138 public static Map<String, ImplementationConfiguration> getSupportedConsolidationPortResources() {
139 return supportedConsolidationPortResources;
142 public static void setSupportedConsolidationPortResources(
143 Map<String, ImplementationConfiguration> supportedConsolidationPortResources) {
144 TranslationContext.supportedConsolidationPortResources = supportedConsolidationPortResources;
148 * Get nameExtractor implemetation class instance.
150 * @param extractorImplKey configuration key for the implementation class
151 * @return implemetation class instance
153 public static NameExtractor getNameExtractorImpl(String extractorImplKey) {
154 String nameExtractorImplClassName =
155 nameExtractorImplMap.get(extractorImplKey).getImplementationClass();
157 return CommonMethods.newInstance(nameExtractorImplClassName, NameExtractor.class);
160 public Map<String, UnifiedSubstitutionData> getUnifiedSubstitutionData() {
161 return unifiedSubstitutionData;
164 public void setUnifiedSubstitutionData(
165 Map<String, UnifiedSubstitutionData> unifiedSubstitutionData) {
166 this.unifiedSubstitutionData = unifiedSubstitutionData;
169 public void addCleanedNodeTemplate(String serviceTemplateName,
170 String nodeTemplateId,
171 UnifiedCompositionEntity unifiedCompositionEntity,
172 NodeTemplate nodeTemplate) {
173 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
174 this.unifiedSubstitutionData
175 .get(serviceTemplateName)
176 .addCleanedNodeTemplate(nodeTemplateId, unifiedCompositionEntity, nodeTemplate);
179 public NodeTemplate getCleanedNodeTemplate(String serviceTemplateName,
180 String nodeTemplateId) {
181 return this.unifiedSubstitutionData.get(serviceTemplateName)
182 .getCleanedNodeTemplate(nodeTemplateId);
185 public void addUnifiedNestedNodeTemplateId(String serviceTemplateName,
186 String nestedNodeTemplateId,
187 String unifiedNestedNodeTemplateId) {
188 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
189 this.unifiedSubstitutionData.get(serviceTemplateName)
190 .addUnifiedNestedNodeTemplateId(nestedNodeTemplateId, unifiedNestedNodeTemplateId);
193 public Optional<String> getUnifiedNestedNodeTemplateId(String serviceTemplateName,
194 String nestedNodeTemplateId) {
195 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
196 : this.unifiedSubstitutionData.get(serviceTemplateName)
197 .getUnifiedNestedNodeTemplateId(nestedNodeTemplateId);
200 public void addUnifiedNestedNodeTypeId(String serviceTemplateName,
201 String nestedNodeTypeId,
202 String unifiedNestedNodeTypeId) {
203 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
204 this.unifiedSubstitutionData.get(serviceTemplateName)
205 .addUnifiedNestedNodeTypeId(nestedNodeTypeId, unifiedNestedNodeTypeId);
208 public Optional<String> getUnifiedNestedNodeTypeId(String serviceTemplateName,
209 String nestedNodeTemplateId) {
210 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
211 : this.unifiedSubstitutionData.get(serviceTemplateName)
212 .getUnifiedNestedNodeTypeId(nestedNodeTemplateId);
215 public ConsolidationData getConsolidationData() {
216 return consolidationData;
219 public void setConsolidationData(ConsolidationData consolidationData) {
220 this.consolidationData = consolidationData;
223 public void addManifestFile(String fileName, FileData.Type fileType) {
224 this.manifestFiles.put(fileName, fileType);
227 public Set<String> getNestedHeatsFiles() {
228 return nestedHeatsFiles;
231 public Map<String, Set<String>> getHeatStackGroupMembers() {
232 return heatStackGroupMembers;
235 public FileContentHandler getFiles() {
239 public void setFiles(Map<String, byte[]> files) {
240 this.files.putAll(files);
243 public InputStream getFileContent(String fileName) {
244 return files.getFileContent(fileName);
247 public void addFile(String name, byte[] content) {
248 files.addFile(name, content);
251 public ManifestFile getManifest() {
255 public void setManifest(ManifestFile manifest) {
256 this.manifest = manifest;
259 public Map<String, Set<String>> getTranslatedResources() {
260 return translatedResources;
263 public Map<String, Map<String, String>> getTranslatedIds() {
264 return translatedIds;
267 public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String
268 nestedHeatFileNameToSkip){
269 Set<String> allTranslatedResourceIds = new HashSet<>();
271 this.translatedIds.entrySet().stream().filter(
272 heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey()
273 .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> {
274 allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet());
277 return allTranslatedResourceIds;
280 // get tosca name from mapping configuration file
281 //element type - parameter/attribute
282 // element name - heat parameter/attribute name
283 //return value - tosca parameter/attribute name
284 public String getElementMapping(String resourceType, String elementType, String elementName) {
285 if (Objects.isNull(translationMapping.get(resourceType))) {
288 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
291 return translationMapping.get(resourceType).get(elementType).get(elementName);
294 public Map<String, String> getElementMapping(String resourceType, String elementType) {
295 if (Objects.isNull(translationMapping.get(resourceType))) {
298 return translationMapping.get(resourceType).get(elementType);
301 public Set<String> getElementSet(String resourceType, String elementType) {
302 if (Objects.isNull(translationMapping.get(resourceType))) {
303 return new HashSet<>();
305 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
306 return new HashSet<>();
308 return translationMapping.get(resourceType).get(elementType).keySet();
311 public Map<String, ServiceTemplate> getTranslatedServiceTemplates() {
312 return translatedServiceTemplates;
315 public ServiceTemplate getGlobalSubstitutionServiceTemplate() {
316 return getTranslatedServiceTemplates().get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
319 public FileContentHandler getExternalArtifacts() {
320 return externalArtifacts;
323 public void addExternalArtifacts(String name, byte[] content) {
324 this.externalArtifacts.addFile(name, content);
327 public Map<String, TranslatedHeatResource> getHeatSharedResourcesByParam() {
328 return heatSharedResourcesByParam;
331 public void addHeatSharedResourcesByParam(String parameterName, String resourceId,
333 this.addHeatSharedResourcesByParam(parameterName,
334 new TranslatedHeatResource(resourceId, resource));
337 private void addHeatSharedResourcesByParam(String parameterName,
338 TranslatedHeatResource translatedHeatResource) {
339 this.heatSharedResourcesByParam.put(parameterName, translatedHeatResource);
342 public Map<String, ServiceTemplate> getGlobalServiceTemplates() {
343 return globalServiceTemplates;
346 public Map<String, String> getNestedHeatFileName() {
347 return nestedHeatFileName;
350 public void addNestedHeatFileName(String substituteServiceTempalteName,
351 String nestedHeatFileName) {
352 this.nestedHeatFileName.put(substituteServiceTempalteName, nestedHeatFileName);
355 public Map<String, Map<String, String>> getUsedHeatPseudoParams() {
356 return usedHeatPseudoParams;
359 public void addUsedHeatPseudoParams(String heatFileName, String heatPseudoParam, String
360 translatedToscaParam) {
361 if (Objects.isNull(this.usedHeatPseudoParams.get(heatFileName))) {
362 this.usedHeatPseudoParams.put(heatFileName, new HashMap<>());
364 this.usedHeatPseudoParams.get(heatFileName).put(heatPseudoParam, translatedToscaParam);
367 public Set<String> getTranslatedResourceIdsFromOtherFiles(String fileNameToIgnore){
368 if(MapUtils.isEmpty(this.translatedResources)){
369 return new HashSet<>();
372 Set<String> translatedResourceIds = new HashSet<>();
374 this.translatedResources.entrySet().stream().filter(entry -> !entry.getKey().equals(fileNameToIgnore))
375 .forEach(entry -> translatedResourceIds.addAll(entry.getValue()));
377 return translatedResourceIds;
381 * Add the unified substitution data info in context. Contains a mapping of original node
382 * template id and the new node template id in the abstract substitute
384 * @param serviceTemplateFileName the service template file name
385 * @param originalNodeTemplateId the original node template id
386 * @param abstractNodeTemplateId the node template id in the abstract substitute
388 public void addUnifiedSubstitutionData(String serviceTemplateFileName,
389 String originalNodeTemplateId,
390 String abstractNodeTemplateId) {
392 Map<String, String> nodeAbstractNodeTemplateIdMap = this.getUnifiedSubstitutionData()
393 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
394 .getNodesRelatedAbstractNode();
396 if (nodeAbstractNodeTemplateIdMap == null) {
397 nodeAbstractNodeTemplateIdMap = new HashMap<>();
400 if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
401 throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(originalNodeTemplateId).build());
403 nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
404 this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
405 nodeAbstractNodeTemplateIdMap);
409 * Add the unified substitution data info in context. Contains a mapping of original node
410 * template id and the new node template id in the abstract substitute
412 * @param serviceTemplateFileName the service template file name
413 * @param originalNodeTemplateId the original node template id
414 * @param substitutionServiceTemplateNodeTemplateId the node template id in the substitution
417 public void addSubstitutionServiceTemplateUnifiedSubstitutionData(
418 String serviceTemplateFileName,
419 String originalNodeTemplateId,
420 String substitutionServiceTemplateNodeTemplateId) {
422 Map<String, String> nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = this
423 .getUnifiedSubstitutionData()
424 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
425 .getNodesRelatedSubstitutionServiceTemplateNode();
427 if (nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap == null) {
428 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = new HashMap<>();
430 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap.put(originalNodeTemplateId,
431 substitutionServiceTemplateNodeTemplateId);
432 this.getUnifiedSubstitutionData().get(serviceTemplateFileName)
433 .setNodesRelatedSubstitutionServiceTemplateNode(
434 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap);
438 * Get unified abstract node template which is mapped to the input node template id.
440 * @param serviceTemplate the service template
441 * @param nodeTemplateId the node template id
443 public String getUnifiedAbstractNodeTemplateId(ServiceTemplate serviceTemplate,
444 String nodeTemplateId) {
445 UnifiedSubstitutionData unifiedSubstitutionData =
446 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
447 return unifiedSubstitutionData.getNodesRelatedAbstractNode().get(nodeTemplateId);
451 * Get unified node template in the substitution service template which is mapped to the
452 * original input node template id.
454 * @param serviceTemplate the service template
455 * @param nodeTemplateId the node template id
457 public String getUnifiedSubstitutionNodeTemplateId(ServiceTemplate serviceTemplate,
458 String nodeTemplateId) {
459 UnifiedSubstitutionData unifiedSubstitutionData =
460 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
461 return unifiedSubstitutionData.getNodesRelatedSubstitutionServiceTemplateNode()
462 .get(nodeTemplateId);
465 public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
466 String computeType) {
467 return this.unifiedSubstitutionData.get(serviceTemplateName)
468 .getHandledNestedComputeNodeTemplateIndex(computeType);
471 public void updateHandledComputeType(String serviceTemplateName,
472 String handledComputeType,
473 String nestedServiceTemplateFileName) {
474 String globalSTName =
475 ToscaUtil.getServiceTemplateFileName(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
476 this.unifiedSubstitutionData.putIfAbsent(
477 globalSTName, new UnifiedSubstitutionData());
478 this.unifiedSubstitutionData.get(globalSTName)
479 .addHandledComputeType(handledComputeType);
480 this.unifiedSubstitutionData.get(globalSTName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
482 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
483 this.unifiedSubstitutionData.get(serviceTemplateName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
486 public void addHandledComputeTypeInServiceTemplate(String serviceTemplateName,
487 String handledComputeType){
488 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
489 this.unifiedSubstitutionData.get(serviceTemplateName).addHandledComputeType(handledComputeType);
492 public boolean isComputeTypeHandledInServiceTemplate(String serviceTemplateName,
493 String computeType) {
494 return !Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))
495 && this.unifiedSubstitutionData.get(serviceTemplateName)
496 .isComputeTypeHandledInServiceTemplate(computeType);
499 public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
500 String nestedServiceTemplateName,
502 return this.unifiedSubstitutionData.get(serviceTemplateName)
503 .getHandledNestedComputeNodeTemplateIndex(computeType);
506 public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName,
507 String nestedServiceTemplateFileName) {
508 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
511 return this.unifiedSubstitutionData.get(serviceTemplateName)
512 .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName);
515 public Set<String> getAllRelatedNestedNodeTypeIds(){
516 String globalName = "GlobalSubstitutionTypes";
517 if(Objects.isNull(this.unifiedSubstitutionData) ||
518 Objects.isNull(this.unifiedSubstitutionData.get(globalName))){
519 return new HashSet<>();
522 return this.unifiedSubstitutionData.get(globalName).getAllRelatedNestedNodeTypeIds();
525 public boolean isUnifiedHandledServiceTemplate(ServiceTemplate serviceTemplate) {
526 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
527 if (unifiedHandledServiceTemplates.contains(serviceTemplateFileName)) {
535 public void addUnifiedHandledServiceTeamplte(ServiceTemplate serviceTemplate) {
536 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
537 this.unifiedHandledServiceTemplates.add(serviceTemplateFileName);
540 public boolean isNestedNodeWasHandled(String serviceTemplateName,
541 String nestedNodeTemplateId) {
542 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
545 return this.unifiedSubstitutionData.get(serviceTemplateName)
546 .isNestedNodeWasHandled(nestedNodeTemplateId);
549 public void addNestedNodeAsHandled(String serviceTemplateName,
550 String nestedNodeTemplateId) {
551 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
552 this.unifiedSubstitutionData.get(serviceTemplateName)
553 .addHandledNestedNodes(nestedNodeTemplateId);
556 public void updateUsedTimesForNestedComputeNodeType(String serviceTemplateName,
557 String computeType) {
558 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
560 this.unifiedSubstitutionData.get(serviceTemplateName)
561 .updateUsedTimesForNestedComputeNodeType(computeType);
564 public int getGlobalNodeTypeIndex(String serviceTemplateName,
565 String computeType) {
566 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
569 return this.unifiedSubstitutionData.get(serviceTemplateName).getGlobalNodeTypeIndex
573 public void addNewPropertyIdToNodeTemplate(String serviceTemplateName,
574 String newPropertyId,
575 Object origPropertyValue){
576 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
577 this.unifiedSubstitutionData.get(serviceTemplateName).addNewPropertyIdToNodeTemplate(
578 newPropertyId, origPropertyValue);
581 public Optional<Object> getNewPropertyInputParamId(String serviceTemplateName,
582 String newPropertyId){
583 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
584 return Optional.empty();
587 return this.unifiedSubstitutionData.get(serviceTemplateName).getNewPropertyInputParam
591 public Map<String, Object> getAllNewPropertyInputParamIdsPerNodeTenplateId(String serviceTemplateName){
592 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
593 return new HashMap<>();
596 return this.unifiedSubstitutionData.get(serviceTemplateName).getAllNewPropertyInputParamIds();
600 public boolean isServiceTemplateWithoutNodeTemplatesSection(String serviceTemplateName){
601 return Objects.nonNull(serviceTemplateName)
602 && serviceTemplatesWithoutNodeTemplateSection.contains(serviceTemplateName);
605 public void addServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
606 this.serviceTemplatesWithoutNodeTemplateSection.add(serviceTemplateName);
609 public void addNestedNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
610 this.nodeTemplateIdsPointingToStWithoutNodeTemplates.add(nodeTemplateId);
613 public boolean isNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
614 return Objects.nonNull(nodeTemplateId)
615 && nodeTemplateIdsPointingToStWithoutNodeTemplates.contains(nodeTemplateId);
618 public void updateRequirementAssignmentIdIndex(String serviceTemplateName,
619 String nodeTemplateId,
620 String requirementId){
621 requirementIdAppearanceInNodeTemplate.putIfAbsent(serviceTemplateName, new HashMap<>());
622 requirementIdAppearanceInNodeTemplate
623 .get(serviceTemplateName).putIfAbsent(nodeTemplateId, new HashMap<>());
625 Map<String, Integer> requirementIdToAppearance =
626 requirementIdAppearanceInNodeTemplate.get(serviceTemplateName).get(nodeTemplateId);
628 if(requirementIdToAppearance.containsKey(requirementId)){
629 requirementIdToAppearance
630 .put(requirementId, requirementIdToAppearance.get(requirementId) + 1);
632 requirementIdToAppearance.put(requirementId, 0);