2 * Copyright © 2016-2017 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.translator.datatypes.heattotosca;
19 import org.apache.commons.collections.MapUtils;
20 import org.openecomp.config.api.Configuration;
21 import org.openecomp.config.api.ConfigurationManager;
22 import org.openecomp.core.utilities.CommonMethods;
23 import org.openecomp.core.utilities.file.FileContentHandler;
24 import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
25 import org.openecomp.sdc.common.errors.CoreException;
26 import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
27 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
28 import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
29 import org.openecomp.sdc.heat.datatypes.model.Resource;
30 import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
31 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
32 import org.openecomp.sdc.tosca.services.ToscaUtil;
33 import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
34 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionEntity;
35 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedSubstitutionData;
36 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
37 import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
38 import org.openecomp.sdc.translator.services.heattotosca.Constants;
39 import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
40 import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
41 import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
43 import java.io.InputStream;
44 import java.util.HashMap;
45 import java.util.HashSet;
46 import java.util.List;
48 import java.util.Objects;
49 import java.util.Optional;
53 public class TranslationContext {
56 private static Map<String, Map<String, Map<String, String>>> translationMapping;
57 private static Map<String, ServiceTemplate> globalServiceTemplates;
58 private static Map<String, ImplementationConfiguration> nameExtractorImplMap;
59 private static Map<String, ImplementationConfiguration> supportedConsolidationComputeResources;
60 private static Map<String, ImplementationConfiguration> supportedConsolidationPortResources;
61 private static List<String> enrichPortResourceProperties;
62 private ManifestFile manifest;
63 private FileContentHandler files = new FileContentHandler();
64 private Map<String, FileData.Type> manifestFiles = new HashMap<>();
65 //Key - file name, value - file type
66 private Set<String> nestedHeatsFiles = new HashSet<>();
67 private FileContentHandler externalArtifacts = new FileContentHandler();
68 // Key - heat file name,value - set of heat resource ids which were translated
69 private Map<String, Set<String>> translatedResources = new HashMap<>();
70 // Key - heat file name, value - translated Node template id
71 private Map<String, Set<String>> heatStackGroupMembers = new HashMap<>();
72 // Key - heat file name, value - Map with Key - heat resource Id, Value - tosca entity template id
73 private Map<String, Map<String, String>> translatedIds = new HashMap<>();
74 // key - service template type, value - translated service templates
75 private Map<String, ServiceTemplate> translatedServiceTemplates = new HashMap<>();
76 //key - heat param name, value - shared resource data
77 private Map<String, TranslatedHeatResource> heatSharedResourcesByParam = new HashMap<>();
78 //key - translated substitute service template file name, value - source nested heat file name
79 private Map<String, String> nestedHeatFileName = new HashMap<>();
80 //Key - heat file name,value - Map eith key - heat pseudo param name,
81 // value - translated tosca parameter name
82 private Map<String, Map<String, String>> usedHeatPseudoParams = new HashMap<>();
83 //Consolidation data gathered for Unified TOSCA model
84 private ConsolidationData consolidationData = new ConsolidationData();
85 private Map<String, UnifiedSubstitutionData> unifiedSubstitutionData = new HashMap<>();
86 private Set<String> unifiedHandledServiceTemplates = new HashSet<>();
88 private Map<String, Map<String, Map<String, Integer>>>
89 requirementIdAppearanceInNodeTemplate = new HashMap<>();
91 private Set<String> serviceTemplatesWithoutNodeTemplateSection = new HashSet<>();
93 private Set<String> nodeTemplateIdsPointingToStWithoutNodeTemplates = new HashSet<>();
96 Configuration config = ConfigurationManager.lookup();
98 config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY);
100 globalServiceTemplates =
101 GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.ZIP);
102 } catch (Exception exc) {
103 throw new RuntimeException("Failed to load GlobalTypes", exc);
105 nameExtractorImplMap = config.populateMap(ConfigConstants.TRANSLATOR_NAMESPACE,
106 ConfigConstants.NAMING_CONVENTION_EXTRACTOR_IMPL_KEY, ImplementationConfiguration.class);
107 supportedConsolidationComputeResources = config.populateMap(ConfigConstants
108 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
109 .SUPPORTED_CONSOLIDATION_COMPUTE_RESOURCES_KEY, ImplementationConfiguration.class);
110 supportedConsolidationPortResources = config.populateMap(ConfigConstants
111 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
112 .SUPPORTED_CONSOLIDATION_PORT_RESOURCES_KEY, ImplementationConfiguration.class);
113 enrichPortResourceProperties = config.getAsStringValues(ConfigConstants
114 .MANDATORY_UNIFIED_MODEL_NAMESPACE, ConfigConstants
115 .ENRICH_PORT_RESOURCE_PROP);
118 public static List<String> getEnrichPortResourceProperties() {
119 return enrichPortResourceProperties;
122 public static Map<String, ImplementationConfiguration>
123 getSupportedConsolidationComputeResources() {
124 return supportedConsolidationComputeResources;
127 public static void setSupportedConsolidationComputeResources(
128 Map<String, ImplementationConfiguration> supportedConsolidationComputeResources) {
129 TranslationContext.supportedConsolidationComputeResources =
130 supportedConsolidationComputeResources;
133 public static Map<String, ImplementationConfiguration> getSupportedConsolidationPortResources() {
134 return supportedConsolidationPortResources;
137 public static void setSupportedConsolidationPortResources(
138 Map<String, ImplementationConfiguration> supportedConsolidationPortResources) {
139 TranslationContext.supportedConsolidationPortResources = supportedConsolidationPortResources;
143 * Get nameExtractor implemetation class instance.
145 * @param extractorImplKey configuration key for the implementation class
146 * @return implemetation class instance
148 public static NameExtractor getNameExtractorImpl(String extractorImplKey) {
149 String nameExtractorImplClassName =
150 nameExtractorImplMap.get(extractorImplKey).getImplementationClass();
152 return CommonMethods.newInstance(nameExtractorImplClassName, NameExtractor.class);
155 public Map<String, UnifiedSubstitutionData> getUnifiedSubstitutionData() {
156 return unifiedSubstitutionData;
159 public void setUnifiedSubstitutionData(
160 Map<String, UnifiedSubstitutionData> unifiedSubstitutionData) {
161 this.unifiedSubstitutionData = unifiedSubstitutionData;
164 public void addCleanedNodeTemplate(String serviceTemplateName,
165 String nodeTemplateId,
166 UnifiedCompositionEntity unifiedCompositionEntity,
167 NodeTemplate nodeTemplate) {
168 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
169 this.unifiedSubstitutionData
170 .get(serviceTemplateName)
171 .addCleanedNodeTemplate(nodeTemplateId, unifiedCompositionEntity, nodeTemplate);
174 public NodeTemplate getCleanedNodeTemplate(String serviceTemplateName,
175 String nodeTemplateId) {
176 return this.unifiedSubstitutionData.get(serviceTemplateName)
177 .getCleanedNodeTemplate(nodeTemplateId);
180 public void addUnifiedNestedNodeTemplateId(String serviceTemplateName,
181 String nestedNodeTemplateId,
182 String unifiedNestedNodeTemplateId) {
183 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
184 this.unifiedSubstitutionData.get(serviceTemplateName)
185 .addUnifiedNestedNodeTemplateId(nestedNodeTemplateId, unifiedNestedNodeTemplateId);
188 public Optional<String> getUnifiedNestedNodeTemplateId(String serviceTemplateName,
189 String nestedNodeTemplateId) {
190 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
191 : this.unifiedSubstitutionData.get(serviceTemplateName)
192 .getUnifiedNestedNodeTemplateId(nestedNodeTemplateId);
195 public void addUnifiedNestedNodeTypeId(String serviceTemplateName,
196 String nestedNodeTypeId,
197 String unifiedNestedNodeTypeId) {
198 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
199 this.unifiedSubstitutionData.get(serviceTemplateName)
200 .addUnifiedNestedNodeTypeId(nestedNodeTypeId, unifiedNestedNodeTypeId);
203 public Optional<String> getUnifiedNestedNodeTypeId(String serviceTemplateName,
204 String nestedNodeTemplateId) {
205 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
206 : this.unifiedSubstitutionData.get(serviceTemplateName)
207 .getUnifiedNestedNodeTypeId(nestedNodeTemplateId);
210 public ConsolidationData getConsolidationData() {
211 return consolidationData;
214 public void setConsolidationData(ConsolidationData consolidationData) {
215 this.consolidationData = consolidationData;
218 public void addManifestFile(String fileName, FileData.Type fileType) {
219 this.manifestFiles.put(fileName, fileType);
222 public Set<String> getNestedHeatsFiles() {
223 return nestedHeatsFiles;
226 public Map<String, Set<String>> getHeatStackGroupMembers() {
227 return heatStackGroupMembers;
230 public FileContentHandler getFiles() {
234 public void setFiles(Map<String, byte[]> files) {
235 this.files.putAll(files);
238 public InputStream getFileContent(String fileName) {
239 return files.getFileContent(fileName);
242 public void addFile(String name, byte[] content) {
243 files.addFile(name, content);
246 public ManifestFile getManifest() {
250 public void setManifest(ManifestFile manifest) {
251 this.manifest = manifest;
254 public Map<String, Set<String>> getTranslatedResources() {
255 return translatedResources;
258 public Map<String, Map<String, String>> getTranslatedIds() {
259 return translatedIds;
262 public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String
263 nestedHeatFileNameToSkip) {
264 Set<String> allTranslatedResourceIds = new HashSet<>();
266 this.translatedIds.entrySet().stream().filter(
267 heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey()
268 .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry ->
269 allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet())
272 return allTranslatedResourceIds;
275 // get tosca name from mapping configuration file
276 //element type - parameter/attribute
277 // element name - heat parameter/attribute name
278 //return value - tosca parameter/attribute name
279 public String getElementMapping(String resourceType, String elementType, String elementName) {
280 if (Objects.isNull(translationMapping.get(resourceType))) {
283 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
286 return translationMapping.get(resourceType).get(elementType).get(elementName);
289 public Map<String, String> getElementMapping(String resourceType, String elementType) {
290 if (Objects.isNull(translationMapping.get(resourceType))) {
293 return translationMapping.get(resourceType).get(elementType);
296 public Set<String> getElementSet(String resourceType, String elementType) {
297 if (Objects.isNull(translationMapping.get(resourceType))) {
298 return new HashSet<>();
300 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
301 return new HashSet<>();
303 return translationMapping.get(resourceType).get(elementType).keySet();
306 public Map<String, ServiceTemplate> getTranslatedServiceTemplates() {
307 return translatedServiceTemplates;
310 public ServiceTemplate getGlobalSubstitutionServiceTemplate() {
311 return getTranslatedServiceTemplates().get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
314 public FileContentHandler getExternalArtifacts() {
315 return externalArtifacts;
318 public void addExternalArtifacts(String name, byte[] content) {
319 this.externalArtifacts.addFile(name, content);
322 public Map<String, TranslatedHeatResource> getHeatSharedResourcesByParam() {
323 return heatSharedResourcesByParam;
326 public void addHeatSharedResourcesByParam(String parameterName, String resourceId,
328 this.addHeatSharedResourcesByParam(parameterName,
329 new TranslatedHeatResource(resourceId, resource));
332 private void addHeatSharedResourcesByParam(String parameterName,
333 TranslatedHeatResource translatedHeatResource) {
334 this.heatSharedResourcesByParam.put(parameterName, translatedHeatResource);
337 public Map<String, ServiceTemplate> getGlobalServiceTemplates() {
338 return globalServiceTemplates;
341 public Map<String, String> getNestedHeatFileName() {
342 return nestedHeatFileName;
345 public void addNestedHeatFileName(String substituteServiceTempalteName,
346 String nestedHeatFileName) {
347 this.nestedHeatFileName.put(substituteServiceTempalteName, nestedHeatFileName);
350 public Map<String, Map<String, String>> getUsedHeatPseudoParams() {
351 return usedHeatPseudoParams;
354 public void addUsedHeatPseudoParams(String heatFileName, String heatPseudoParam, String
355 translatedToscaParam) {
356 if (Objects.isNull(this.usedHeatPseudoParams.get(heatFileName))) {
357 this.usedHeatPseudoParams.put(heatFileName, new HashMap<>());
359 this.usedHeatPseudoParams.get(heatFileName).put(heatPseudoParam, translatedToscaParam);
362 public Set<String> getTranslatedResourceIdsFromOtherFiles(String fileNameToIgnore){
363 if(MapUtils.isEmpty(this.translatedResources)){
364 return new HashSet<>();
367 Set<String> translatedResourceIds = new HashSet<>();
369 this.translatedResources.entrySet().stream().filter(entry -> !entry.getKey().equals(fileNameToIgnore))
370 .forEach(entry -> translatedResourceIds.addAll(entry.getValue()));
372 return translatedResourceIds;
376 * Add the unified substitution data info in context. Contains a mapping of original node
377 * template id and the new node template id in the abstract substitute
379 * @param serviceTemplateFileName the service template file name
380 * @param originalNodeTemplateId the original node template id
381 * @param abstractNodeTemplateId the node template id in the abstract substitute
383 public void addUnifiedSubstitutionData(String serviceTemplateFileName,
384 String originalNodeTemplateId,
385 String abstractNodeTemplateId) {
387 Map<String, String> nodeAbstractNodeTemplateIdMap = this.getUnifiedSubstitutionData()
388 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
389 .getNodesRelatedAbstractNode();
391 if (nodeAbstractNodeTemplateIdMap == null) {
392 nodeAbstractNodeTemplateIdMap = new HashMap<>();
395 if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
396 throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(originalNodeTemplateId).build());
398 nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
399 this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
400 nodeAbstractNodeTemplateIdMap);
404 * Add the unified substitution data info in context. Contains a mapping of original node
405 * template id and the new node template id in the abstract substitute
407 * @param serviceTemplateFileName the service template file name
408 * @param originalNodeTemplateId the original node template id
409 * @param substitutionServiceTemplateNodeTemplateId the node template id in the substitution
412 public void addSubstitutionServiceTemplateUnifiedSubstitutionData(
413 String serviceTemplateFileName,
414 String originalNodeTemplateId,
415 String substitutionServiceTemplateNodeTemplateId) {
417 Map<String, String> nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = this
418 .getUnifiedSubstitutionData()
419 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
420 .getNodesRelatedSubstitutionServiceTemplateNode();
422 if (nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap == null) {
423 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = new HashMap<>();
425 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap.put(originalNodeTemplateId,
426 substitutionServiceTemplateNodeTemplateId);
427 this.getUnifiedSubstitutionData().get(serviceTemplateFileName)
428 .setNodesRelatedSubstitutionServiceTemplateNode(
429 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap);
433 * Get unified abstract node template which is mapped to the input node template id.
435 * @param serviceTemplate the service template
436 * @param nodeTemplateId the node template id
438 public String getUnifiedAbstractNodeTemplateId(ServiceTemplate serviceTemplate,
439 String nodeTemplateId) {
440 UnifiedSubstitutionData unifiedSubsData =
441 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
442 return unifiedSubsData.getNodesRelatedAbstractNode().get(nodeTemplateId);
446 * Get unified node template in the substitution service template which is mapped to the
447 * original input node template id.
449 * @param serviceTemplate the service template
450 * @param nodeTemplateId the node template id
452 public String getUnifiedSubstitutionNodeTemplateId(ServiceTemplate serviceTemplate,
453 String nodeTemplateId) {
454 UnifiedSubstitutionData unifiedSubsData =
455 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
456 return unifiedSubsData.getNodesRelatedSubstitutionServiceTemplateNode()
457 .get(nodeTemplateId);
460 public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
461 String computeType) {
462 return this.unifiedSubstitutionData.get(serviceTemplateName)
463 .getHandledNestedComputeNodeTemplateIndex(computeType);
466 public void updateHandledComputeType(String serviceTemplateName,
467 String handledComputeType,
468 String nestedServiceTemplateFileName) {
469 String globalSTName =
470 ToscaUtil.getServiceTemplateFileName(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
471 this.unifiedSubstitutionData.putIfAbsent(
472 globalSTName, new UnifiedSubstitutionData());
473 this.unifiedSubstitutionData.get(globalSTName)
474 .addHandledComputeType(handledComputeType);
475 this.unifiedSubstitutionData.get(globalSTName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
477 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
478 this.unifiedSubstitutionData.get(serviceTemplateName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
481 public void addHandledComputeTypeInServiceTemplate(String serviceTemplateName,
482 String handledComputeType){
483 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
484 this.unifiedSubstitutionData.get(serviceTemplateName).addHandledComputeType(handledComputeType);
487 public boolean isComputeTypeHandledInServiceTemplate(String serviceTemplateName,
488 String computeType) {
489 return !Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))
490 && this.unifiedSubstitutionData.get(serviceTemplateName)
491 .isComputeTypeHandledInServiceTemplate(computeType);
494 public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName,
495 String nestedServiceTemplateFileName) {
496 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
499 return this.unifiedSubstitutionData.get(serviceTemplateName)
500 .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName);
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<>();
510 return this.unifiedSubstitutionData.get(globalName).getAllRelatedNestedNodeTypeIds();
513 public boolean isUnifiedHandledServiceTemplate(ServiceTemplate serviceTemplate) {
514 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
515 if (unifiedHandledServiceTemplates.contains(serviceTemplateFileName)) {
523 public void addUnifiedHandledServiceTeamplte(ServiceTemplate serviceTemplate) {
524 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
525 this.unifiedHandledServiceTemplates.add(serviceTemplateFileName);
528 public boolean isNestedNodeWasHandled(String serviceTemplateName,
529 String nestedNodeTemplateId) {
530 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
533 return this.unifiedSubstitutionData.get(serviceTemplateName)
534 .isNestedNodeWasHandled(nestedNodeTemplateId);
537 public void addNestedNodeAsHandled(String serviceTemplateName,
538 String nestedNodeTemplateId) {
539 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
540 this.unifiedSubstitutionData.get(serviceTemplateName)
541 .addHandledNestedNodes(nestedNodeTemplateId);
544 public void updateUsedTimesForNestedComputeNodeType(String serviceTemplateName,
545 String computeType) {
546 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
548 this.unifiedSubstitutionData.get(serviceTemplateName)
549 .updateUsedTimesForNestedComputeNodeType(computeType);
552 public int getGlobalNodeTypeIndex(String serviceTemplateName,
553 String computeType) {
554 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
557 return this.unifiedSubstitutionData.get(serviceTemplateName).getGlobalNodeTypeIndex
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);
569 public Optional<Object> getNewPropertyInputParamId(String serviceTemplateName,
570 String newPropertyId){
571 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
572 return Optional.empty();
575 return this.unifiedSubstitutionData.get(serviceTemplateName).getNewPropertyInputParam
579 public Map<String, Object> getAllNewPropertyInputParamIdsPerNodeTenplateId(String serviceTemplateName){
580 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
581 return new HashMap<>();
584 return this.unifiedSubstitutionData.get(serviceTemplateName).getAllNewPropertyInputParamIds();
588 public boolean isServiceTemplateWithoutNodeTemplatesSection(String serviceTemplateName){
589 return Objects.nonNull(serviceTemplateName)
590 && serviceTemplatesWithoutNodeTemplateSection.contains(serviceTemplateName);
593 public void addServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
594 this.serviceTemplatesWithoutNodeTemplateSection.add(serviceTemplateName);
597 public void addNestedNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
598 this.nodeTemplateIdsPointingToStWithoutNodeTemplates.add(nodeTemplateId);
601 public boolean isNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
602 return Objects.nonNull(nodeTemplateId)
603 && nodeTemplateIdsPointingToStWithoutNodeTemplates.contains(nodeTemplateId);
606 public void updateRequirementAssignmentIdIndex(String serviceTemplateName,
607 String nodeTemplateId,
608 String requirementId){
609 requirementIdAppearanceInNodeTemplate.putIfAbsent(serviceTemplateName, new HashMap<>());
610 requirementIdAppearanceInNodeTemplate
611 .get(serviceTemplateName).putIfAbsent(nodeTemplateId, new HashMap<>());
613 Map<String, Integer> requirementIdToAppearance =
614 requirementIdAppearanceInNodeTemplate.get(serviceTemplateName).get(nodeTemplateId);
616 if(requirementIdToAppearance.containsKey(requirementId)){
617 requirementIdToAppearance
618 .put(requirementId, requirementIdToAppearance.get(requirementId) + 1);
620 requirementIdToAppearance.put(requirementId, 0);