0e6610d5cd0d21af99e823433f16fc75acd1c7c3
[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.utils.SdcCommon;
28 import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
29 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
30 import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
31 import org.openecomp.sdc.heat.datatypes.model.Resource;
32 import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
33 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
34 import org.openecomp.sdc.tosca.services.ToscaUtil;
35 import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
36 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionEntity;
37 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedSubstitutionData;
38 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
39 import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
40 import org.openecomp.sdc.translator.services.heattotosca.Constants;
41 import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
42 import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
43
44 import java.io.InputStream;
45 import java.util.ArrayList;
46 import java.util.Collection;
47 import java.util.HashMap;
48 import java.util.HashSet;
49 import java.util.List;
50 import java.util.Map;
51 import java.util.Objects;
52 import java.util.Optional;
53 import java.util.Set;
54
55
56 public class TranslationContext {
57
58
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;
65
66   static {
67     Configuration config = ConfigurationManager.lookup();
68     String propertyFileName = SdcCommon.HEAT_TO_TOSCA_MAPPING_CONF;
69     translationMapping =
70         config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY);
71     try {
72       globalServiceTemplates = GlobalTypesGenerator.getGlobalTypesServiceTemplate();
73     } catch (Exception exc) {
74       throw new RuntimeException("Failed to load GlobalTypes", exc);
75     }
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);
87
88   }
89
90   private ManifestFile manifest;
91
92   public static List getEnrichPortResourceProperties() {
93     return enrichPortResourceProperties;
94   }
95
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<>();
120
121   public static Map<String, ImplementationConfiguration>
122   getSupportedConsolidationComputeResources() {
123     return supportedConsolidationComputeResources;
124   }
125
126   public static void setSupportedConsolidationComputeResources(
127       Map<String, ImplementationConfiguration> supportedConsolidationComputeResources) {
128     TranslationContext.supportedConsolidationComputeResources =
129         supportedConsolidationComputeResources;
130   }
131
132   public static Map<String, ImplementationConfiguration> getSupportedConsolidationPortResources() {
133     return supportedConsolidationPortResources;
134   }
135
136   public static void setSupportedConsolidationPortResources(
137       Map<String, ImplementationConfiguration> supportedConsolidationPortResources) {
138     TranslationContext.supportedConsolidationPortResources = supportedConsolidationPortResources;
139   }
140
141   /**
142    * Get nameExtractor implemetation class instance.
143    *
144    * @param extractorImplKey configuration key for the implementation class
145    * @return implemetation class instance
146    */
147   public static NameExtractor getNameExtractorImpl(String extractorImplKey) {
148     String nameExtractorImplClassName =
149         nameExtractorImplMap.get(extractorImplKey).getImplementationClass();
150
151     return CommonMethods.newInstance(nameExtractorImplClassName, NameExtractor.class);
152   }
153
154   public Map<String, UnifiedSubstitutionData> getUnifiedSubstitutionData() {
155     return unifiedSubstitutionData;
156   }
157
158   public void setUnifiedSubstitutionData(
159       Map<String, UnifiedSubstitutionData> unifiedSubstitutionData) {
160     this.unifiedSubstitutionData = unifiedSubstitutionData;
161   }
162
163   public void addCleanedNodeTemplate(String serviceTemplateName,
164                                      String nodeTemplateId,
165                                      UnifiedCompositionEntity unifiedCompositionEntity,
166                                      NodeTemplate nodeTemplate) {
167     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
168     this.unifiedSubstitutionData
169         .get(serviceTemplateName)
170         .addCleanedNodeTemplate(nodeTemplateId, unifiedCompositionEntity, nodeTemplate);
171   }
172
173   public NodeTemplate getCleanedNodeTemplate(String serviceTemplateName,
174                                              String nodeTemplateId) {
175     return this.unifiedSubstitutionData.get(serviceTemplateName)
176         .getCleanedNodeTemplate(nodeTemplateId);
177   }
178
179   public void addUnifiedNestedNodeTemplateId(String serviceTemplateName,
180                                              String nestedNodeTemplateId,
181                                              String unifiedNestedNodeTemplateId) {
182     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
183     this.unifiedSubstitutionData.get(serviceTemplateName)
184         .addUnifiedNestedNodeTemplateId(nestedNodeTemplateId, unifiedNestedNodeTemplateId);
185   }
186
187   public Optional<String> getUnifiedNestedNodeTemplateId(String serviceTemplateName,
188                                                          String nestedNodeTemplateId) {
189     return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
190         : this.unifiedSubstitutionData.get(serviceTemplateName)
191             .getUnifiedNestedNodeTemplateId(nestedNodeTemplateId);
192   }
193
194   public void addUnifiedNestedNodeTypeId(String serviceTemplateName,
195                                          String nestedNodeTypeId,
196                                          String unifiedNestedNodeTypeId) {
197     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
198     this.unifiedSubstitutionData.get(serviceTemplateName)
199         .addUnifiedNestedNodeTypeId(nestedNodeTypeId, unifiedNestedNodeTypeId);
200   }
201
202   public Optional<String> getUnifiedNestedNodeTypeId(String serviceTemplateName,
203                                                      String nestedNodeTemplateId) {
204     return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
205         : this.unifiedSubstitutionData.get(serviceTemplateName)
206             .getUnifiedNestedNodeTypeId(nestedNodeTemplateId);
207   }
208
209   public ConsolidationData getConsolidationData() {
210     return consolidationData;
211   }
212
213   public void setConsolidationData(ConsolidationData consolidationData) {
214     this.consolidationData = consolidationData;
215   }
216
217   public void addManifestFile(String fileName, FileData.Type fileType) {
218     this.manifestFiles.put(fileName, fileType);
219   }
220
221   public Set<String> getNestedHeatsFiles() {
222     return nestedHeatsFiles;
223   }
224
225   public Map<String, Set<String>> getHeatStackGroupMembers() {
226     return heatStackGroupMembers;
227   }
228
229   public FileContentHandler getFiles() {
230     return files;
231   }
232
233   public void setFiles(Map<String, byte[]> files) {
234     this.files.putAll(files);
235   }
236
237   public InputStream getFileContent(String fileName) {
238     return files.getFileContent(fileName);
239   }
240
241   public void addFile(String name, byte[] content) {
242     files.addFile(name, content);
243   }
244
245   public ManifestFile getManifest() {
246     return manifest;
247   }
248
249   public void setManifest(ManifestFile manifest) {
250     this.manifest = manifest;
251   }
252
253   public Map<String, Set<String>> getTranslatedResources() {
254     return translatedResources;
255   }
256
257   public Map<String, Map<String, String>> getTranslatedIds() {
258     return translatedIds;
259   }
260
261   public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String
262                                                                         nestedHeatFileNameToSkip){
263     Set<String> allTranslatedResourceIds = new HashSet<>();
264
265     this.translatedIds.entrySet().stream().filter(
266         heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey()
267             .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> {
268       allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet());
269     });
270
271     return allTranslatedResourceIds;
272   }
273
274   // get tosca name from mapping configuration file
275   //element type - parameter/attribute
276   // element name - heat parameter/attribute name
277   //return value - tosca parameter/attribute name
278   public String getElementMapping(String resourceType, String elementType, String elementName) {
279     if (Objects.isNull(translationMapping.get(resourceType))) {
280       return null;
281     }
282     if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
283       return null;
284     }
285     return translationMapping.get(resourceType).get(elementType).get(elementName);
286   }
287
288   public Map<String, String> getElementMapping(String resourceType, String elementType) {
289     if (Objects.isNull(translationMapping.get(resourceType))) {
290       return null;
291     }
292     return translationMapping.get(resourceType).get(elementType);
293   }
294
295   public Set<String> getElementSet(String resourceType, String elementType) {
296     if (Objects.isNull(translationMapping.get(resourceType))) {
297       return new HashSet<>();
298     }
299     if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
300       return new HashSet<>();
301     }
302     return translationMapping.get(resourceType).get(elementType).keySet();
303   }
304
305   public Map<String, ServiceTemplate> getTranslatedServiceTemplates() {
306     return translatedServiceTemplates;
307   }
308
309   public ServiceTemplate getGlobalSubstitutionServiceTemplate() {
310     return getTranslatedServiceTemplates().get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
311   }
312
313   public FileContentHandler getExternalArtifacts() {
314     return externalArtifacts;
315   }
316
317   public void addExternalArtifacts(String name, byte[] content) {
318     this.externalArtifacts.addFile(name, content);
319   }
320
321   public Map<String, TranslatedHeatResource> getHeatSharedResourcesByParam() {
322     return heatSharedResourcesByParam;
323   }
324
325   public void addHeatSharedResourcesByParam(String parameterName, String resourceId,
326                                             Resource resource) {
327     this.addHeatSharedResourcesByParam(parameterName,
328         new TranslatedHeatResource(resourceId, resource));
329   }
330
331   private void addHeatSharedResourcesByParam(String parameterName,
332                                              TranslatedHeatResource translatedHeatResource) {
333     this.heatSharedResourcesByParam.put(parameterName, translatedHeatResource);
334   }
335
336   public Map<String, ServiceTemplate> getGlobalServiceTemplates() {
337     return globalServiceTemplates;
338   }
339
340   public Map<String, String> getNestedHeatFileName() {
341     return nestedHeatFileName;
342   }
343
344   public void addNestedHeatFileName(String substituteServiceTempalteName,
345                                     String nestedHeatFileName) {
346     this.nestedHeatFileName.put(substituteServiceTempalteName, nestedHeatFileName);
347   }
348
349   public Map<String, Map<String, String>> getUsedHeatPseudoParams() {
350     return usedHeatPseudoParams;
351   }
352
353   public void addUsedHeatPseudoParams(String heatFileName, String heatPseudoParam, String
354       translatedToscaParam) {
355     if (Objects.isNull(this.usedHeatPseudoParams.get(heatFileName))) {
356       this.usedHeatPseudoParams.put(heatFileName, new HashMap<>());
357     }
358     this.usedHeatPseudoParams.get(heatFileName).put(heatPseudoParam, translatedToscaParam);
359   }
360
361   /**
362    * Add the unified substitution data info in context. Contains a mapping of original node
363    * template id and the new node template id in the abstract substitute
364    *
365    * @param serviceTemplateFileName the service template file name
366    * @param originalNodeTemplateId  the original node template id
367    * @param abstractNodeTemplateId  the node template id in the abstract substitute
368    */
369   public void addUnifiedSubstitutionData(String serviceTemplateFileName,
370                                          String originalNodeTemplateId,
371                                          String abstractNodeTemplateId) {
372
373     Map<String, String> nodeAbstractNodeTemplateIdMap = this.getUnifiedSubstitutionData()
374         .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
375         .getNodesRelatedAbstractNode();
376
377     if (nodeAbstractNodeTemplateIdMap == null) {
378       nodeAbstractNodeTemplateIdMap = new HashMap<>();
379     }
380     nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
381     this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
382         nodeAbstractNodeTemplateIdMap);
383   }
384
385   /**
386    * Add the unified substitution data info in context. Contains a mapping of original node
387    * template id and the new node template id in the abstract substitute
388    *
389    * @param serviceTemplateFileName                   the service template file name
390    * @param originalNodeTemplateId                    the original node template id
391    * @param substitutionServiceTemplateNodeTemplateId the node template id in the substitution
392    *                                                  service template
393    */
394   public void addSubstitutionServiceTemplateUnifiedSubstitutionData(
395       String serviceTemplateFileName,
396       String originalNodeTemplateId,
397       String substitutionServiceTemplateNodeTemplateId) {
398
399     Map<String, String> nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = this
400         .getUnifiedSubstitutionData()
401         .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
402         .getNodesRelatedSubstitutionServiceTemplateNode();
403
404     if (nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap == null) {
405       nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = new HashMap<>();
406     }
407     nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap.put(originalNodeTemplateId,
408         substitutionServiceTemplateNodeTemplateId);
409     this.getUnifiedSubstitutionData().get(serviceTemplateFileName)
410         .setNodesRelatedSubstitutionServiceTemplateNode(
411             nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap);
412   }
413
414   /**
415    * Get unified abstract node template which is mapped to the input node template id.
416    *
417    * @param serviceTemplate the service template
418    * @param nodeTemplateId  the node template id
419    */
420   public String getUnifiedAbstractNodeTemplateId(ServiceTemplate serviceTemplate,
421                                                  String nodeTemplateId) {
422     UnifiedSubstitutionData unifiedSubstitutionData =
423         this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
424     return unifiedSubstitutionData.getNodesRelatedAbstractNode().get(nodeTemplateId);
425   }
426
427   /**
428    * Get unified node template in the substitution service template which is mapped to the
429    * original input node template id.
430    *
431    * @param serviceTemplate the service template
432    * @param nodeTemplateId  the node template id
433    */
434   public String getUnifiedSubstitutionNodeTemplateId(ServiceTemplate serviceTemplate,
435                                                      String nodeTemplateId) {
436     UnifiedSubstitutionData unifiedSubstitutionData =
437         this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
438     return unifiedSubstitutionData.getNodesRelatedSubstitutionServiceTemplateNode()
439         .get(nodeTemplateId);
440   }
441
442   public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
443                                                       String computeType) {
444     return this.unifiedSubstitutionData.get(serviceTemplateName)
445         .getHandledNestedComputeNodeTemplateIndex(computeType);
446   }
447
448   public void updateHandledComputeType(String serviceTemplateName,
449                                        String handledComputeType,
450                                        String nestedServiceTemplateFileName) {
451     String globalSTName =
452         ToscaUtil.getServiceTemplateFileName(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
453     this.unifiedSubstitutionData.putIfAbsent(
454         globalSTName, new UnifiedSubstitutionData());
455     this.unifiedSubstitutionData.get(globalSTName)
456         .addHandledComputeType(handledComputeType);
457     this.unifiedSubstitutionData.get(globalSTName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
458
459     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
460     this.unifiedSubstitutionData.get(serviceTemplateName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
461   }
462
463   public void addHandledComputeTypeInServiceTemplate(String serviceTemplateName,
464                                                      String handledComputeType){
465     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
466     this.unifiedSubstitutionData.get(serviceTemplateName).addHandledComputeType(handledComputeType);
467   }
468
469   public boolean isComputeTypeHandledInServiceTemplate(String serviceTemplateName,
470                                                        String computeType) {
471     return !Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))
472         && this.unifiedSubstitutionData.get(serviceTemplateName)
473         .isComputeTypeHandledInServiceTemplate(computeType);
474   }
475
476   public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
477                                                       String nestedServiceTemplateName,
478                                                       String computeType){
479     return this.unifiedSubstitutionData.get(serviceTemplateName)
480         .getHandledNestedComputeNodeTemplateIndex(computeType);
481   }
482
483   public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName,
484                                                    String nestedServiceTemplateFileName) {
485     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
486       return false;
487     }
488     return this.unifiedSubstitutionData.get(serviceTemplateName)
489         .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName);
490   }
491
492   public Set<String> getAllRelatedNestedNodeTypeIds(){
493     String globalName = "GlobalSubstitutionTypes";
494     if(Objects.isNull(this.unifiedSubstitutionData) ||
495        Objects.isNull(this.unifiedSubstitutionData.get(globalName))){
496       return new HashSet<>();
497     }
498
499     return this.unifiedSubstitutionData.get(globalName).getAllRelatedNestedNodeTypeIds();
500   }
501
502   public boolean isUnifiedHandledServiceTemplate(ServiceTemplate serviceTemplate) {
503     String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
504     if (unifiedHandledServiceTemplates.contains(serviceTemplateFileName)) {
505       return true;
506     }
507     return false;
508   }
509
510
511
512   public void addUnifiedHandledServiceTeamplte(ServiceTemplate serviceTemplate) {
513     String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
514     this.unifiedHandledServiceTemplates.add(serviceTemplateFileName);
515   }
516
517   public boolean isNestedNodeWasHandled(String serviceTemplateName,
518                                         String nestedNodeTemplateId) {
519     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
520       return false;
521     }
522     return this.unifiedSubstitutionData.get(serviceTemplateName)
523         .isNestedNodeWasHandled(nestedNodeTemplateId);
524   }
525
526   public void addNestedNodeAsHandled(String serviceTemplateName,
527                                      String nestedNodeTemplateId) {
528     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
529     this.unifiedSubstitutionData.get(serviceTemplateName)
530         .addHandledNestedNodes(nestedNodeTemplateId);
531   }
532
533   public void updateUsedTimesForNestedComputeNodeType(String serviceTemplateName,
534                                                       String computeType) {
535     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
536
537     this.unifiedSubstitutionData.get(serviceTemplateName)
538         .updateUsedTimesForNestedComputeNodeType(computeType);
539   }
540
541   public int getGlobalNodeTypeIndex(String serviceTemplateName,
542                                     String computeType) {
543     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
544       return 0;
545     }
546     return this.unifiedSubstitutionData.get(serviceTemplateName).getGlobalNodeTypeIndex
547         (computeType);
548   }
549
550   public void addNewPropertyIdToNodeTemplate(String serviceTemplateName,
551                                              String newPropertyId,
552                                              Object origPropertyValue){
553     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
554     this.unifiedSubstitutionData.get(serviceTemplateName).addNewPropertyIdToNodeTemplate(
555         newPropertyId, origPropertyValue);
556   }
557
558   public Optional<Object> getNewPropertyInputParamId(String serviceTemplateName,
559                                                      String newPropertyId){
560     if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
561       return Optional.empty();
562     }
563
564     return this.unifiedSubstitutionData.get(serviceTemplateName).getNewPropertyInputParam
565         (newPropertyId);
566   }
567
568   public Map<String, Object> getAllNewPropertyInputParamIdsPerNodeTenplateId(String serviceTemplateName){
569     if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
570       return new HashMap<>();
571     }
572
573     return this.unifiedSubstitutionData.get(serviceTemplateName).getAllNewPropertyInputParamIds();
574
575   }
576
577
578 }