f5ad2a1d3cea8a6c1aade8091224de7606909685
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.translator.datatypes.heattotosca;
22
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.errors.ErrorCode;
29 import org.openecomp.sdc.common.utils.SdcCommon;
30 import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
31 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
32 import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
33 import org.openecomp.sdc.heat.datatypes.model.Resource;
34 import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
35 import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
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.globaltypes.GlobalTypesGenerator;
46
47 import java.io.InputStream;
48 import java.util.HashMap;
49 import java.util.HashSet;
50 import java.util.List;
51 import java.util.Map;
52 import java.util.Objects;
53 import java.util.Optional;
54 import java.util.Set;
55
56
57 public class TranslationContext {
58
59
60   private static Map<String, Map<String, Map<String, String>>> translationMapping;
61   private static Map<String, ServiceTemplate> globalServiceTemplates;
62   private static Map<String, ImplementationConfiguration> nameExtractorImplMap;
63   private static Map<String, ImplementationConfiguration> supportedConsolidationComputeResources;
64   private static Map<String, ImplementationConfiguration> supportedConsolidationPortResources;
65   private static List enrichPortResourceProperties;
66
67   static {
68     Configuration config = ConfigurationManager.lookup();
69     String propertyFileName = SdcCommon.HEAT_TO_TOSCA_MAPPING_CONF;
70     translationMapping =
71         config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY);
72     try {
73       globalServiceTemplates = GlobalTypesGenerator.getGlobalTypesServiceTemplate();
74     } catch (Exception exc) {
75       throw new RuntimeException("Failed to load GlobalTypes", exc);
76     }
77     nameExtractorImplMap = config.populateMap(ConfigConstants.TRANSLATOR_NAMESPACE,
78         ConfigConstants.NAMING_CONVENTION_EXTRACTOR_IMPL_KEY, ImplementationConfiguration.class);
79     supportedConsolidationComputeResources = config.populateMap(ConfigConstants
80         .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
81         .SUPPORTED_CONSOLIDATION_COMPUTE_RESOURCES_KEY, ImplementationConfiguration.class);
82     supportedConsolidationPortResources = config.populateMap(ConfigConstants
83         .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
84         .SUPPORTED_CONSOLIDATION_PORT_RESOURCES_KEY, ImplementationConfiguration.class);
85     enrichPortResourceProperties = config.getAsStringValues(ConfigConstants
86         .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
87         .ENRICH_PORT_RESOURCE_PROP);
88
89   }
90
91   private ManifestFile manifest;
92
93   public static List getEnrichPortResourceProperties() {
94     return enrichPortResourceProperties;
95   }
96
97   private FileContentHandler files = new FileContentHandler();
98   private Map<String, FileData.Type> manifestFiles = new HashMap<>();
99   //Key - file name, value - file type
100   private Set<String> nestedHeatsFiles = new HashSet<>();
101   private FileContentHandler externalArtifacts = new FileContentHandler();
102   // Key - heat file name,value - set of heat resource ids which were translated
103   private Map<String, Set<String>> translatedResources = new HashMap<>();
104   // Key - heat file name, value - translated Node template id
105   private Map<String, Set<String>> heatStackGroupMembers = new HashMap<>();
106   // Key - heat file name, value - Map with Key - heat resource Id, Value - tosca entity template id
107   private Map<String, Map<String, String>> translatedIds = new HashMap<>();
108   // key - service template type, value - translated service templates
109   private Map<String, ServiceTemplate> translatedServiceTemplates = new HashMap<>();
110   //key - heat param name, value - shared resource data
111   private Map<String, TranslatedHeatResource> heatSharedResourcesByParam = new HashMap<>();
112   //key - translated substitute service template file name, value - source nested heat file name
113   private Map<String, String> nestedHeatFileName = new HashMap<>();
114   //Key - heat file name,value - Map eith key - heat pseudo param name,
115   // value - translated tosca parameter name
116   private Map<String, Map<String, String>> usedHeatPseudoParams = new HashMap<>();
117   //Consolidation data gathered for Unified TOSCA model
118   private ConsolidationData consolidationData = new ConsolidationData();
119   private Map<String, UnifiedSubstitutionData> unifiedSubstitutionData = new HashMap<>();
120   private Set<String> unifiedHandledServiceTemplates = new HashSet<>();
121
122   private Map<String, Map<String, Map<String, Integer>>>
123       requirementIdAppearanceInNodeTemplate = new HashMap<>();
124
125   private Set<String> serviceTemplatesWithoutNodeTemplateSection = new HashSet<>();
126
127   public static Map<String, ImplementationConfiguration>
128   getSupportedConsolidationComputeResources() {
129     return supportedConsolidationComputeResources;
130   }
131
132   public static void setSupportedConsolidationComputeResources(
133       Map<String, ImplementationConfiguration> supportedConsolidationComputeResources) {
134     TranslationContext.supportedConsolidationComputeResources =
135         supportedConsolidationComputeResources;
136   }
137
138   public static Map<String, ImplementationConfiguration> getSupportedConsolidationPortResources() {
139     return supportedConsolidationPortResources;
140   }
141
142   public static void setSupportedConsolidationPortResources(
143       Map<String, ImplementationConfiguration> supportedConsolidationPortResources) {
144     TranslationContext.supportedConsolidationPortResources = supportedConsolidationPortResources;
145   }
146
147   /**
148    * Get nameExtractor implemetation class instance.
149    *
150    * @param extractorImplKey configuration key for the implementation class
151    * @return implemetation class instance
152    */
153   public static NameExtractor getNameExtractorImpl(String extractorImplKey) {
154     String nameExtractorImplClassName =
155         nameExtractorImplMap.get(extractorImplKey).getImplementationClass();
156
157     return CommonMethods.newInstance(nameExtractorImplClassName, NameExtractor.class);
158   }
159
160   public Map<String, UnifiedSubstitutionData> getUnifiedSubstitutionData() {
161     return unifiedSubstitutionData;
162   }
163
164   public void setUnifiedSubstitutionData(
165       Map<String, UnifiedSubstitutionData> unifiedSubstitutionData) {
166     this.unifiedSubstitutionData = unifiedSubstitutionData;
167   }
168
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);
177   }
178
179   public NodeTemplate getCleanedNodeTemplate(String serviceTemplateName,
180                                              String nodeTemplateId) {
181     return this.unifiedSubstitutionData.get(serviceTemplateName)
182         .getCleanedNodeTemplate(nodeTemplateId);
183   }
184
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);
191   }
192
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);
198   }
199
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);
206   }
207
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);
213   }
214
215   public ConsolidationData getConsolidationData() {
216     return consolidationData;
217   }
218
219   public void setConsolidationData(ConsolidationData consolidationData) {
220     this.consolidationData = consolidationData;
221   }
222
223   public void addManifestFile(String fileName, FileData.Type fileType) {
224     this.manifestFiles.put(fileName, fileType);
225   }
226
227   public Set<String> getNestedHeatsFiles() {
228     return nestedHeatsFiles;
229   }
230
231   public Map<String, Set<String>> getHeatStackGroupMembers() {
232     return heatStackGroupMembers;
233   }
234
235   public FileContentHandler getFiles() {
236     return files;
237   }
238
239   public void setFiles(Map<String, byte[]> files) {
240     this.files.putAll(files);
241   }
242
243   public InputStream getFileContent(String fileName) {
244     return files.getFileContent(fileName);
245   }
246
247   public void addFile(String name, byte[] content) {
248     files.addFile(name, content);
249   }
250
251   public ManifestFile getManifest() {
252     return manifest;
253   }
254
255   public void setManifest(ManifestFile manifest) {
256     this.manifest = manifest;
257   }
258
259   public Map<String, Set<String>> getTranslatedResources() {
260     return translatedResources;
261   }
262
263   public Map<String, Map<String, String>> getTranslatedIds() {
264     return translatedIds;
265   }
266
267   public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String
268                                                                         nestedHeatFileNameToSkip){
269     Set<String> allTranslatedResourceIds = new HashSet<>();
270
271     this.translatedIds.entrySet().stream().filter(
272         heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey()
273             .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> {
274       allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet());
275     });
276
277     return allTranslatedResourceIds;
278   }
279
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))) {
286       return null;
287     }
288     if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
289       return null;
290     }
291     return translationMapping.get(resourceType).get(elementType).get(elementName);
292   }
293
294   public Map<String, String> getElementMapping(String resourceType, String elementType) {
295     if (Objects.isNull(translationMapping.get(resourceType))) {
296       return null;
297     }
298     return translationMapping.get(resourceType).get(elementType);
299   }
300
301   public Set<String> getElementSet(String resourceType, String elementType) {
302     if (Objects.isNull(translationMapping.get(resourceType))) {
303       return new HashSet<>();
304     }
305     if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
306       return new HashSet<>();
307     }
308     return translationMapping.get(resourceType).get(elementType).keySet();
309   }
310
311   public Map<String, ServiceTemplate> getTranslatedServiceTemplates() {
312     return translatedServiceTemplates;
313   }
314
315   public ServiceTemplate getGlobalSubstitutionServiceTemplate() {
316     return getTranslatedServiceTemplates().get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
317   }
318
319   public FileContentHandler getExternalArtifacts() {
320     return externalArtifacts;
321   }
322
323   public void addExternalArtifacts(String name, byte[] content) {
324     this.externalArtifacts.addFile(name, content);
325   }
326
327   public Map<String, TranslatedHeatResource> getHeatSharedResourcesByParam() {
328     return heatSharedResourcesByParam;
329   }
330
331   public void addHeatSharedResourcesByParam(String parameterName, String resourceId,
332                                             Resource resource) {
333     this.addHeatSharedResourcesByParam(parameterName,
334         new TranslatedHeatResource(resourceId, resource));
335   }
336
337   private void addHeatSharedResourcesByParam(String parameterName,
338                                              TranslatedHeatResource translatedHeatResource) {
339     this.heatSharedResourcesByParam.put(parameterName, translatedHeatResource);
340   }
341
342   public Map<String, ServiceTemplate> getGlobalServiceTemplates() {
343     return globalServiceTemplates;
344   }
345
346   public Map<String, String> getNestedHeatFileName() {
347     return nestedHeatFileName;
348   }
349
350   public void addNestedHeatFileName(String substituteServiceTempalteName,
351                                     String nestedHeatFileName) {
352     this.nestedHeatFileName.put(substituteServiceTempalteName, nestedHeatFileName);
353   }
354
355   public Map<String, Map<String, String>> getUsedHeatPseudoParams() {
356     return usedHeatPseudoParams;
357   }
358
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<>());
363     }
364     this.usedHeatPseudoParams.get(heatFileName).put(heatPseudoParam, translatedToscaParam);
365   }
366
367   /**
368    * Add the unified substitution data info in context. Contains a mapping of original node
369    * template id and the new node template id in the abstract substitute
370    *
371    * @param serviceTemplateFileName the service template file name
372    * @param originalNodeTemplateId  the original node template id
373    * @param abstractNodeTemplateId  the node template id in the abstract substitute
374    */
375   public void addUnifiedSubstitutionData(String serviceTemplateFileName,
376                                          String originalNodeTemplateId,
377                                          String abstractNodeTemplateId) {
378
379     Map<String, String> nodeAbstractNodeTemplateIdMap = this.getUnifiedSubstitutionData()
380         .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
381         .getNodesRelatedAbstractNode();
382
383     if (nodeAbstractNodeTemplateIdMap == null) {
384       nodeAbstractNodeTemplateIdMap = new HashMap<>();
385     }
386
387     if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
388       throw new CoreException((new ErrorCode.ErrorCodeBuilder())
389           .withMessage("Resource with id "
390               + originalNodeTemplateId + " occures more than once in different addOn files")
391           .build());
392     }
393     nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
394     this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
395         nodeAbstractNodeTemplateIdMap);
396   }
397
398   /**
399    * Add the unified substitution data info in context. Contains a mapping of original node
400    * template id and the new node template id in the abstract substitute
401    *
402    * @param serviceTemplateFileName                   the service template file name
403    * @param originalNodeTemplateId                    the original node template id
404    * @param substitutionServiceTemplateNodeTemplateId the node template id in the substitution
405    *                                                  service template
406    */
407   public void addSubstitutionServiceTemplateUnifiedSubstitutionData(
408       String serviceTemplateFileName,
409       String originalNodeTemplateId,
410       String substitutionServiceTemplateNodeTemplateId) {
411
412     Map<String, String> nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = this
413         .getUnifiedSubstitutionData()
414         .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
415         .getNodesRelatedSubstitutionServiceTemplateNode();
416
417     if (nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap == null) {
418       nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = new HashMap<>();
419     }
420     nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap.put(originalNodeTemplateId,
421         substitutionServiceTemplateNodeTemplateId);
422     this.getUnifiedSubstitutionData().get(serviceTemplateFileName)
423         .setNodesRelatedSubstitutionServiceTemplateNode(
424             nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap);
425   }
426
427   /**
428    * Get unified abstract node template which is mapped to the input node template id.
429    *
430    * @param serviceTemplate the service template
431    * @param nodeTemplateId  the node template id
432    */
433   public String getUnifiedAbstractNodeTemplateId(ServiceTemplate serviceTemplate,
434                                                  String nodeTemplateId) {
435     UnifiedSubstitutionData unifiedSubstitutionData =
436         this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
437     return unifiedSubstitutionData.getNodesRelatedAbstractNode().get(nodeTemplateId);
438   }
439
440   /**
441    * Get unified node template in the substitution service template which is mapped to the
442    * original input node template id.
443    *
444    * @param serviceTemplate the service template
445    * @param nodeTemplateId  the node template id
446    */
447   public String getUnifiedSubstitutionNodeTemplateId(ServiceTemplate serviceTemplate,
448                                                      String nodeTemplateId) {
449     UnifiedSubstitutionData unifiedSubstitutionData =
450         this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
451     return unifiedSubstitutionData.getNodesRelatedSubstitutionServiceTemplateNode()
452         .get(nodeTemplateId);
453   }
454
455   public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
456                                                       String computeType) {
457     return this.unifiedSubstitutionData.get(serviceTemplateName)
458         .getHandledNestedComputeNodeTemplateIndex(computeType);
459   }
460
461   public void updateHandledComputeType(String serviceTemplateName,
462                                        String handledComputeType,
463                                        String nestedServiceTemplateFileName) {
464     String globalSTName =
465         ToscaUtil.getServiceTemplateFileName(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
466     this.unifiedSubstitutionData.putIfAbsent(
467         globalSTName, new UnifiedSubstitutionData());
468     this.unifiedSubstitutionData.get(globalSTName)
469         .addHandledComputeType(handledComputeType);
470     this.unifiedSubstitutionData.get(globalSTName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
471
472     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
473     this.unifiedSubstitutionData.get(serviceTemplateName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
474   }
475
476   public void addHandledComputeTypeInServiceTemplate(String serviceTemplateName,
477                                                      String handledComputeType){
478     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
479     this.unifiedSubstitutionData.get(serviceTemplateName).addHandledComputeType(handledComputeType);
480   }
481
482   public boolean isComputeTypeHandledInServiceTemplate(String serviceTemplateName,
483                                                        String computeType) {
484     return !Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))
485         && this.unifiedSubstitutionData.get(serviceTemplateName)
486         .isComputeTypeHandledInServiceTemplate(computeType);
487   }
488
489   public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
490                                                       String nestedServiceTemplateName,
491                                                       String computeType){
492     return this.unifiedSubstitutionData.get(serviceTemplateName)
493         .getHandledNestedComputeNodeTemplateIndex(computeType);
494   }
495
496   public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName,
497                                                    String nestedServiceTemplateFileName) {
498     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
499       return false;
500     }
501     return this.unifiedSubstitutionData.get(serviceTemplateName)
502         .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName);
503   }
504
505   public Set<String> getAllRelatedNestedNodeTypeIds(){
506     String globalName = "GlobalSubstitutionTypes";
507     if(Objects.isNull(this.unifiedSubstitutionData) ||
508         Objects.isNull(this.unifiedSubstitutionData.get(globalName))){
509       return new HashSet<>();
510     }
511
512     return this.unifiedSubstitutionData.get(globalName).getAllRelatedNestedNodeTypeIds();
513   }
514
515   public boolean isUnifiedHandledServiceTemplate(ServiceTemplate serviceTemplate) {
516     String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
517     if (unifiedHandledServiceTemplates.contains(serviceTemplateFileName)) {
518       return true;
519     }
520     return false;
521   }
522
523
524
525   public void addUnifiedHandledServiceTeamplte(ServiceTemplate serviceTemplate) {
526     String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
527     this.unifiedHandledServiceTemplates.add(serviceTemplateFileName);
528   }
529
530   public boolean isNestedNodeWasHandled(String serviceTemplateName,
531                                         String nestedNodeTemplateId) {
532     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
533       return false;
534     }
535     return this.unifiedSubstitutionData.get(serviceTemplateName)
536         .isNestedNodeWasHandled(nestedNodeTemplateId);
537   }
538
539   public void addNestedNodeAsHandled(String serviceTemplateName,
540                                      String nestedNodeTemplateId) {
541     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
542     this.unifiedSubstitutionData.get(serviceTemplateName)
543         .addHandledNestedNodes(nestedNodeTemplateId);
544   }
545
546   public void updateUsedTimesForNestedComputeNodeType(String serviceTemplateName,
547                                                       String computeType) {
548     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
549
550     this.unifiedSubstitutionData.get(serviceTemplateName)
551         .updateUsedTimesForNestedComputeNodeType(computeType);
552   }
553
554   public int getGlobalNodeTypeIndex(String serviceTemplateName,
555                                     String computeType) {
556     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
557       return 0;
558     }
559     return this.unifiedSubstitutionData.get(serviceTemplateName).getGlobalNodeTypeIndex
560         (computeType);
561   }
562
563   public void addNewPropertyIdToNodeTemplate(String serviceTemplateName,
564                                              String newPropertyId,
565                                              Object origPropertyValue){
566     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
567     this.unifiedSubstitutionData.get(serviceTemplateName).addNewPropertyIdToNodeTemplate(
568         newPropertyId, origPropertyValue);
569   }
570
571   public Optional<Object> getNewPropertyInputParamId(String serviceTemplateName,
572                                                      String newPropertyId){
573     if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
574       return Optional.empty();
575     }
576
577     return this.unifiedSubstitutionData.get(serviceTemplateName).getNewPropertyInputParam
578         (newPropertyId);
579   }
580
581   public Map<String, Object> getAllNewPropertyInputParamIdsPerNodeTenplateId(String serviceTemplateName){
582     if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
583       return new HashMap<>();
584     }
585
586     return this.unifiedSubstitutionData.get(serviceTemplateName).getAllNewPropertyInputParamIds();
587
588   }
589
590   public void addServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
591     this.serviceTemplatesWithoutNodeTemplateSection.add(serviceTemplateName);
592   }
593
594   public boolean isServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
595     return !Objects.isNull(serviceTemplateName) &&
596         this.serviceTemplatesWithoutNodeTemplateSection.contains(serviceTemplateName);
597   }
598
599   public void updateRequirementAssignmentIdIndex(String serviceTemplateName,
600                                                  String nodeTemplateId,
601                                                  String requirementId){
602     requirementIdAppearanceInNodeTemplate.putIfAbsent(serviceTemplateName, new HashMap<>());
603     requirementIdAppearanceInNodeTemplate
604         .get(serviceTemplateName).putIfAbsent(nodeTemplateId, new HashMap<>());
605
606     Map<String, Integer> requirementIdToAppearance =
607         requirementIdAppearanceInNodeTemplate.get(serviceTemplateName).get(nodeTemplateId);
608
609     if(requirementIdToAppearance.containsKey(requirementId)){
610       requirementIdToAppearance
611           .put(requirementId, requirementIdToAppearance.get(requirementId) + 1);
612     } else {
613       requirementIdToAppearance.put(requirementId, 0);
614     }
615   }
616
617 }