c03ca56d4994e233ffb06882a578409c4068dc7b
[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<RequirementAssignment, String>>
123           mapDependencySubMappingToRequirementAssignment = new HashMap<>();
124
125   public static Map<String, ImplementationConfiguration>
126   getSupportedConsolidationComputeResources() {
127     return supportedConsolidationComputeResources;
128   }
129
130   public static void setSupportedConsolidationComputeResources(
131           Map<String, ImplementationConfiguration> supportedConsolidationComputeResources) {
132     TranslationContext.supportedConsolidationComputeResources =
133             supportedConsolidationComputeResources;
134   }
135
136   public static Map<String, ImplementationConfiguration> getSupportedConsolidationPortResources() {
137     return supportedConsolidationPortResources;
138   }
139
140   public static void setSupportedConsolidationPortResources(
141           Map<String, ImplementationConfiguration> supportedConsolidationPortResources) {
142     TranslationContext.supportedConsolidationPortResources = supportedConsolidationPortResources;
143   }
144
145   /**
146    * Get nameExtractor implemetation class instance.
147    *
148    * @param extractorImplKey configuration key for the implementation class
149    * @return implemetation class instance
150    */
151   public static NameExtractor getNameExtractorImpl(String extractorImplKey) {
152     String nameExtractorImplClassName =
153             nameExtractorImplMap.get(extractorImplKey).getImplementationClass();
154
155     return CommonMethods.newInstance(nameExtractorImplClassName, NameExtractor.class);
156   }
157
158   public Map<String, UnifiedSubstitutionData> getUnifiedSubstitutionData() {
159     return unifiedSubstitutionData;
160   }
161
162   public void setUnifiedSubstitutionData(
163           Map<String, UnifiedSubstitutionData> unifiedSubstitutionData) {
164     this.unifiedSubstitutionData = unifiedSubstitutionData;
165   }
166
167   public void addCleanedNodeTemplate(String serviceTemplateName,
168                                      String nodeTemplateId,
169                                      UnifiedCompositionEntity unifiedCompositionEntity,
170                                      NodeTemplate nodeTemplate) {
171     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
172     this.unifiedSubstitutionData
173             .get(serviceTemplateName)
174             .addCleanedNodeTemplate(nodeTemplateId, unifiedCompositionEntity, nodeTemplate);
175   }
176
177   public NodeTemplate getCleanedNodeTemplate(String serviceTemplateName,
178                                              String nodeTemplateId) {
179     return this.unifiedSubstitutionData.get(serviceTemplateName)
180             .getCleanedNodeTemplate(nodeTemplateId);
181   }
182
183   public void addUnifiedNestedNodeTemplateId(String serviceTemplateName,
184                                              String nestedNodeTemplateId,
185                                              String unifiedNestedNodeTemplateId) {
186     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
187     this.unifiedSubstitutionData.get(serviceTemplateName)
188             .addUnifiedNestedNodeTemplateId(nestedNodeTemplateId, unifiedNestedNodeTemplateId);
189   }
190
191   public Optional<String> getUnifiedNestedNodeTemplateId(String serviceTemplateName,
192                                                          String nestedNodeTemplateId) {
193     return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
194             : this.unifiedSubstitutionData.get(serviceTemplateName)
195             .getUnifiedNestedNodeTemplateId(nestedNodeTemplateId);
196   }
197
198   public void addUnifiedNestedNodeTypeId(String serviceTemplateName,
199                                          String nestedNodeTypeId,
200                                          String unifiedNestedNodeTypeId) {
201     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
202     this.unifiedSubstitutionData.get(serviceTemplateName)
203             .addUnifiedNestedNodeTypeId(nestedNodeTypeId, unifiedNestedNodeTypeId);
204   }
205
206   public Optional<String> getUnifiedNestedNodeTypeId(String serviceTemplateName,
207                                                      String nestedNodeTemplateId) {
208     return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
209             : this.unifiedSubstitutionData.get(serviceTemplateName)
210             .getUnifiedNestedNodeTypeId(nestedNodeTemplateId);
211   }
212
213   public ConsolidationData getConsolidationData() {
214     return consolidationData;
215   }
216
217   public void setConsolidationData(ConsolidationData consolidationData) {
218     this.consolidationData = consolidationData;
219   }
220
221   public void addManifestFile(String fileName, FileData.Type fileType) {
222     this.manifestFiles.put(fileName, fileType);
223   }
224
225   public Set<String> getNestedHeatsFiles() {
226     return nestedHeatsFiles;
227   }
228
229   public Map<String, Set<String>> getHeatStackGroupMembers() {
230     return heatStackGroupMembers;
231   }
232
233   public FileContentHandler getFiles() {
234     return files;
235   }
236
237   public void setFiles(Map<String, byte[]> files) {
238     this.files.putAll(files);
239   }
240
241   public InputStream getFileContent(String fileName) {
242     return files.getFileContent(fileName);
243   }
244
245   public void addFile(String name, byte[] content) {
246     files.addFile(name, content);
247   }
248
249   public ManifestFile getManifest() {
250     return manifest;
251   }
252
253   public void setManifest(ManifestFile manifest) {
254     this.manifest = manifest;
255   }
256
257   public Map<String, Set<String>> getTranslatedResources() {
258     return translatedResources;
259   }
260
261   public Map<String, Map<String, String>> getTranslatedIds() {
262     return translatedIds;
263   }
264
265   public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String
266                                                                             nestedHeatFileNameToSkip){
267     Set<String> allTranslatedResourceIds = new HashSet<>();
268
269     this.translatedIds.entrySet().stream().filter(
270             heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey()
271                     .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> {
272       allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet());
273     });
274
275     return allTranslatedResourceIds;
276   }
277
278   // get tosca name from mapping configuration file
279   //element type - parameter/attribute
280   // element name - heat parameter/attribute name
281   //return value - tosca parameter/attribute name
282   public String getElementMapping(String resourceType, String elementType, String elementName) {
283     if (Objects.isNull(translationMapping.get(resourceType))) {
284       return null;
285     }
286     if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
287       return null;
288     }
289     return translationMapping.get(resourceType).get(elementType).get(elementName);
290   }
291
292   public Map<String, String> getElementMapping(String resourceType, String elementType) {
293     if (Objects.isNull(translationMapping.get(resourceType))) {
294       return null;
295     }
296     return translationMapping.get(resourceType).get(elementType);
297   }
298
299   public Set<String> getElementSet(String resourceType, String elementType) {
300     if (Objects.isNull(translationMapping.get(resourceType))) {
301       return new HashSet<>();
302     }
303     if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
304       return new HashSet<>();
305     }
306     return translationMapping.get(resourceType).get(elementType).keySet();
307   }
308
309   public Map<String, ServiceTemplate> getTranslatedServiceTemplates() {
310     return translatedServiceTemplates;
311   }
312
313   public ServiceTemplate getGlobalSubstitutionServiceTemplate() {
314     return getTranslatedServiceTemplates().get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
315   }
316
317   public FileContentHandler getExternalArtifacts() {
318     return externalArtifacts;
319   }
320
321   public void addExternalArtifacts(String name, byte[] content) {
322     this.externalArtifacts.addFile(name, content);
323   }
324
325   public Map<String, TranslatedHeatResource> getHeatSharedResourcesByParam() {
326     return heatSharedResourcesByParam;
327   }
328
329   public void addHeatSharedResourcesByParam(String parameterName, String resourceId,
330                                             Resource resource) {
331     this.addHeatSharedResourcesByParam(parameterName,
332             new TranslatedHeatResource(resourceId, resource));
333   }
334
335   private void addHeatSharedResourcesByParam(String parameterName,
336                                              TranslatedHeatResource translatedHeatResource) {
337     this.heatSharedResourcesByParam.put(parameterName, translatedHeatResource);
338   }
339
340   public Map<String, ServiceTemplate> getGlobalServiceTemplates() {
341     return globalServiceTemplates;
342   }
343
344   public Map<String, String> getNestedHeatFileName() {
345     return nestedHeatFileName;
346   }
347
348   public void addNestedHeatFileName(String substituteServiceTempalteName,
349                                     String nestedHeatFileName) {
350     this.nestedHeatFileName.put(substituteServiceTempalteName, nestedHeatFileName);
351   }
352
353   public Map<String, Map<String, String>> getUsedHeatPseudoParams() {
354     return usedHeatPseudoParams;
355   }
356
357   public void addUsedHeatPseudoParams(String heatFileName, String heatPseudoParam, String
358           translatedToscaParam) {
359     if (Objects.isNull(this.usedHeatPseudoParams.get(heatFileName))) {
360       this.usedHeatPseudoParams.put(heatFileName, new HashMap<>());
361     }
362     this.usedHeatPseudoParams.get(heatFileName).put(heatPseudoParam, translatedToscaParam);
363   }
364
365   /**
366    * Add the unified substitution data info in context. Contains a mapping of original node
367    * template id and the new node template id in the abstract substitute
368    *
369    * @param serviceTemplateFileName the service template file name
370    * @param originalNodeTemplateId  the original node template id
371    * @param abstractNodeTemplateId  the node template id in the abstract substitute
372    */
373   public void addUnifiedSubstitutionData(String serviceTemplateFileName,
374                                          String originalNodeTemplateId,
375                                          String abstractNodeTemplateId) {
376
377     Map<String, String> nodeAbstractNodeTemplateIdMap = this.getUnifiedSubstitutionData()
378             .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
379             .getNodesRelatedAbstractNode();
380
381     if (nodeAbstractNodeTemplateIdMap == null) {
382       nodeAbstractNodeTemplateIdMap = new HashMap<>();
383     }
384
385     if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
386       throw new CoreException((new ErrorCode.ErrorCodeBuilder())
387               .withMessage("Resource with id "
388                       + originalNodeTemplateId + " occures more than once in different addOn files")
389               .build());
390     }
391     nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
392     this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
393             nodeAbstractNodeTemplateIdMap);
394   }
395
396   /**
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
399    *
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
403    *                                                  service template
404    */
405   public void addSubstitutionServiceTemplateUnifiedSubstitutionData(
406           String serviceTemplateFileName,
407           String originalNodeTemplateId,
408           String substitutionServiceTemplateNodeTemplateId) {
409
410     Map<String, String> nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = this
411             .getUnifiedSubstitutionData()
412             .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
413             .getNodesRelatedSubstitutionServiceTemplateNode();
414
415     if (nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap == null) {
416       nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = new HashMap<>();
417     }
418     nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap.put(originalNodeTemplateId,
419             substitutionServiceTemplateNodeTemplateId);
420     this.getUnifiedSubstitutionData().get(serviceTemplateFileName)
421             .setNodesRelatedSubstitutionServiceTemplateNode(
422                     nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap);
423   }
424
425   /**
426    * Get unified abstract node template which is mapped to the input node template id.
427    *
428    * @param serviceTemplate the service template
429    * @param nodeTemplateId  the node template id
430    */
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);
436   }
437
438   /**
439    * Get unified node template in the substitution service template which is mapped to the
440    * original input node template id.
441    *
442    * @param serviceTemplate the service template
443    * @param nodeTemplateId  the node template id
444    */
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);
451   }
452
453   public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
454                                                       String computeType) {
455     return this.unifiedSubstitutionData.get(serviceTemplateName)
456             .getHandledNestedComputeNodeTemplateIndex(computeType);
457   }
458
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);
469
470     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
471     this.unifiedSubstitutionData.get(serviceTemplateName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
472   }
473
474   public void addHandledComputeTypeInServiceTemplate(String serviceTemplateName,
475                                                      String handledComputeType){
476     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
477     this.unifiedSubstitutionData.get(serviceTemplateName).addHandledComputeType(handledComputeType);
478   }
479
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);
485   }
486
487   public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
488                                                       String nestedServiceTemplateName,
489                                                       String computeType){
490     return this.unifiedSubstitutionData.get(serviceTemplateName)
491             .getHandledNestedComputeNodeTemplateIndex(computeType);
492   }
493
494   public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName,
495                                                    String nestedServiceTemplateFileName) {
496     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
497       return false;
498     }
499     return this.unifiedSubstitutionData.get(serviceTemplateName)
500             .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName);
501   }
502
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<>();
508     }
509
510     return this.unifiedSubstitutionData.get(globalName).getAllRelatedNestedNodeTypeIds();
511   }
512
513   public boolean isUnifiedHandledServiceTemplate(ServiceTemplate serviceTemplate) {
514     String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
515     if (unifiedHandledServiceTemplates.contains(serviceTemplateFileName)) {
516       return true;
517     }
518     return false;
519   }
520
521
522
523   public void addUnifiedHandledServiceTeamplte(ServiceTemplate serviceTemplate) {
524     String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
525     this.unifiedHandledServiceTemplates.add(serviceTemplateFileName);
526   }
527
528   public boolean isNestedNodeWasHandled(String serviceTemplateName,
529                                         String nestedNodeTemplateId) {
530     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
531       return false;
532     }
533     return this.unifiedSubstitutionData.get(serviceTemplateName)
534             .isNestedNodeWasHandled(nestedNodeTemplateId);
535   }
536
537   public void addNestedNodeAsHandled(String serviceTemplateName,
538                                      String nestedNodeTemplateId) {
539     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
540     this.unifiedSubstitutionData.get(serviceTemplateName)
541             .addHandledNestedNodes(nestedNodeTemplateId);
542   }
543
544   public void updateUsedTimesForNestedComputeNodeType(String serviceTemplateName,
545                                                       String computeType) {
546     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
547
548     this.unifiedSubstitutionData.get(serviceTemplateName)
549             .updateUsedTimesForNestedComputeNodeType(computeType);
550   }
551
552   public int getGlobalNodeTypeIndex(String serviceTemplateName,
553                                     String computeType) {
554     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
555       return 0;
556     }
557     return this.unifiedSubstitutionData.get(serviceTemplateName).getGlobalNodeTypeIndex
558             (computeType);
559   }
560
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);
567   }
568
569   public Optional<Object> getNewPropertyInputParamId(String serviceTemplateName,
570                                                      String newPropertyId){
571     if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
572       return Optional.empty();
573     }
574
575     return this.unifiedSubstitutionData.get(serviceTemplateName).getNewPropertyInputParam
576             (newPropertyId);
577   }
578
579   public Map<String, Object> getAllNewPropertyInputParamIdsPerNodeTenplateId(String serviceTemplateName){
580     if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
581       return new HashMap<>();
582     }
583
584     return this.unifiedSubstitutionData.get(serviceTemplateName).getAllNewPropertyInputParamIds();
585
586   }
587
588   public void addSubMappingReqAssignment(String serviceTemplateName,
589                                          RequirementAssignment requirementAssignment,
590                                          String newReqId){
591     this.mapDependencySubMappingToRequirementAssignment
592             .putIfAbsent(serviceTemplateName, new HashMap<>());
593     this.mapDependencySubMappingToRequirementAssignment.get(serviceTemplateName)
594             .putIfAbsent(requirementAssignment, newReqId);
595   }
596
597   public Optional<String> getNewReqAssignmentDependencyId(String serviceTemplateName,
598                                                           RequirementAssignment requirementAssignment){
599     if(!this.mapDependencySubMappingToRequirementAssignment.containsKey(serviceTemplateName)){
600       return Optional.empty();
601     }
602
603     Map<RequirementAssignment, String> requirementAssignmentMap =
604             this.mapDependencySubMappingToRequirementAssignment.get(serviceTemplateName);
605     return requirementAssignmentMap.containsKey
606             (requirementAssignment) ? Optional.of(requirementAssignmentMap.get(requirementAssignment)) :
607             Optional.empty();
608   }
609
610
611 }