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.apache.commons.collections.MapUtils;
24 import org.openecomp.config.api.Configuration;
25 import org.openecomp.config.api.ConfigurationManager;
26 import org.openecomp.core.utilities.CommonMethods;
27 import org.openecomp.core.utilities.file.FileContentHandler;
28 import org.openecomp.sdc.common.errors.CoreException;
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.ServiceTemplate;
36 import org.openecomp.sdc.tosca.services.ToscaUtil;
37 import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
38 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionEntity;
39 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedSubstitutionData;
40 import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
41 import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
42 import org.openecomp.sdc.translator.services.heattotosca.Constants;
43 import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
44 import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
45 import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
47 import java.io.InputStream;
48 import java.util.HashMap;
49 import java.util.HashSet;
50 import java.util.List;
52 import java.util.Objects;
53 import java.util.Optional;
57 public class TranslationContext {
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;
68 Configuration config = ConfigurationManager.lookup();
69 String propertyFileName = SdcCommon.HEAT_TO_TOSCA_MAPPING_CONF;
71 config.generateMap(ConfigConstants.MAPPING_NAMESPACE, ConfigConstants.RESOURCE_MAPPING_KEY);
73 globalServiceTemplates = GlobalTypesGenerator.getGlobalTypesServiceTemplate();
74 } catch (Exception exc) {
75 throw new RuntimeException("Failed to load GlobalTypes", exc);
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);
91 private ManifestFile manifest;
93 public static List getEnrichPortResourceProperties() {
94 return enrichPortResourceProperties;
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<>();
122 private Map<String, Map<String, Map<String, Integer>>>
123 requirementIdAppearanceInNodeTemplate = new HashMap<>();
125 private Set<String> serviceTemplatesWithoutNodeTemplateSection = new HashSet<>();
127 private Set<String> nodeTemplateIdsPointingToStWithoutNodeTemplates = new HashSet<>();
129 public static Map<String, ImplementationConfiguration>
130 getSupportedConsolidationComputeResources() {
131 return supportedConsolidationComputeResources;
134 public static void setSupportedConsolidationComputeResources(
135 Map<String, ImplementationConfiguration> supportedConsolidationComputeResources) {
136 TranslationContext.supportedConsolidationComputeResources =
137 supportedConsolidationComputeResources;
140 public static Map<String, ImplementationConfiguration> getSupportedConsolidationPortResources() {
141 return supportedConsolidationPortResources;
144 public static void setSupportedConsolidationPortResources(
145 Map<String, ImplementationConfiguration> supportedConsolidationPortResources) {
146 TranslationContext.supportedConsolidationPortResources = supportedConsolidationPortResources;
150 * Get nameExtractor implemetation class instance.
152 * @param extractorImplKey configuration key for the implementation class
153 * @return implemetation class instance
155 public static NameExtractor getNameExtractorImpl(String extractorImplKey) {
156 String nameExtractorImplClassName =
157 nameExtractorImplMap.get(extractorImplKey).getImplementationClass();
159 return CommonMethods.newInstance(nameExtractorImplClassName, NameExtractor.class);
162 public Map<String, UnifiedSubstitutionData> getUnifiedSubstitutionData() {
163 return unifiedSubstitutionData;
166 public void setUnifiedSubstitutionData(
167 Map<String, UnifiedSubstitutionData> unifiedSubstitutionData) {
168 this.unifiedSubstitutionData = unifiedSubstitutionData;
171 public void addCleanedNodeTemplate(String serviceTemplateName,
172 String nodeTemplateId,
173 UnifiedCompositionEntity unifiedCompositionEntity,
174 NodeTemplate nodeTemplate) {
175 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
176 this.unifiedSubstitutionData
177 .get(serviceTemplateName)
178 .addCleanedNodeTemplate(nodeTemplateId, unifiedCompositionEntity, nodeTemplate);
181 public NodeTemplate getCleanedNodeTemplate(String serviceTemplateName,
182 String nodeTemplateId) {
183 return this.unifiedSubstitutionData.get(serviceTemplateName)
184 .getCleanedNodeTemplate(nodeTemplateId);
187 public void addUnifiedNestedNodeTemplateId(String serviceTemplateName,
188 String nestedNodeTemplateId,
189 String unifiedNestedNodeTemplateId) {
190 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
191 this.unifiedSubstitutionData.get(serviceTemplateName)
192 .addUnifiedNestedNodeTemplateId(nestedNodeTemplateId, unifiedNestedNodeTemplateId);
195 public Optional<String> getUnifiedNestedNodeTemplateId(String serviceTemplateName,
196 String nestedNodeTemplateId) {
197 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
198 : this.unifiedSubstitutionData.get(serviceTemplateName)
199 .getUnifiedNestedNodeTemplateId(nestedNodeTemplateId);
202 public void addUnifiedNestedNodeTypeId(String serviceTemplateName,
203 String nestedNodeTypeId,
204 String unifiedNestedNodeTypeId) {
205 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
206 this.unifiedSubstitutionData.get(serviceTemplateName)
207 .addUnifiedNestedNodeTypeId(nestedNodeTypeId, unifiedNestedNodeTypeId);
210 public Optional<String> getUnifiedNestedNodeTypeId(String serviceTemplateName,
211 String nestedNodeTemplateId) {
212 return this.unifiedSubstitutionData.get(serviceTemplateName) == null ? Optional.empty()
213 : this.unifiedSubstitutionData.get(serviceTemplateName)
214 .getUnifiedNestedNodeTypeId(nestedNodeTemplateId);
217 public ConsolidationData getConsolidationData() {
218 return consolidationData;
221 public void setConsolidationData(ConsolidationData consolidationData) {
222 this.consolidationData = consolidationData;
225 public void addManifestFile(String fileName, FileData.Type fileType) {
226 this.manifestFiles.put(fileName, fileType);
229 public Set<String> getNestedHeatsFiles() {
230 return nestedHeatsFiles;
233 public Map<String, Set<String>> getHeatStackGroupMembers() {
234 return heatStackGroupMembers;
237 public FileContentHandler getFiles() {
241 public void setFiles(Map<String, byte[]> files) {
242 this.files.putAll(files);
245 public InputStream getFileContent(String fileName) {
246 return files.getFileContent(fileName);
249 public void addFile(String name, byte[] content) {
250 files.addFile(name, content);
253 public ManifestFile getManifest() {
257 public void setManifest(ManifestFile manifest) {
258 this.manifest = manifest;
261 public Map<String, Set<String>> getTranslatedResources() {
262 return translatedResources;
265 public Map<String, Map<String, String>> getTranslatedIds() {
266 return translatedIds;
269 public Set<String> getAllTranslatedResourceIdsFromDiffNestedFiles(String
270 nestedHeatFileNameToSkip){
271 Set<String> allTranslatedResourceIds = new HashSet<>();
273 this.translatedIds.entrySet().stream().filter(
274 heatFileNameToTranslatedIdsEntry -> !heatFileNameToTranslatedIdsEntry.getKey()
275 .equals(nestedHeatFileNameToSkip)).forEach(heatFileNameToTranslatedIdsEntry -> {
276 allTranslatedResourceIds.addAll(heatFileNameToTranslatedIdsEntry.getValue().keySet());
279 return allTranslatedResourceIds;
282 // get tosca name from mapping configuration file
283 //element type - parameter/attribute
284 // element name - heat parameter/attribute name
285 //return value - tosca parameter/attribute name
286 public String getElementMapping(String resourceType, String elementType, String elementName) {
287 if (Objects.isNull(translationMapping.get(resourceType))) {
290 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
293 return translationMapping.get(resourceType).get(elementType).get(elementName);
296 public Map<String, String> getElementMapping(String resourceType, String elementType) {
297 if (Objects.isNull(translationMapping.get(resourceType))) {
300 return translationMapping.get(resourceType).get(elementType);
303 public Set<String> getElementSet(String resourceType, String elementType) {
304 if (Objects.isNull(translationMapping.get(resourceType))) {
305 return new HashSet<>();
307 if (Objects.isNull(translationMapping.get(resourceType).get(elementType))) {
308 return new HashSet<>();
310 return translationMapping.get(resourceType).get(elementType).keySet();
313 public Map<String, ServiceTemplate> getTranslatedServiceTemplates() {
314 return translatedServiceTemplates;
317 public ServiceTemplate getGlobalSubstitutionServiceTemplate() {
318 return getTranslatedServiceTemplates().get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
321 public FileContentHandler getExternalArtifacts() {
322 return externalArtifacts;
325 public void addExternalArtifacts(String name, byte[] content) {
326 this.externalArtifacts.addFile(name, content);
329 public Map<String, TranslatedHeatResource> getHeatSharedResourcesByParam() {
330 return heatSharedResourcesByParam;
333 public void addHeatSharedResourcesByParam(String parameterName, String resourceId,
335 this.addHeatSharedResourcesByParam(parameterName,
336 new TranslatedHeatResource(resourceId, resource));
339 private void addHeatSharedResourcesByParam(String parameterName,
340 TranslatedHeatResource translatedHeatResource) {
341 this.heatSharedResourcesByParam.put(parameterName, translatedHeatResource);
344 public Map<String, ServiceTemplate> getGlobalServiceTemplates() {
345 return globalServiceTemplates;
348 public Map<String, String> getNestedHeatFileName() {
349 return nestedHeatFileName;
352 public void addNestedHeatFileName(String substituteServiceTempalteName,
353 String nestedHeatFileName) {
354 this.nestedHeatFileName.put(substituteServiceTempalteName, nestedHeatFileName);
357 public Map<String, Map<String, String>> getUsedHeatPseudoParams() {
358 return usedHeatPseudoParams;
361 public void addUsedHeatPseudoParams(String heatFileName, String heatPseudoParam, String
362 translatedToscaParam) {
363 if (Objects.isNull(this.usedHeatPseudoParams.get(heatFileName))) {
364 this.usedHeatPseudoParams.put(heatFileName, new HashMap<>());
366 this.usedHeatPseudoParams.get(heatFileName).put(heatPseudoParam, translatedToscaParam);
369 public Set<String> getTranslatedResourceIdsFromOtherFiles(String fileNameToIgnore){
370 if(MapUtils.isEmpty(this.translatedResources)){
371 return new HashSet<>();
374 Set<String> translatedResourceIds = new HashSet<>();
376 this.translatedResources.entrySet().stream().filter(entry -> !entry.getKey().equals(fileNameToIgnore))
377 .forEach(entry -> translatedResourceIds.addAll(entry.getValue()));
379 return translatedResourceIds;
383 * Add the unified substitution data info in context. Contains a mapping of original node
384 * template id and the new node template id in the abstract substitute
386 * @param serviceTemplateFileName the service template file name
387 * @param originalNodeTemplateId the original node template id
388 * @param abstractNodeTemplateId the node template id in the abstract substitute
390 public void addUnifiedSubstitutionData(String serviceTemplateFileName,
391 String originalNodeTemplateId,
392 String abstractNodeTemplateId) {
394 Map<String, String> nodeAbstractNodeTemplateIdMap = this.getUnifiedSubstitutionData()
395 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
396 .getNodesRelatedAbstractNode();
398 if (nodeAbstractNodeTemplateIdMap == null) {
399 nodeAbstractNodeTemplateIdMap = new HashMap<>();
402 if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
403 throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(originalNodeTemplateId).build());
405 nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
406 this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
407 nodeAbstractNodeTemplateIdMap);
411 * Add the unified substitution data info in context. Contains a mapping of original node
412 * template id and the new node template id in the abstract substitute
414 * @param serviceTemplateFileName the service template file name
415 * @param originalNodeTemplateId the original node template id
416 * @param substitutionServiceTemplateNodeTemplateId the node template id in the substitution
419 public void addSubstitutionServiceTemplateUnifiedSubstitutionData(
420 String serviceTemplateFileName,
421 String originalNodeTemplateId,
422 String substitutionServiceTemplateNodeTemplateId) {
424 Map<String, String> nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = this
425 .getUnifiedSubstitutionData()
426 .computeIfAbsent(serviceTemplateFileName, k -> new UnifiedSubstitutionData())
427 .getNodesRelatedSubstitutionServiceTemplateNode();
429 if (nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap == null) {
430 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap = new HashMap<>();
432 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap.put(originalNodeTemplateId,
433 substitutionServiceTemplateNodeTemplateId);
434 this.getUnifiedSubstitutionData().get(serviceTemplateFileName)
435 .setNodesRelatedSubstitutionServiceTemplateNode(
436 nodesRelatedSubstitutionServiceTemplateNodeTemplateIdMap);
440 * Get unified abstract node template which is mapped to the input node template id.
442 * @param serviceTemplate the service template
443 * @param nodeTemplateId the node template id
445 public String getUnifiedAbstractNodeTemplateId(ServiceTemplate serviceTemplate,
446 String nodeTemplateId) {
447 UnifiedSubstitutionData unifiedSubstitutionData =
448 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
449 return unifiedSubstitutionData.getNodesRelatedAbstractNode().get(nodeTemplateId);
453 * Get unified node template in the substitution service template which is mapped to the
454 * original input node template id.
456 * @param serviceTemplate the service template
457 * @param nodeTemplateId the node template id
459 public String getUnifiedSubstitutionNodeTemplateId(ServiceTemplate serviceTemplate,
460 String nodeTemplateId) {
461 UnifiedSubstitutionData unifiedSubstitutionData =
462 this.unifiedSubstitutionData.get(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
463 return unifiedSubstitutionData.getNodesRelatedSubstitutionServiceTemplateNode()
464 .get(nodeTemplateId);
467 public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
468 String computeType) {
469 return this.unifiedSubstitutionData.get(serviceTemplateName)
470 .getHandledNestedComputeNodeTemplateIndex(computeType);
473 public void updateHandledComputeType(String serviceTemplateName,
474 String handledComputeType,
475 String nestedServiceTemplateFileName) {
476 String globalSTName =
477 ToscaUtil.getServiceTemplateFileName(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
478 this.unifiedSubstitutionData.putIfAbsent(
479 globalSTName, new UnifiedSubstitutionData());
480 this.unifiedSubstitutionData.get(globalSTName)
481 .addHandledComputeType(handledComputeType);
482 this.unifiedSubstitutionData.get(globalSTName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
484 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
485 this.unifiedSubstitutionData.get(serviceTemplateName).addHandlesNestedServiceTemplate(nestedServiceTemplateFileName);
488 public void addHandledComputeTypeInServiceTemplate(String serviceTemplateName,
489 String handledComputeType){
490 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
491 this.unifiedSubstitutionData.get(serviceTemplateName).addHandledComputeType(handledComputeType);
494 public boolean isComputeTypeHandledInServiceTemplate(String serviceTemplateName,
495 String computeType) {
496 return !Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))
497 && this.unifiedSubstitutionData.get(serviceTemplateName)
498 .isComputeTypeHandledInServiceTemplate(computeType);
501 public int getHandledNestedComputeNodeTemplateIndex(String serviceTemplateName,
502 String nestedServiceTemplateName,
504 return this.unifiedSubstitutionData.get(serviceTemplateName)
505 .getHandledNestedComputeNodeTemplateIndex(computeType);
508 public boolean isNestedServiceTemplateWasHandled(String serviceTemplateName,
509 String nestedServiceTemplateFileName) {
510 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
513 return this.unifiedSubstitutionData.get(serviceTemplateName)
514 .isNestedServiceTemplateWasHandled(nestedServiceTemplateFileName);
517 public Set<String> getAllRelatedNestedNodeTypeIds(){
518 String globalName = "GlobalSubstitutionTypes";
519 if(Objects.isNull(this.unifiedSubstitutionData) ||
520 Objects.isNull(this.unifiedSubstitutionData.get(globalName))){
521 return new HashSet<>();
524 return this.unifiedSubstitutionData.get(globalName).getAllRelatedNestedNodeTypeIds();
527 public boolean isUnifiedHandledServiceTemplate(ServiceTemplate serviceTemplate) {
528 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
529 if (unifiedHandledServiceTemplates.contains(serviceTemplateFileName)) {
537 public void addUnifiedHandledServiceTeamplte(ServiceTemplate serviceTemplate) {
538 String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
539 this.unifiedHandledServiceTemplates.add(serviceTemplateFileName);
542 public boolean isNestedNodeWasHandled(String serviceTemplateName,
543 String nestedNodeTemplateId) {
544 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
547 return this.unifiedSubstitutionData.get(serviceTemplateName)
548 .isNestedNodeWasHandled(nestedNodeTemplateId);
551 public void addNestedNodeAsHandled(String serviceTemplateName,
552 String nestedNodeTemplateId) {
553 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
554 this.unifiedSubstitutionData.get(serviceTemplateName)
555 .addHandledNestedNodes(nestedNodeTemplateId);
558 public void updateUsedTimesForNestedComputeNodeType(String serviceTemplateName,
559 String computeType) {
560 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
562 this.unifiedSubstitutionData.get(serviceTemplateName)
563 .updateUsedTimesForNestedComputeNodeType(computeType);
566 public int getGlobalNodeTypeIndex(String serviceTemplateName,
567 String computeType) {
568 if (Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))) {
571 return this.unifiedSubstitutionData.get(serviceTemplateName).getGlobalNodeTypeIndex
575 public void addNewPropertyIdToNodeTemplate(String serviceTemplateName,
576 String newPropertyId,
577 Object origPropertyValue){
578 this.unifiedSubstitutionData.putIfAbsent(serviceTemplateName, new UnifiedSubstitutionData());
579 this.unifiedSubstitutionData.get(serviceTemplateName).addNewPropertyIdToNodeTemplate(
580 newPropertyId, origPropertyValue);
583 public Optional<Object> getNewPropertyInputParamId(String serviceTemplateName,
584 String newPropertyId){
585 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
586 return Optional.empty();
589 return this.unifiedSubstitutionData.get(serviceTemplateName).getNewPropertyInputParam
593 public Map<String, Object> getAllNewPropertyInputParamIdsPerNodeTenplateId(String serviceTemplateName){
594 if(Objects.isNull(this.unifiedSubstitutionData.get(serviceTemplateName))){
595 return new HashMap<>();
598 return this.unifiedSubstitutionData.get(serviceTemplateName).getAllNewPropertyInputParamIds();
602 public boolean isServiceTemplateWithoutNodeTemplatesSection(String serviceTemplateName){
603 return Objects.nonNull(serviceTemplateName)
604 && serviceTemplatesWithoutNodeTemplateSection.contains(serviceTemplateName);
607 public void addServiceTemplateWithoutNodeTemplates(String serviceTemplateName){
608 this.serviceTemplatesWithoutNodeTemplateSection.add(serviceTemplateName);
611 public void addNestedNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
612 this.nodeTemplateIdsPointingToStWithoutNodeTemplates.add(nodeTemplateId);
615 public boolean isNodeTemplateIdPointsToStWithoutNodeTemplates(String nodeTemplateId){
616 return Objects.nonNull(nodeTemplateId)
617 && nodeTemplateIdsPointingToStWithoutNodeTemplates.contains(nodeTemplateId);
620 public void updateRequirementAssignmentIdIndex(String serviceTemplateName,
621 String nodeTemplateId,
622 String requirementId){
623 requirementIdAppearanceInNodeTemplate.putIfAbsent(serviceTemplateName, new HashMap<>());
624 requirementIdAppearanceInNodeTemplate
625 .get(serviceTemplateName).putIfAbsent(nodeTemplateId, new HashMap<>());
627 Map<String, Integer> requirementIdToAppearance =
628 requirementIdAppearanceInNodeTemplate.get(serviceTemplateName).get(nodeTemplateId);
630 if(requirementIdToAppearance.containsKey(requirementId)){
631 requirementIdToAppearance
632 .put(requirementId, requirementIdToAppearance.get(requirementId) + 1);
634 requirementIdToAppearance.put(requirementId, 0);