2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.translator.datatypes.heattotosca;
23 import org.openecomp.config.api.Configuration;
24 import org.openecomp.config.api.ConfigurationManager;
25 import org.openecomp.core.utilities.CommonMethods;
26 import org.openecomp.core.utilities.file.FileContentHandler;
27 import org.openecomp.sdc.common.errors.CoreException;
28 import org.openecomp.sdc.common.utils.SdcCommon;
29 import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
30 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
31 import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
32 import org.openecomp.sdc.heat.datatypes.model.Resource;
33 import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
34 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
35 import org.openecomp.sdc.tosca.services.ToscaUtil;
36 import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
37 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionEntity;
38 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedSubstitutionData;
39 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
40 import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
41 import org.openecomp.sdc.translator.services.heattotosca.Constants;
42 import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
43 import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
44 import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
46 import java.io.InputStream;
47 import java.util.HashMap;
48 import java.util.HashSet;
49 import java.util.List;
51 import java.util.Objects;
52 import java.util.Optional;
56 public class TranslationContext {
59 private static Map<String, Map<String, Map<String, String>>> translationMapping;
60 private static Map<String, ServiceTemplate> globalServiceTemplates;
61 private static Map<String, ImplementationConfiguration> nameExtractorImplMap;
62 private static Map<String, ImplementationConfiguration> supportedConsolidationComputeResources;
63 private static Map<String, ImplementationConfiguration> supportedConsolidationPortResources;
64 private static List enrichPortResourceProperties;
67 Configuration config = ConfigurationManager.lookup();
68 String propertyFileName = SdcCommon.HEAT_TO_TOSCA_MAPPING_CONF;
70 config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY);
72 globalServiceTemplates = GlobalTypesGenerator.getGlobalTypesServiceTemplate();
73 } catch (Exception exc) {
74 throw new RuntimeException("Failed to load GlobalTypes", exc);
76 nameExtractorImplMap = config.populateMap(ConfigConstants.TRANSLATOR_NAMESPACE,
77 ConfigConstants.NAMING_CONVENTION_EXTRACTOR_IMPL_KEY, ImplementationConfiguration.class);
78 supportedConsolidationComputeResources = config.populateMap(ConfigConstants
79 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
80 .SUPPORTED_CONSOLIDATION_COMPUTE_RESOURCES_KEY, ImplementationConfiguration.class);
81 supportedConsolidationPortResources = config.populateMap(ConfigConstants
82 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
83 .SUPPORTED_CONSOLIDATION_PORT_RESOURCES_KEY, ImplementationConfiguration.class);
84 enrichPortResourceProperties = config.getAsStringValues(ConfigConstants
85 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
86 .ENRICH_PORT_RESOURCE_PROP);
90 private ManifestFile manifest;
92 public static List getEnrichPortResourceProperties() {
93 return enrichPortResourceProperties;
96 private FileContentHandler files = new FileContentHandler();
97 private Map<String, FileData.Type> manifestFiles = new HashMap<>();
98 //Key - file name, value - file type
99 private Set<String> nestedHeatsFiles = new HashSet<>();
100 private FileContentHandler externalArtifacts = new FileContentHandler();
101 // Key - heat file name,value - set of heat resource ids which were translated
102 private Map<String, Set<String>> translatedResources = new HashMap<>();
103 // Key - heat file name, value - translated Node template id
104 private Map<String, Set<String>> heatStackGroupMembers = new HashMap<>();
105 // Key - heat file name, value - Map with Key - heat resource Id, Value - tosca entity template id
106 private Map<String, Map<String, String>> translatedIds = new HashMap<>();
107 // key - service template type, value - translated service templates
108 private Map<String, ServiceTemplate> translatedServiceTemplates = new HashMap<>();
109 //key - heat param name, value - shared resource data
110 private Map<String, TranslatedHeatResource> heatSharedResourcesByParam = new HashMap<>();
111 //key - translated substitute service template file name, value - source nested heat file name
112 private Map<String, String> nestedHeatFileName = new HashMap<>();
113 //Key - heat file name,value - Map eith key - heat pseudo param name,
114 // value - translated tosca parameter name
115 private Map<String, Map<String, String>> usedHeatPseudoParams = new HashMap<>();
116 //Consolidation data gathered for Unified TOSCA model
117 private ConsolidationData consolidationData = new ConsolidationData();
118 private Map<String, UnifiedSubstitutionData> unifiedSubstitutionData = new HashMap<>();
119 private Set<String> unifiedHandledServiceTemplates = new HashSet<>();
121 private Map<String, Map<String, Map<String, Integer>>>
122 requirementIdAppearanceInNodeTemplate = new HashMap<>();
124 private Set<String> serviceTemplatesWithoutNodeTemplateSection = new HashSet<>();
126 private Set<String> nodeTemplateIdsPointingToStWithoutNodeTemplates = new HashSet<>();
128 public static Map<String, ImplementationConfiguration>
129 getSupportedConsolidationComputeResources() {
130 return supportedConsolidationComputeResources;
133 public static void setSupportedConsolidationComputeResources(
134 Map<String, ImplementationConfiguration> supportedConsolidationComputeResources) {
135 TranslationContext.supportedConsolidationComputeResources =
136 supportedConsolidationComputeResources;
139 public static Map<String, ImplementationConfiguration> getSupportedConsolidationPortResources() {
140 return supportedConsolidationPortResources;
143 public static void setSupportedConsolidationPortResources(
144 Map<String, ImplementationConfiguration> supportedConsolidationPortResources) {
145 TranslationContext.supportedConsolidationPortResources = supportedConsolidationPortResources;
149 * Get nameExtractor implemetation class instance.
151 * @param extractorImplKey configuration key for the implementation class
152 * @return implemetation class instance
154 public static NameExtractor getNameExtractorImpl(String extractorImplKey) {
155 String nameExtractorImplClassName =
156 nameExtractorImplMap.get(extractorImplKey).getImplementationClass();
158 return CommonMethods.newInstance(nameExtractorImplClassName, NameExtractor.class);
161 public Map<String, UnifiedSubstitutionData> getUnifiedSubstitutionData() {
162 return unifiedSubstitutionData;
165 public void setUnifiedSubstitutionData(
166 Map<String, UnifiedSubstitutionData> unifiedSubstitutionData) {
167 this.unifiedSubstitutionData = unifiedSubstitutionData;
170 public void addCleanedNodeTemplate(String serviceTemplateName,
171 String nodeTemplateId,
172 UnifiedCompositionEntity unifiedCompositionEntity,
173 NodeTemplate nodeTemplate) {
174 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
175 this.unifiedSubstitutionData
176 .get(serviceTemplateName)
177 .addCleanedNodeTemplate(nodeTemplateId, unifiedCompositionEntity, nodeTemplate);
180 public NodeTemplate getCleanedNodeTemplate(String serviceTemplateName,
181 String nodeTemplateId) {
182 return this.unifiedSubstitutionData.get(serviceTemplateName)
183 .getCleanedNodeTemplate(nodeTemplateId);
186 public void addUnifiedNestedNodeTemplateId(String serviceTemplateName,
187 String nestedNodeTemplateId,
188 String unifiedNestedNodeTemplateId) {
189 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
190 this.unifiedSubstitutionData.get(serviceTemplateName)
191 .addUnifiedNestedNodeTemplateId(nestedNodeTemplateId, unifiedNestedNodeTemplateId);
194 public Optional<String> getUnifiedNestedNodeTemplateId(String serviceTemplateName,
195 String nestedNodeTemplateId) {
196 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
197 : this.unifiedSubstitutionData.get(serviceTemplateName)
198 .getUnifiedNestedNodeTemplateId(nestedNodeTemplateId);
201 public void addUnifiedNestedNodeTypeId(String serviceTemplateName,
202 String nestedNodeTypeId,
203 String unifiedNestedNodeTypeId) {
204 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
205 this.unifiedSubstitutionData.get(serviceTemplateName)
206 .addUnifiedNestedNodeTypeId(nestedNodeTypeId, unifiedNestedNodeTypeId);
209 public Optional<String> getUnifiedNestedNodeTypeId(String serviceTemplateName,
210 String nestedNodeTemplateId) {
211 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
212 : this.unifiedSubstitutionData.get(serviceTemplateName)
213 .getUnifiedNestedNodeTypeId(nestedNodeTemplateId);
216 public ConsolidationData getConsolidationData() {
217 return consolidationData;
220 public void setConsolidationData(ConsolidationData consolidationData) {
221 this.consolidationData = consolidationData;
224 public void addManifestFile(String fileName, FileData.Type fileType) {
225 this.manifestFiles.put(fileName, fileType);
228 public Set<String> getNestedHeatsFiles() {
229 return nestedHeatsFiles;
232 public Map<String, Set<String>> getHeatStackGroupMembers() {
233 return heatStackGroupMembers;
236 public FileContentHandler getFiles() {
240 public void setFiles(Map<String, byte[]> files) {
241 this.files.putAll(files);
244 public InputStream getFileContent(String fileName) {
245 return files.getFileContent(fileName);
248 public void addFile(String name, byte[] content) {
249 files.addFile(name, content);
252 public ManifestFile getManifest() {
256 public void setManifest(ManifestFile manifest) {
257 this.manifest = manifest;
260 public Map<String, Set<String>> getTranslatedResources() {
261 return translatedResources;
264 public Map<String, Map<String, String>> getTranslatedIds() {
265 return translatedIds;
268 public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String
269 nestedHeatFileNameToSkip){
270 Set<String> allTranslatedResourceIds = new HashSet<>();
272 this.translatedIds.entrySet().stream().filter(
273 heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey()
274 .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> {
275 allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet());
278 return allTranslatedResourceIds;
281 // get tosca name from mapping configuration file
282 //element type - parameter/attribute
283 // element name - heat parameter/attribute name
284 //return value - tosca parameter/attribute name
285 public String getElementMapping(String resourceType, String elementType, String elementName) {
286 if (Objects.isNull(translationMapping.get(resourceType))) {
289 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
292 return translationMapping.get(resourceType).get(elementType).get(elementName);
295 public Map<String, String> getElementMapping(String resourceType, String elementType) {
296 if (Objects.isNull(translationMapping.get(resourceType))) {
299 return translationMapping.get(resourceType).get(elementType);
302 public Set<String> getElementSet(String resourceType, String elementType) {
303 if (Objects.isNull(translationMapping.get(resourceType))) {
304 return new HashSet<>();
306 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
307 return new HashSet<>();
309 return translationMapping.get(resourceType).get(elementType).keySet();
312 public Map<String, ServiceTemplate> getTranslatedServiceTemplates() {
313 return translatedServiceTemplates;
316 public ServiceTemplate getGlobalSubstitutionServiceTemplate() {
317 return getTranslatedServiceTemplates().get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
320 public FileContentHandler getExternalArtifacts() {
321 return externalArtifacts;
324 public void addExternalArtifacts(String name, byte[] content) {
325 this.externalArtifacts.addFile(name, content);
328 public Map<String, TranslatedHeatResource> getHeatSharedResourcesByParam() {
329 return heatSharedResourcesByParam;
332 public void addHeatSharedResourcesByParam(String parameterName, String resourceId,
334 this.addHeatSharedResourcesByParam(parameterName,
335 new TranslatedHeatResource(resourceId, resource));
338 private void addHeatSharedResourcesByParam(String parameterName,
339 TranslatedHeatResource translatedHeatResource) {
340 this.heatSharedResourcesByParam.put(parameterName, translatedHeatResource);
343 public Map<String, ServiceTemplate> getGlobalServiceTemplates() {
344 return globalServiceTemplates;
347 public Map<String, String> getNestedHeatFileName() {
348 return nestedHeatFileName;
351 public void addNestedHeatFileName(String substituteServiceTempalteName,
352 String nestedHeatFileName) {
353 this.nestedHeatFileName.put(substituteServiceTempalteName, nestedHeatFileName);
356 public Map<String, Map<String, String>> getUsedHeatPseudoParams() {
357 return usedHeatPseudoParams;
360 public void addUsedHeatPseudoParams(String heatFileName, String heatPseudoParam, String
361 translatedToscaParam) {
362 if (Objects.isNull(this.usedHeatPseudoParams.get(heatFileName))) {
363 this.usedHeatPseudoParams.put(heatFileName, new HashMap<>());
365 this.usedHeatPseudoParams.get(heatFileName).put(heatPseudoParam, translatedToscaParam);
369 * Add the unified substitution data info in context. Contains a mapping of original node
370 * template id and the new node template id in the abstract substitute
372 * @param serviceTemplateFileName the service template file name
373 * @param originalNodeTemplateId the original node template id
374 * @param abstractNodeTemplateId the node template id in the abstract substitute
376 public void addUnifiedSubstitutionData(String serviceTemplateFileName,
377 String originalNodeTemplateId,
378 String abstractNodeTemplateId) {
380 Map<String, String> nodeAbstractNodeTemplateIdMap = this.getUnifiedSubstitutionData()
381 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
382 .getNodesRelatedAbstractNode();
384 if (nodeAbstractNodeTemplateIdMap == null) {
385 nodeAbstractNodeTemplateIdMap = new HashMap<>();
388 if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
389 throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(originalNodeTemplateId).build());
391 nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
392 this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
393 nodeAbstractNodeTemplateIdMap);
397 * Add the unified substitution data info in context. Contains a mapping of original node
398 * template id and the new node template id in the abstract substitute
400 * @param serviceTemplateFileName the service template file name
401 * @param originalNodeTemplateId the original node template id
402 * @param substitutionServiceTemplateNodeTemplateId the node template id in the substitution
405 public void addSubstitutionServiceTemplateUnifiedSubstitutionData(
406 String serviceTemplateFileName,
407 String originalNodeTemplateId,
408 String substitutionServiceTemplateNodeTemplateId) {
410 Map<String, String> nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = this
411 .getUnifiedSubstitutionData()
412 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
413 .getNodesRelatedSubstitutionServiceTemplateNode();
415 if (nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap == null) {
416 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = new HashMap<>();
418 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap.put(originalNodeTemplateId,
419 substitutionServiceTemplateNodeTemplateId);
420 this.getUnifiedSubstitutionData().get(serviceTemplateFileName)
421 .setNodesRelatedSubstitutionServiceTemplateNode(
422 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap);
426 * Get unified abstract node template which is mapped to the input node template id.
428 * @param serviceTemplate the service template
429 * @param nodeTemplateId the node template id
431 public String getUnifiedAbstractNodeTemplateId(ServiceTemplate serviceTemplate,
432 String nodeTemplateId) {
433 UnifiedSubstitutionData unifiedSubstitutionData =
434 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
435 return unifiedSubstitutionData.getNodesRelatedAbstractNode().get(nodeTemplateId);
439 * Get unified node template in the substitution service template which is mapped to the
440 * original input node template id.
442 * @param serviceTemplate the service template
443 * @param nodeTemplateId the node template id
445 public String getUnifiedSubstitutionNodeTemplateId(ServiceTemplate serviceTemplate,
446 String nodeTemplateId) {
447 UnifiedSubstitutionData unifiedSubstitutionData =
448 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
449 return unifiedSubstitutionData.getNodesRelatedSubstitutionServiceTemplateNode()
450 .get(nodeTemplateId);
453 public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
454 String computeType) {
455 return this.unifiedSubstitutionData.get(serviceTemplateName)
456 .getHandledNestedComputeNodeTemplateIndex(computeType);
459 public void updateHandledComputeType(String serviceTemplateName,
460 String handledComputeType,
461 String nestedServiceTemplateFileName) {
462 String globalSTName =
463 ToscaUtil.getServiceTemplateFileName(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
464 this.unifiedSubstitutionData.putIfAbsent(
465 globalSTName, new UnifiedSubstitutionData());
466 this.unifiedSubstitutionData.get(globalSTName)
467 .addHandledComputeType(handledComputeType);
468 this.unifiedSubstitutionData.get(globalSTName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
470 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
471 this.unifiedSubstitutionData.get(serviceTemplateName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
474 public void addHandledComputeTypeInServiceTemplate(String serviceTemplateName,
475 String handledComputeType){
476 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
477 this.unifiedSubstitutionData.get(serviceTemplateName).addHandledComputeType(handledComputeType);
480 public boolean isComputeTypeHandledInServiceTemplate(String serviceTemplateName,
481 String computeType) {
482 return !Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))
483 && this.unifiedSubstitutionData.get(serviceTemplateName)
484 .isComputeTypeHandledInServiceTemplate(computeType);
487 public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
488 String nestedServiceTemplateName,
490 return this.unifiedSubstitutionData.get(serviceTemplateName)
491 .getHandledNestedComputeNodeTemplateIndex(computeType);
494 public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName,
495 String nestedServiceTemplateFileName) {
496 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
499 return this.unifiedSubstitutionData.get(serviceTemplateName)
500 .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName);
503 public Set<String> getAllRelatedNestedNodeTypeIds(){
504 String globalName = "GlobalSubstitutionTypes";
505 if(Objects.isNull(this.unifiedSubstitutionData) ||
506 Objects.isNull(this.unifiedSubstitutionData.get(globalName))){
507 return new HashSet<>();
510 return this.unifiedSubstitutionData.get(globalName).getAllRelatedNestedNodeTypeIds();
513 public boolean isUnifiedHandledServiceTemplate(ServiceTemplate serviceTemplate) {
514 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
515 if (unifiedHandledServiceTemplates.contains(serviceTemplateFileName)) {
523 public void addUnifiedHandledServiceTeamplte(ServiceTemplate serviceTemplate) {
524 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
525 this.unifiedHandledServiceTemplates.add(serviceTemplateFileName);
528 public boolean isNestedNodeWasHandled(String serviceTemplateName,
529 String nestedNodeTemplateId) {
530 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
533 return this.unifiedSubstitutionData.get(serviceTemplateName)
534 .isNestedNodeWasHandled(nestedNodeTemplateId);
537 public void addNestedNodeAsHandled(String serviceTemplateName,
538 String nestedNodeTemplateId) {
539 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
540 this.unifiedSubstitutionData.get(serviceTemplateName)
541 .addHandledNestedNodes(nestedNodeTemplateId);
544 public void updateUsedTimesForNestedComputeNodeType(String serviceTemplateName,
545 String computeType) {
546 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
548 this.unifiedSubstitutionData.get(serviceTemplateName)
549 .updateUsedTimesForNestedComputeNodeType(computeType);
552 public int getGlobalNodeTypeIndex(String serviceTemplateName,
553 String computeType) {
554 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
557 return this.unifiedSubstitutionData.get(serviceTemplateName).getGlobalNodeTypeIndex
561 public void addNewPropertyIdToNodeTemplate(String serviceTemplateName,
562 String newPropertyId,
563 Object origPropertyValue){
564 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
565 this.unifiedSubstitutionData.get(serviceTemplateName).addNewPropertyIdToNodeTemplate(
566 newPropertyId, origPropertyValue);
569 public Optional<Object> getNewPropertyInputParamId(String serviceTemplateName,
570 String newPropertyId){
571 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
572 return Optional.empty();
575 return this.unifiedSubstitutionData.get(serviceTemplateName).getNewPropertyInputParam
579 public Map<String, Object> getAllNewPropertyInputParamIdsPerNodeTenplateId(String serviceTemplateName){
580 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
581 return new HashMap<>();
584 return this.unifiedSubstitutionData.get(serviceTemplateName).getAllNewPropertyInputParamIds();
588 public boolean isServiceTemplateWithoutNodeTemplatesSection(String serviceTemplateName){
589 return Objects.nonNull(serviceTemplateName)
590 && serviceTemplatesWithoutNodeTemplateSection.contains(serviceTemplateName);
593 public void addServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
594 this.serviceTemplatesWithoutNodeTemplateSection.add(serviceTemplateName);
597 public void addNestedNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
598 this.nodeTemplateIdsPointingToStWithoutNodeTemplates.add(nodeTemplateId);
601 public boolean isNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
602 return Objects.nonNull(nodeTemplateId)
603 && nodeTemplateIdsPointingToStWithoutNodeTemplates.contains(nodeTemplateId);
606 public void updateRequirementAssignmentIdIndex(String serviceTemplateName,
607 String nodeTemplateId,
608 String requirementId){
609 requirementIdAppearanceInNodeTemplate.putIfAbsent(serviceTemplateName, new HashMap<>());
610 requirementIdAppearanceInNodeTemplate
611 .get(serviceTemplateName).putIfAbsent(nodeTemplateId, new HashMap<>());
613 Map<String, Integer> requirementIdToAppearance =
614 requirementIdAppearanceInNodeTemplate.get(serviceTemplateName).get(nodeTemplateId);
616 if(requirementIdToAppearance.containsKey(requirementId)){
617 requirementIdToAppearance
618 .put(requirementId, requirementIdToAppearance.get(requirementId) + 1);
620 requirementIdToAppearance.put(requirementId, 0);