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.apache.commons.collections.CollectionUtils;
24 import org.apache.commons.collections.MapUtils;
25 import org.openecomp.config.api.Configuration;
26 import org.openecomp.config.api.ConfigurationManager;
27 import org.openecomp.core.utilities.CommonMethods;
28 import org.openecomp.core.utilities.file.FileContentHandler;
29 import org.openecomp.sdc.common.errors.CoreException;
30 import org.openecomp.sdc.common.utils.SdcCommon;
31 import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
32 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
33 import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
34 import org.openecomp.sdc.heat.datatypes.model.Resource;
35 import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
36 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
37 import org.openecomp.sdc.tosca.services.ToscaUtil;
38 import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
39 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionEntity;
40 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedSubstitutionData;
41 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
42 import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
43 import org.openecomp.sdc.translator.services.heattotosca.Constants;
44 import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
45 import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
46 import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
48 import java.io.InputStream;
49 import java.util.HashMap;
50 import java.util.HashSet;
51 import java.util.List;
53 import java.util.Objects;
54 import java.util.Optional;
58 public class TranslationContext {
61 private static Map<String, Map<String, Map<String, String>>> translationMapping;
62 private static Map<String, ServiceTemplate> globalServiceTemplates;
63 private static Map<String, ImplementationConfiguration> nameExtractorImplMap;
64 private static Map<String, ImplementationConfiguration> supportedConsolidationComputeResources;
65 private static Map<String, ImplementationConfiguration> supportedConsolidationPortResources;
66 private static List enrichPortResourceProperties;
69 Configuration config = ConfigurationManager.lookup();
70 String propertyFileName = SdcCommon.HEAT_TO_TOSCA_MAPPING_CONF;
72 config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY);
74 globalServiceTemplates = GlobalTypesGenerator.getGlobalTypesServiceTemplate();
75 } catch (Exception exc) {
76 throw new RuntimeException("Failed to load GlobalTypes", exc);
78 nameExtractorImplMap = config.populateMap(ConfigConstants.TRANSLATOR_NAMESPACE,
79 ConfigConstants.NAMING_CONVENTION_EXTRACTOR_IMPL_KEY, ImplementationConfiguration.class);
80 supportedConsolidationComputeResources = config.populateMap(ConfigConstants
81 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
82 .SUPPORTED_CONSOLIDATION_COMPUTE_RESOURCES_KEY, ImplementationConfiguration.class);
83 supportedConsolidationPortResources = config.populateMap(ConfigConstants
84 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
85 .SUPPORTED_CONSOLIDATION_PORT_RESOURCES_KEY, ImplementationConfiguration.class);
86 enrichPortResourceProperties = config.getAsStringValues(ConfigConstants
87 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
88 .ENRICH_PORT_RESOURCE_PROP);
92 private ManifestFile manifest;
94 public static List getEnrichPortResourceProperties() {
95 return enrichPortResourceProperties;
98 private FileContentHandler files = new FileContentHandler();
99 private Map<String, FileData.Type> manifestFiles = new HashMap<>();
100 //Key - file name, value - file type
101 private Set<String> nestedHeatsFiles = new HashSet<>();
102 private FileContentHandler externalArtifacts = new FileContentHandler();
103 // Key - heat file name,value - set of heat resource ids which were translated
104 private Map<String, Set<String>> translatedResources = new HashMap<>();
105 // Key - heat file name, value - translated Node template id
106 private Map<String, Set<String>> heatStackGroupMembers = new HashMap<>();
107 // Key - heat file name, value - Map with Key - heat resource Id, Value - tosca entity template id
108 private Map<String, Map<String, String>> translatedIds = new HashMap<>();
109 // key - service template type, value - translated service templates
110 private Map<String, ServiceTemplate> translatedServiceTemplates = new HashMap<>();
111 //key - heat param name, value - shared resource data
112 private Map<String, TranslatedHeatResource> heatSharedResourcesByParam = new HashMap<>();
113 //key - translated substitute service template file name, value - source nested heat file name
114 private Map<String, String> nestedHeatFileName = new HashMap<>();
115 //Key - heat file name,value - Map eith key - heat pseudo param name,
116 // value - translated tosca parameter name
117 private Map<String, Map<String, String>> usedHeatPseudoParams = new HashMap<>();
118 //Consolidation data gathered for Unified TOSCA model
119 private ConsolidationData consolidationData = new ConsolidationData();
120 private Map<String, UnifiedSubstitutionData> unifiedSubstitutionData = new HashMap<>();
121 private Set<String> unifiedHandledServiceTemplates = new HashSet<>();
123 private Map<String, Map<String, Map<String, Integer>>>
124 requirementIdAppearanceInNodeTemplate = new HashMap<>();
126 private Set<String> serviceTemplatesWithoutNodeTemplateSection = new HashSet<>();
128 private Set<String> nodeTemplateIdsPointingToStWithoutNodeTemplates = new HashSet<>();
130 public static Map<String, ImplementationConfiguration>
131 getSupportedConsolidationComputeResources() {
132 return supportedConsolidationComputeResources;
135 public static void setSupportedConsolidationComputeResources(
136 Map<String, ImplementationConfiguration> supportedConsolidationComputeResources) {
137 TranslationContext.supportedConsolidationComputeResources =
138 supportedConsolidationComputeResources;
141 public static Map<String, ImplementationConfiguration> getSupportedConsolidationPortResources() {
142 return supportedConsolidationPortResources;
145 public static void setSupportedConsolidationPortResources(
146 Map<String, ImplementationConfiguration> supportedConsolidationPortResources) {
147 TranslationContext.supportedConsolidationPortResources = supportedConsolidationPortResources;
151 * Get nameExtractor implemetation class instance.
153 * @param extractorImplKey configuration key for the implementation class
154 * @return implemetation class instance
156 public static NameExtractor getNameExtractorImpl(String extractorImplKey) {
157 String nameExtractorImplClassName =
158 nameExtractorImplMap.get(extractorImplKey).getImplementationClass();
160 return CommonMethods.newInstance(nameExtractorImplClassName, NameExtractor.class);
163 public Map<String, UnifiedSubstitutionData> getUnifiedSubstitutionData() {
164 return unifiedSubstitutionData;
167 public void setUnifiedSubstitutionData(
168 Map<String, UnifiedSubstitutionData> unifiedSubstitutionData) {
169 this.unifiedSubstitutionData = unifiedSubstitutionData;
172 public void addCleanedNodeTemplate(String serviceTemplateName,
173 String nodeTemplateId,
174 UnifiedCompositionEntity unifiedCompositionEntity,
175 NodeTemplate nodeTemplate) {
176 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
177 this.unifiedSubstitutionData
178 .get(serviceTemplateName)
179 .addCleanedNodeTemplate(nodeTemplateId, unifiedCompositionEntity, nodeTemplate);
182 public NodeTemplate getCleanedNodeTemplate(String serviceTemplateName,
183 String nodeTemplateId) {
184 return this.unifiedSubstitutionData.get(serviceTemplateName)
185 .getCleanedNodeTemplate(nodeTemplateId);
188 public void addUnifiedNestedNodeTemplateId(String serviceTemplateName,
189 String nestedNodeTemplateId,
190 String unifiedNestedNodeTemplateId) {
191 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
192 this.unifiedSubstitutionData.get(serviceTemplateName)
193 .addUnifiedNestedNodeTemplateId(nestedNodeTemplateId, unifiedNestedNodeTemplateId);
196 public Optional<String> getUnifiedNestedNodeTemplateId(String serviceTemplateName,
197 String nestedNodeTemplateId) {
198 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
199 : this.unifiedSubstitutionData.get(serviceTemplateName)
200 .getUnifiedNestedNodeTemplateId(nestedNodeTemplateId);
203 public void addUnifiedNestedNodeTypeId(String serviceTemplateName,
204 String nestedNodeTypeId,
205 String unifiedNestedNodeTypeId) {
206 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
207 this.unifiedSubstitutionData.get(serviceTemplateName)
208 .addUnifiedNestedNodeTypeId(nestedNodeTypeId, unifiedNestedNodeTypeId);
211 public Optional<String> getUnifiedNestedNodeTypeId(String serviceTemplateName,
212 String nestedNodeTemplateId) {
213 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
214 : this.unifiedSubstitutionData.get(serviceTemplateName)
215 .getUnifiedNestedNodeTypeId(nestedNodeTemplateId);
218 public ConsolidationData getConsolidationData() {
219 return consolidationData;
222 public void setConsolidationData(ConsolidationData consolidationData) {
223 this.consolidationData = consolidationData;
226 public void addManifestFile(String fileName, FileData.Type fileType) {
227 this.manifestFiles.put(fileName, fileType);
230 public Set<String> getNestedHeatsFiles() {
231 return nestedHeatsFiles;
234 public Map<String, Set<String>> getHeatStackGroupMembers() {
235 return heatStackGroupMembers;
238 public FileContentHandler getFiles() {
242 public void setFiles(Map<String, byte[]> files) {
243 this.files.putAll(files);
246 public InputStream getFileContent(String fileName) {
247 return files.getFileContent(fileName);
250 public void addFile(String name, byte[] content) {
251 files.addFile(name, content);
254 public ManifestFile getManifest() {
258 public void setManifest(ManifestFile manifest) {
259 this.manifest = manifest;
262 public Map<String, Set<String>> getTranslatedResources() {
263 return translatedResources;
266 public Map<String, Map<String, String>> getTranslatedIds() {
267 return translatedIds;
270 public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String
271 nestedHeatFileNameToSkip){
272 Set<String> allTranslatedResourceIds = new HashSet<>();
274 this.translatedIds.entrySet().stream().filter(
275 heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey()
276 .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> {
277 allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet());
280 return allTranslatedResourceIds;
283 // get tosca name from mapping configuration file
284 //element type - parameter/attribute
285 // element name - heat parameter/attribute name
286 //return value - tosca parameter/attribute name
287 public String getElementMapping(String resourceType, String elementType, String elementName) {
288 if (Objects.isNull(translationMapping.get(resourceType))) {
291 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
294 return translationMapping.get(resourceType).get(elementType).get(elementName);
297 public Map<String, String> getElementMapping(String resourceType, String elementType) {
298 if (Objects.isNull(translationMapping.get(resourceType))) {
301 return translationMapping.get(resourceType).get(elementType);
304 public Set<String> getElementSet(String resourceType, String elementType) {
305 if (Objects.isNull(translationMapping.get(resourceType))) {
306 return new HashSet<>();
308 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
309 return new HashSet<>();
311 return translationMapping.get(resourceType).get(elementType).keySet();
314 public Map<String, ServiceTemplate> getTranslatedServiceTemplates() {
315 return translatedServiceTemplates;
318 public ServiceTemplate getGlobalSubstitutionServiceTemplate() {
319 return getTranslatedServiceTemplates().get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
322 public FileContentHandler getExternalArtifacts() {
323 return externalArtifacts;
326 public void addExternalArtifacts(String name, byte[] content) {
327 this.externalArtifacts.addFile(name, content);
330 public Map<String, TranslatedHeatResource> getHeatSharedResourcesByParam() {
331 return heatSharedResourcesByParam;
334 public void addHeatSharedResourcesByParam(String parameterName, String resourceId,
336 this.addHeatSharedResourcesByParam(parameterName,
337 new TranslatedHeatResource(resourceId, resource));
340 private void addHeatSharedResourcesByParam(String parameterName,
341 TranslatedHeatResource translatedHeatResource) {
342 this.heatSharedResourcesByParam.put(parameterName, translatedHeatResource);
345 public Map<String, ServiceTemplate> getGlobalServiceTemplates() {
346 return globalServiceTemplates;
349 public Map<String, String> getNestedHeatFileName() {
350 return nestedHeatFileName;
353 public void addNestedHeatFileName(String substituteServiceTempalteName,
354 String nestedHeatFileName) {
355 this.nestedHeatFileName.put(substituteServiceTempalteName, nestedHeatFileName);
358 public Map<String, Map<String, String>> getUsedHeatPseudoParams() {
359 return usedHeatPseudoParams;
362 public void addUsedHeatPseudoParams(String heatFileName, String heatPseudoParam, String
363 translatedToscaParam) {
364 if (Objects.isNull(this.usedHeatPseudoParams.get(heatFileName))) {
365 this.usedHeatPseudoParams.put(heatFileName, new HashMap<>());
367 this.usedHeatPseudoParams.get(heatFileName).put(heatPseudoParam, translatedToscaParam);
370 public Set<String> getTranslatedResourceIdsFromOtherFiles(String fileNameToIgnore){
371 if(MapUtils.isEmpty(this.translatedResources)){
372 return new HashSet<>();
375 Set<String> translatedResourceIds = new HashSet<>();
377 this.translatedResources.entrySet().stream().filter(entry -> !entry.getKey().equals(fileNameToIgnore))
378 .forEach(entry -> translatedResourceIds.addAll(entry.getValue()));
380 return translatedResourceIds;
384 * Add the unified substitution data info in context. Contains a mapping of original node
385 * template id and the new node template id in the abstract substitute
387 * @param serviceTemplateFileName the service template file name
388 * @param originalNodeTemplateId the original node template id
389 * @param abstractNodeTemplateId the node template id in the abstract substitute
391 public void addUnifiedSubstitutionData(String serviceTemplateFileName,
392 String originalNodeTemplateId,
393 String abstractNodeTemplateId) {
395 Map<String, String> nodeAbstractNodeTemplateIdMap = this.getUnifiedSubstitutionData()
396 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
397 .getNodesRelatedAbstractNode();
399 if (nodeAbstractNodeTemplateIdMap == null) {
400 nodeAbstractNodeTemplateIdMap = new HashMap<>();
403 if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
404 throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(originalNodeTemplateId).build());
406 nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
407 this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
408 nodeAbstractNodeTemplateIdMap);
412 * Add the unified substitution data info in context. Contains a mapping of original node
413 * template id and the new node template id in the abstract substitute
415 * @param serviceTemplateFileName the service template file name
416 * @param originalNodeTemplateId the original node template id
417 * @param substitutionServiceTemplateNodeTemplateId the node template id in the substitution
420 public void addSubstitutionServiceTemplateUnifiedSubstitutionData(
421 String serviceTemplateFileName,
422 String originalNodeTemplateId,
423 String substitutionServiceTemplateNodeTemplateId) {
425 Map<String, String> nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = this
426 .getUnifiedSubstitutionData()
427 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
428 .getNodesRelatedSubstitutionServiceTemplateNode();
430 if (nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap == null) {
431 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = new HashMap<>();
433 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap.put(originalNodeTemplateId,
434 substitutionServiceTemplateNodeTemplateId);
435 this.getUnifiedSubstitutionData().get(serviceTemplateFileName)
436 .setNodesRelatedSubstitutionServiceTemplateNode(
437 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap);
441 * Get unified abstract node template which is mapped to the input node template id.
443 * @param serviceTemplate the service template
444 * @param nodeTemplateId the node template id
446 public String getUnifiedAbstractNodeTemplateId(ServiceTemplate serviceTemplate,
447 String nodeTemplateId) {
448 UnifiedSubstitutionData unifiedSubstitutionData =
449 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
450 return unifiedSubstitutionData.getNodesRelatedAbstractNode().get(nodeTemplateId);
454 * Get unified node template in the substitution service template which is mapped to the
455 * original input node template id.
457 * @param serviceTemplate the service template
458 * @param nodeTemplateId the node template id
460 public String getUnifiedSubstitutionNodeTemplateId(ServiceTemplate serviceTemplate,
461 String nodeTemplateId) {
462 UnifiedSubstitutionData unifiedSubstitutionData =
463 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
464 return unifiedSubstitutionData.getNodesRelatedSubstitutionServiceTemplateNode()
465 .get(nodeTemplateId);
468 public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
469 String computeType) {
470 return this.unifiedSubstitutionData.get(serviceTemplateName)
471 .getHandledNestedComputeNodeTemplateIndex(computeType);
474 public void updateHandledComputeType(String serviceTemplateName,
475 String handledComputeType,
476 String nestedServiceTemplateFileName) {
477 String globalSTName =
478 ToscaUtil.getServiceTemplateFileName(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
479 this.unifiedSubstitutionData.putIfAbsent(
480 globalSTName, new UnifiedSubstitutionData());
481 this.unifiedSubstitutionData.get(globalSTName)
482 .addHandledComputeType(handledComputeType);
483 this.unifiedSubstitutionData.get(globalSTName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
485 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
486 this.unifiedSubstitutionData.get(serviceTemplateName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
489 public void addHandledComputeTypeInServiceTemplate(String serviceTemplateName,
490 String handledComputeType){
491 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
492 this.unifiedSubstitutionData.get(serviceTemplateName).addHandledComputeType(handledComputeType);
495 public boolean isComputeTypeHandledInServiceTemplate(String serviceTemplateName,
496 String computeType) {
497 return !Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))
498 && this.unifiedSubstitutionData.get(serviceTemplateName)
499 .isComputeTypeHandledInServiceTemplate(computeType);
502 public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
503 String nestedServiceTemplateName,
505 return this.unifiedSubstitutionData.get(serviceTemplateName)
506 .getHandledNestedComputeNodeTemplateIndex(computeType);
509 public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName,
510 String nestedServiceTemplateFileName) {
511 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
514 return this.unifiedSubstitutionData.get(serviceTemplateName)
515 .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName);
518 public Set<String> getAllRelatedNestedNodeTypeIds(){
519 String globalName = "GlobalSubstitutionTypes";
520 if(Objects.isNull(this.unifiedSubstitutionData) ||
521 Objects.isNull(this.unifiedSubstitutionData.get(globalName))){
522 return new HashSet<>();
525 return this.unifiedSubstitutionData.get(globalName).getAllRelatedNestedNodeTypeIds();
528 public boolean isUnifiedHandledServiceTemplate(ServiceTemplate serviceTemplate) {
529 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
530 if (unifiedHandledServiceTemplates.contains(serviceTemplateFileName)) {
538 public void addUnifiedHandledServiceTeamplte(ServiceTemplate serviceTemplate) {
539 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
540 this.unifiedHandledServiceTemplates.add(serviceTemplateFileName);
543 public boolean isNestedNodeWasHandled(String serviceTemplateName,
544 String nestedNodeTemplateId) {
545 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
548 return this.unifiedSubstitutionData.get(serviceTemplateName)
549 .isNestedNodeWasHandled(nestedNodeTemplateId);
552 public void addNestedNodeAsHandled(String serviceTemplateName,
553 String nestedNodeTemplateId) {
554 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
555 this.unifiedSubstitutionData.get(serviceTemplateName)
556 .addHandledNestedNodes(nestedNodeTemplateId);
559 public void updateUsedTimesForNestedComputeNodeType(String serviceTemplateName,
560 String computeType) {
561 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
563 this.unifiedSubstitutionData.get(serviceTemplateName)
564 .updateUsedTimesForNestedComputeNodeType(computeType);
567 public int getGlobalNodeTypeIndex(String serviceTemplateName,
568 String computeType) {
569 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
572 return this.unifiedSubstitutionData.get(serviceTemplateName).getGlobalNodeTypeIndex
576 public void addNewPropertyIdToNodeTemplate(String serviceTemplateName,
577 String newPropertyId,
578 Object origPropertyValue){
579 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
580 this.unifiedSubstitutionData.get(serviceTemplateName).addNewPropertyIdToNodeTemplate(
581 newPropertyId, origPropertyValue);
584 public Optional<Object> getNewPropertyInputParamId(String serviceTemplateName,
585 String newPropertyId){
586 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
587 return Optional.empty();
590 return this.unifiedSubstitutionData.get(serviceTemplateName).getNewPropertyInputParam
594 public Map<String, Object> getAllNewPropertyInputParamIdsPerNodeTenplateId(String serviceTemplateName){
595 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
596 return new HashMap<>();
599 return this.unifiedSubstitutionData.get(serviceTemplateName).getAllNewPropertyInputParamIds();
603 public boolean isServiceTemplateWithoutNodeTemplatesSection(String serviceTemplateName){
604 return Objects.nonNull(serviceTemplateName)
605 && serviceTemplatesWithoutNodeTemplateSection.contains(serviceTemplateName);
608 public void addServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
609 this.serviceTemplatesWithoutNodeTemplateSection.add(serviceTemplateName);
612 public void addNestedNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
613 this.nodeTemplateIdsPointingToStWithoutNodeTemplates.add(nodeTemplateId);
616 public boolean isNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
617 return Objects.nonNull(nodeTemplateId)
618 && nodeTemplateIdsPointingToStWithoutNodeTemplates.contains(nodeTemplateId);
621 public void updateRequirementAssignmentIdIndex(String serviceTemplateName,
622 String nodeTemplateId,
623 String requirementId){
624 requirementIdAppearanceInNodeTemplate.putIfAbsent(serviceTemplateName, new HashMap<>());
625 requirementIdAppearanceInNodeTemplate
626 .get(serviceTemplateName).putIfAbsent(nodeTemplateId, new HashMap<>());
628 Map<String, Integer> requirementIdToAppearance =
629 requirementIdAppearanceInNodeTemplate.get(serviceTemplateName).get(nodeTemplateId);
631 if(requirementIdToAppearance.containsKey(requirementId)){
632 requirementIdToAppearance
633 .put(requirementId, requirementIdToAppearance.get(requirementId) + 1);
635 requirementIdToAppearance.put(requirementId, 0);