2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.openecomp.sdc.translator.datatypes.heattotosca;
 
  23 import org.openecomp.config.api.Configuration;
 
  24 import org.openecomp.config.api.ConfigurationManager;
 
  25 import org.openecomp.core.utilities.CommonMethods;
 
  26 import org.openecomp.core.utilities.file.FileContentHandler;
 
  27 import org.openecomp.sdc.common.errors.CoreException;
 
  28 import org.openecomp.sdc.common.utils.SdcCommon;
 
  29 import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
 
  30 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
 
  31 import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
 
  32 import org.openecomp.sdc.heat.datatypes.model.Resource;
 
  33 import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
 
  34 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
 
  35 import org.openecomp.sdc.tosca.services.ToscaUtil;
 
  36 import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
 
  37 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionEntity;
 
  38 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedSubstitutionData;
 
  39 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
 
  40 import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
 
  41 import org.openecomp.sdc.translator.services.heattotosca.Constants;
 
  42 import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
 
  43 import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
 
  44 import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
 
  46 import java.io.InputStream;
 
  47 import java.util.HashMap;
 
  48 import java.util.HashSet;
 
  49 import java.util.List;
 
  51 import java.util.Objects;
 
  52 import java.util.Optional;
 
  56 public class TranslationContext {
 
  59   private static Map<String, Map<String, Map<String, String>>> translationMapping;
 
  60   private static Map<String, ServiceTemplate> globalServiceTemplates;
 
  61   private static Map<String, ImplementationConfiguration> nameExtractorImplMap;
 
  62   private static Map<String, ImplementationConfiguration> supportedConsolidationComputeResources;
 
  63   private static Map<String, ImplementationConfiguration> supportedConsolidationPortResources;
 
  64   private static List enrichPortResourceProperties;
 
  67     Configuration config = ConfigurationManager.lookup();
 
  68     String propertyFileName = SdcCommon.HEAT_TO_TOSCA_MAPPING_CONF;
 
  70         config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY);
 
  72       globalServiceTemplates = GlobalTypesGenerator.getGlobalTypesServiceTemplate();
 
  73     } catch (Exception exc) {
 
  74       throw new RuntimeException("Failed to load GlobalTypes", exc);
 
  76     nameExtractorImplMap = config.populateMap(ConfigConstants.TRANSLATOR_NAMESPACE,
 
  77         ConfigConstants.NAMING_CONVENTION_EXTRACTOR_IMPL_KEY, ImplementationConfiguration.class);
 
  78     supportedConsolidationComputeResources = config.populateMap(ConfigConstants
 
  79         .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
 
  80         .SUPPORTED_CONSOLIDATION_COMPUTE_RESOURCES_KEY, ImplementationConfiguration.class);
 
  81     supportedConsolidationPortResources = config.populateMap(ConfigConstants
 
  82         .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
 
  83         .SUPPORTED_CONSOLIDATION_PORT_RESOURCES_KEY, ImplementationConfiguration.class);
 
  84     enrichPortResourceProperties = config.getAsStringValues(ConfigConstants
 
  85         .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
 
  86         .ENRICH_PORT_RESOURCE_PROP);
 
  90   private ManifestFile manifest;
 
  92   public static List getEnrichPortResourceProperties() {
 
  93     return enrichPortResourceProperties;
 
  96   private FileContentHandler files = new FileContentHandler();
 
  97   private Map<String, FileData.Type> manifestFiles = new HashMap<>();
 
  98   //Key - file name, value - file type
 
  99   private Set<String> nestedHeatsFiles = new HashSet<>();
 
 100   private FileContentHandler externalArtifacts = new FileContentHandler();
 
 101   // Key - heat file name,value - set of heat resource ids which were translated
 
 102   private Map<String, Set<String>> translatedResources = new HashMap<>();
 
 103   // Key - heat file name, value - translated Node template id
 
 104   private Map<String, Set<String>> heatStackGroupMembers = new HashMap<>();
 
 105   // Key - heat file name, value - Map with Key - heat resource Id, Value - tosca entity template id
 
 106   private Map<String, Map<String, String>> translatedIds = new HashMap<>();
 
 107   // key - service template type, value - translated service templates
 
 108   private Map<String, ServiceTemplate> translatedServiceTemplates = new HashMap<>();
 
 109   //key - heat param name, value - shared resource data
 
 110   private Map<String, TranslatedHeatResource> heatSharedResourcesByParam = new HashMap<>();
 
 111   //key - translated substitute service template file name, value - source nested heat file name
 
 112   private Map<String, String> nestedHeatFileName = new HashMap<>();
 
 113   //Key - heat file name,value - Map eith key - heat pseudo param name,
 
 114   // value - translated tosca parameter name
 
 115   private Map<String, Map<String, String>> usedHeatPseudoParams = new HashMap<>();
 
 116   //Consolidation data gathered for Unified TOSCA model
 
 117   private ConsolidationData consolidationData = new ConsolidationData();
 
 118   private Map<String, UnifiedSubstitutionData> unifiedSubstitutionData = new HashMap<>();
 
 119   private Set<String> unifiedHandledServiceTemplates = new HashSet<>();
 
 121   private Map<String, Map<String, Map<String, Integer>>>
 
 122       requirementIdAppearanceInNodeTemplate = new HashMap<>();
 
 124   private Set<String> serviceTemplatesWithoutNodeTemplateSection = new HashSet<>();
 
 126   public static Map<String, ImplementationConfiguration>
 
 127   getSupportedConsolidationComputeResources() {
 
 128     return supportedConsolidationComputeResources;
 
 131   public static void setSupportedConsolidationComputeResources(
 
 132       Map<String, ImplementationConfiguration> supportedConsolidationComputeResources) {
 
 133     TranslationContext.supportedConsolidationComputeResources =
 
 134         supportedConsolidationComputeResources;
 
 137   public static Map<String, ImplementationConfiguration> getSupportedConsolidationPortResources() {
 
 138     return supportedConsolidationPortResources;
 
 141   public static void setSupportedConsolidationPortResources(
 
 142       Map<String, ImplementationConfiguration> supportedConsolidationPortResources) {
 
 143     TranslationContext.supportedConsolidationPortResources = supportedConsolidationPortResources;
 
 147    * Get nameExtractor implemetation class instance.
 
 149    * @param extractorImplKey configuration key for the implementation class
 
 150    * @return implemetation class instance
 
 152   public static NameExtractor getNameExtractorImpl(String extractorImplKey) {
 
 153     String nameExtractorImplClassName =
 
 154         nameExtractorImplMap.get(extractorImplKey).getImplementationClass();
 
 156     return CommonMethods.newInstance(nameExtractorImplClassName, NameExtractor.class);
 
 159   public Map<String, UnifiedSubstitutionData> getUnifiedSubstitutionData() {
 
 160     return unifiedSubstitutionData;
 
 163   public void setUnifiedSubstitutionData(
 
 164       Map<String, UnifiedSubstitutionData> unifiedSubstitutionData) {
 
 165     this.unifiedSubstitutionData = unifiedSubstitutionData;
 
 168   public void addCleanedNodeTemplate(String serviceTemplateName,
 
 169                                      String nodeTemplateId,
 
 170                                      UnifiedCompositionEntity unifiedCompositionEntity,
 
 171                                      NodeTemplate nodeTemplate) {
 
 172     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
 
 173     this.unifiedSubstitutionData
 
 174         .get(serviceTemplateName)
 
 175         .addCleanedNodeTemplate(nodeTemplateId, unifiedCompositionEntity, nodeTemplate);
 
 178   public NodeTemplate getCleanedNodeTemplate(String serviceTemplateName,
 
 179                                              String nodeTemplateId) {
 
 180     return this.unifiedSubstitutionData.get(serviceTemplateName)
 
 181         .getCleanedNodeTemplate(nodeTemplateId);
 
 184   public void addUnifiedNestedNodeTemplateId(String serviceTemplateName,
 
 185                                              String nestedNodeTemplateId,
 
 186                                              String unifiedNestedNodeTemplateId) {
 
 187     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
 
 188     this.unifiedSubstitutionData.get(serviceTemplateName)
 
 189         .addUnifiedNestedNodeTemplateId(nestedNodeTemplateId, unifiedNestedNodeTemplateId);
 
 192   public Optional<String> getUnifiedNestedNodeTemplateId(String serviceTemplateName,
 
 193                                                          String nestedNodeTemplateId) {
 
 194     return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
 
 195         : this.unifiedSubstitutionData.get(serviceTemplateName)
 
 196             .getUnifiedNestedNodeTemplateId(nestedNodeTemplateId);
 
 199   public void addUnifiedNestedNodeTypeId(String serviceTemplateName,
 
 200                                          String nestedNodeTypeId,
 
 201                                          String unifiedNestedNodeTypeId) {
 
 202     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
 
 203     this.unifiedSubstitutionData.get(serviceTemplateName)
 
 204         .addUnifiedNestedNodeTypeId(nestedNodeTypeId, unifiedNestedNodeTypeId);
 
 207   public Optional<String> getUnifiedNestedNodeTypeId(String serviceTemplateName,
 
 208                                                      String nestedNodeTemplateId) {
 
 209     return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
 
 210         : this.unifiedSubstitutionData.get(serviceTemplateName)
 
 211             .getUnifiedNestedNodeTypeId(nestedNodeTemplateId);
 
 214   public ConsolidationData getConsolidationData() {
 
 215     return consolidationData;
 
 218   public void setConsolidationData(ConsolidationData consolidationData) {
 
 219     this.consolidationData = consolidationData;
 
 222   public void addManifestFile(String fileName, FileData.Type fileType) {
 
 223     this.manifestFiles.put(fileName, fileType);
 
 226   public Set<String> getNestedHeatsFiles() {
 
 227     return nestedHeatsFiles;
 
 230   public Map<String, Set<String>> getHeatStackGroupMembers() {
 
 231     return heatStackGroupMembers;
 
 234   public FileContentHandler getFiles() {
 
 238   public void setFiles(Map<String, byte[]> files) {
 
 239     this.files.putAll(files);
 
 242   public InputStream getFileContent(String fileName) {
 
 243     return files.getFileContent(fileName);
 
 246   public void addFile(String name, byte[] content) {
 
 247     files.addFile(name, content);
 
 250   public ManifestFile getManifest() {
 
 254   public void setManifest(ManifestFile manifest) {
 
 255     this.manifest = manifest;
 
 258   public Map<String, Set<String>> getTranslatedResources() {
 
 259     return translatedResources;
 
 262   public Map<String, Map<String, String>> getTranslatedIds() {
 
 263     return translatedIds;
 
 266   public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String
 
 267                                                                         nestedHeatFileNameToSkip){
 
 268     Set<String> allTranslatedResourceIds = new HashSet<>();
 
 270     this.translatedIds.entrySet().stream().filter(
 
 271         heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey()
 
 272             .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> {
 
 273       allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet());
 
 276     return allTranslatedResourceIds;
 
 279   // get tosca name from mapping configuration file
 
 280   //element type - parameter/attribute
 
 281   // element name - heat parameter/attribute name
 
 282   //return value - tosca parameter/attribute name
 
 283   public String getElementMapping(String resourceType, String elementType, String elementName) {
 
 284     if (Objects.isNull(translationMapping.get(resourceType))) {
 
 287     if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
 
 290     return translationMapping.get(resourceType).get(elementType).get(elementName);
 
 293   public Map<String, String> getElementMapping(String resourceType, String elementType) {
 
 294     if (Objects.isNull(translationMapping.get(resourceType))) {
 
 297     return translationMapping.get(resourceType).get(elementType);
 
 300   public Set<String> getElementSet(String resourceType, String elementType) {
 
 301     if (Objects.isNull(translationMapping.get(resourceType))) {
 
 302       return new HashSet<>();
 
 304     if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
 
 305       return new HashSet<>();
 
 307     return translationMapping.get(resourceType).get(elementType).keySet();
 
 310   public Map<String, ServiceTemplate> getTranslatedServiceTemplates() {
 
 311     return translatedServiceTemplates;
 
 314   public ServiceTemplate getGlobalSubstitutionServiceTemplate() {
 
 315     return getTranslatedServiceTemplates().get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
 
 318   public FileContentHandler getExternalArtifacts() {
 
 319     return externalArtifacts;
 
 322   public void addExternalArtifacts(String name, byte[] content) {
 
 323     this.externalArtifacts.addFile(name, content);
 
 326   public Map<String, TranslatedHeatResource> getHeatSharedResourcesByParam() {
 
 327     return heatSharedResourcesByParam;
 
 330   public void addHeatSharedResourcesByParam(String parameterName, String resourceId,
 
 332     this.addHeatSharedResourcesByParam(parameterName,
 
 333         new TranslatedHeatResource(resourceId, resource));
 
 336   private void addHeatSharedResourcesByParam(String parameterName,
 
 337                                              TranslatedHeatResource translatedHeatResource) {
 
 338     this.heatSharedResourcesByParam.put(parameterName, translatedHeatResource);
 
 341   public Map<String, ServiceTemplate> getGlobalServiceTemplates() {
 
 342     return globalServiceTemplates;
 
 345   public Map<String, String> getNestedHeatFileName() {
 
 346     return nestedHeatFileName;
 
 349   public void addNestedHeatFileName(String substituteServiceTempalteName,
 
 350                                     String nestedHeatFileName) {
 
 351     this.nestedHeatFileName.put(substituteServiceTempalteName, nestedHeatFileName);
 
 354   public Map<String, Map<String, String>> getUsedHeatPseudoParams() {
 
 355     return usedHeatPseudoParams;
 
 358   public void addUsedHeatPseudoParams(String heatFileName, String heatPseudoParam, String
 
 359       translatedToscaParam) {
 
 360     if (Objects.isNull(this.usedHeatPseudoParams.get(heatFileName))) {
 
 361       this.usedHeatPseudoParams.put(heatFileName, new HashMap<>());
 
 363     this.usedHeatPseudoParams.get(heatFileName).put(heatPseudoParam, translatedToscaParam);
 
 367    * Add the unified substitution data info in context. Contains a mapping of original node
 
 368    * template id and the new node template id in the abstract substitute
 
 370    * @param serviceTemplateFileName the service template file name
 
 371    * @param originalNodeTemplateId  the original node template id
 
 372    * @param abstractNodeTemplateId  the node template id in the abstract substitute
 
 374   public void addUnifiedSubstitutionData(String serviceTemplateFileName,
 
 375                                          String originalNodeTemplateId,
 
 376                                          String abstractNodeTemplateId) {
 
 378     Map<String, String> nodeAbstractNodeTemplateIdMap = this.getUnifiedSubstitutionData()
 
 379         .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
 
 380         .getNodesRelatedAbstractNode();
 
 382     if (nodeAbstractNodeTemplateIdMap == null) {
 
 383       nodeAbstractNodeTemplateIdMap = new HashMap<>();
 
 386     if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
 
 387       throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(originalNodeTemplateId).build());
 
 389     nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
 
 390     this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
 
 391         nodeAbstractNodeTemplateIdMap);
 
 395    * Add the unified substitution data info in context. Contains a mapping of original node
 
 396    * template id and the new node template id in the abstract substitute
 
 398    * @param serviceTemplateFileName                   the service template file name
 
 399    * @param originalNodeTemplateId                    the original node template id
 
 400    * @param substitutionServiceTemplateNodeTemplateId the node template id in the substitution
 
 403   public void addSubstitutionServiceTemplateUnifiedSubstitutionData(
 
 404       String serviceTemplateFileName,
 
 405       String originalNodeTemplateId,
 
 406       String substitutionServiceTemplateNodeTemplateId) {
 
 408     Map<String, String> nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = this
 
 409         .getUnifiedSubstitutionData()
 
 410         .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
 
 411         .getNodesRelatedSubstitutionServiceTemplateNode();
 
 413     if (nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap == null) {
 
 414       nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = new HashMap<>();
 
 416     nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap.put(originalNodeTemplateId,
 
 417         substitutionServiceTemplateNodeTemplateId);
 
 418     this.getUnifiedSubstitutionData().get(serviceTemplateFileName)
 
 419         .setNodesRelatedSubstitutionServiceTemplateNode(
 
 420             nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap);
 
 424    * Get unified abstract node template which is mapped to the input node template id.
 
 426    * @param serviceTemplate the service template
 
 427    * @param nodeTemplateId  the node template id
 
 429   public String getUnifiedAbstractNodeTemplateId(ServiceTemplate serviceTemplate,
 
 430                                                  String nodeTemplateId) {
 
 431     UnifiedSubstitutionData unifiedSubstitutionData =
 
 432         this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
 
 433     return unifiedSubstitutionData.getNodesRelatedAbstractNode().get(nodeTemplateId);
 
 437    * Get unified node template in the substitution service template which is mapped to the
 
 438    * original input node template id.
 
 440    * @param serviceTemplate the service template
 
 441    * @param nodeTemplateId  the node template id
 
 443   public String getUnifiedSubstitutionNodeTemplateId(ServiceTemplate serviceTemplate,
 
 444                                                      String nodeTemplateId) {
 
 445     UnifiedSubstitutionData unifiedSubstitutionData =
 
 446         this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
 
 447     return unifiedSubstitutionData.getNodesRelatedSubstitutionServiceTemplateNode()
 
 448         .get(nodeTemplateId);
 
 451   public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
 
 452                                                       String computeType) {
 
 453     return this.unifiedSubstitutionData.get(serviceTemplateName)
 
 454         .getHandledNestedComputeNodeTemplateIndex(computeType);
 
 457   public void updateHandledComputeType(String serviceTemplateName,
 
 458                                        String handledComputeType,
 
 459                                        String nestedServiceTemplateFileName) {
 
 460     String globalSTName =
 
 461         ToscaUtil.getServiceTemplateFileName(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
 
 462     this.unifiedSubstitutionData.putIfAbsent(
 
 463         globalSTName, new UnifiedSubstitutionData());
 
 464     this.unifiedSubstitutionData.get(globalSTName)
 
 465         .addHandledComputeType(handledComputeType);
 
 466     this.unifiedSubstitutionData.get(globalSTName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
 
 468     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
 
 469     this.unifiedSubstitutionData.get(serviceTemplateName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
 
 472   public void addHandledComputeTypeInServiceTemplate(String serviceTemplateName,
 
 473                                                      String handledComputeType){
 
 474     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
 
 475     this.unifiedSubstitutionData.get(serviceTemplateName).addHandledComputeType(handledComputeType);
 
 478   public boolean isComputeTypeHandledInServiceTemplate(String serviceTemplateName,
 
 479                                                        String computeType) {
 
 480     return !Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))
 
 481         && this.unifiedSubstitutionData.get(serviceTemplateName)
 
 482         .isComputeTypeHandledInServiceTemplate(computeType);
 
 485   public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
 
 486                                                       String nestedServiceTemplateName,
 
 488     return this.unifiedSubstitutionData.get(serviceTemplateName)
 
 489         .getHandledNestedComputeNodeTemplateIndex(computeType);
 
 492   public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName,
 
 493                                                    String nestedServiceTemplateFileName) {
 
 494     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
 
 497     return this.unifiedSubstitutionData.get(serviceTemplateName)
 
 498         .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName);
 
 501   public Set<String> getAllRelatedNestedNodeTypeIds(){
 
 502     String globalName = "GlobalSubstitutionTypes";
 
 503     if(Objects.isNull(this.unifiedSubstitutionData) ||
 
 504         Objects.isNull(this.unifiedSubstitutionData.get(globalName))){
 
 505       return new HashSet<>();
 
 508     return this.unifiedSubstitutionData.get(globalName).getAllRelatedNestedNodeTypeIds();
 
 511   public boolean isUnifiedHandledServiceTemplate(ServiceTemplate serviceTemplate) {
 
 512     String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
 
 513     if (unifiedHandledServiceTemplates.contains(serviceTemplateFileName)) {
 
 521   public void addUnifiedHandledServiceTeamplte(ServiceTemplate serviceTemplate) {
 
 522     String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
 
 523     this.unifiedHandledServiceTemplates.add(serviceTemplateFileName);
 
 526   public boolean isNestedNodeWasHandled(String serviceTemplateName,
 
 527                                         String nestedNodeTemplateId) {
 
 528     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
 
 531     return this.unifiedSubstitutionData.get(serviceTemplateName)
 
 532         .isNestedNodeWasHandled(nestedNodeTemplateId);
 
 535   public void addNestedNodeAsHandled(String serviceTemplateName,
 
 536                                      String nestedNodeTemplateId) {
 
 537     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
 
 538     this.unifiedSubstitutionData.get(serviceTemplateName)
 
 539         .addHandledNestedNodes(nestedNodeTemplateId);
 
 542   public void updateUsedTimesForNestedComputeNodeType(String serviceTemplateName,
 
 543                                                       String computeType) {
 
 544     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
 
 546     this.unifiedSubstitutionData.get(serviceTemplateName)
 
 547         .updateUsedTimesForNestedComputeNodeType(computeType);
 
 550   public int getGlobalNodeTypeIndex(String serviceTemplateName,
 
 551                                     String computeType) {
 
 552     if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
 
 555     return this.unifiedSubstitutionData.get(serviceTemplateName).getGlobalNodeTypeIndex
 
 559   public void addNewPropertyIdToNodeTemplate(String serviceTemplateName,
 
 560                                              String newPropertyId,
 
 561                                              Object origPropertyValue){
 
 562     this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
 
 563     this.unifiedSubstitutionData.get(serviceTemplateName).addNewPropertyIdToNodeTemplate(
 
 564         newPropertyId, origPropertyValue);
 
 567   public Optional<Object> getNewPropertyInputParamId(String serviceTemplateName,
 
 568                                                      String newPropertyId){
 
 569     if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
 
 570       return Optional.empty();
 
 573     return this.unifiedSubstitutionData.get(serviceTemplateName).getNewPropertyInputParam
 
 577   public Map<String, Object> getAllNewPropertyInputParamIdsPerNodeTenplateId(String serviceTemplateName){
 
 578     if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
 
 579       return new HashMap<>();
 
 582     return this.unifiedSubstitutionData.get(serviceTemplateName).getAllNewPropertyInputParamIds();
 
 586   public Set<String> getServiceTemplatesWithoutNodeTemplateSection() {
 
 587     return serviceTemplatesWithoutNodeTemplateSection;
 
 590   public void setServiceTemplatesWithoutNodeTemplateSection(
 
 591       Set<String> serviceTemplatesWithoutNodeTemplateSection) {
 
 592     this.serviceTemplatesWithoutNodeTemplateSection = serviceTemplatesWithoutNodeTemplateSection;
 
 595   public void addServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
 
 596     this.serviceTemplatesWithoutNodeTemplateSection.add(serviceTemplateName);
 
 599   public boolean isServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
 
 600     return !Objects.isNull(serviceTemplateName) &&
 
 601         this.serviceTemplatesWithoutNodeTemplateSection.contains(serviceTemplateName);
 
 604   public void updateRequirementAssignmentIdIndex(String serviceTemplateName,
 
 605                                                  String nodeTemplateId,
 
 606                                                  String requirementId){
 
 607     requirementIdAppearanceInNodeTemplate.putIfAbsent(serviceTemplateName, new HashMap<>());
 
 608     requirementIdAppearanceInNodeTemplate
 
 609         .get(serviceTemplateName).putIfAbsent(nodeTemplateId, new HashMap<>());
 
 611     Map<String, Integer> requirementIdToAppearance =
 
 612         requirementIdAppearanceInNodeTemplate.get(serviceTemplateName).get(nodeTemplateId);
 
 614     if(requirementIdToAppearance.containsKey(requirementId)){
 
 615       requirementIdToAppearance
 
 616           .put(requirementId, requirementIdToAppearance.get(requirementId) + 1);
 
 618       requirementIdToAppearance.put(requirementId, 0);