push addional code
[sdc.git] / openecomp-be / lib / openecomp-sdc-translator-lib / openecomp-sdc-translator-core / src / main / java / org / openecomp / sdc / translator / services / heattotosca / globaltypes / GlobalTypesGenerator.java
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.services.heattotosca.globaltypes;
22
23 import org.openecomp.sdc.tosca.datatypes.model.Import;
24 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
25 import org.openecomp.sdc.tosca.services.ToscaNativeTypesServiceTemplate;
26 import org.openecomp.sdc.tosca.services.ToscaUtil;
27 import org.openecomp.sdc.translator.services.heattotosca.Constants;
28
29 import java.util.HashMap;
30 import java.util.Map;
31
32 public class GlobalTypesGenerator {
33
34   private GlobalTypesGenerator() {
35   }
36
37   /**
38    * Gets global types service template.
39    *
40    * @return the global types service template
41    */
42   public static Map<String, ServiceTemplate> getGlobalTypesServiceTemplate() {
43     Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
44
45     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
46         CommonGlobalTypes.createServiceTemplate());
47     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
48         NovaServerGlobalType.createServiceTemplate());
49     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
50         CinderVolumeGlobalType.createServiceTemplate());
51     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
52         ContrailVirtualNetworkGlobalType.createServiceTemplate());
53     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
54         ContrailV2VirtualNetworkGlobalType.createServiceTemplate());
55     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
56         ContrailV2VirtualMachineInterfaceGlobalType.createServiceTemplate());
57     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
58         NeutronNetGlobalType.createServiceTemplate());
59     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
60         NeutronPortGlobalType.createServiceTemplate());
61     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
62         ContrailNetworkRuleGlobalType.createServiceTemplate());
63     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
64         ContrailV2NetworkRuleGlobalType.createServiceTemplate());
65     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
66         NeutronSecurityRulesGlobalType.createServiceTemplate());
67     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
68         AbstractSubstituteGlobalType.createServiceTemplate());
69     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
70         ToscaNativeTypesServiceTemplate.createServiceTemplate());
71     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
72         ContrailComputeGlobalType.createServiceTemplate());
73     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
74         ContrailPortGlobalType.createServiceTemplate());
75     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
76         ContrailV2NetworkRuleGlobalType.createServiceTemplate());
77     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
78         ContrailV2VirtualNetworkGlobalType.createServiceTemplate());
79     ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
80         ContrailAbstractSubstituteGlobalType.createServiceTemplate());
81     return serviceTemplates;
82   }
83
84   private static void addGlobalServiceTemplate(Map<String, ServiceTemplate> serviceTemplates,
85                                                ServiceTemplate commonServiceTemplate) {
86     serviceTemplates
87         .put(ToscaUtil.getServiceTemplateFileName(commonServiceTemplate), commonServiceTemplate);
88   }
89
90   /**
91    * Gets global types import list.
92    *
93    * @return the global types import list
94    */
95   public static Map<String, Import> getGlobalTypesImportList() {
96     Map<String, Import> globalImportMap = new HashMap<>();
97     globalImportMap.put(Constants.COMMON_GLOBAL_TEMPLATE_NAME,
98         GlobalTypesUtil.createServiceTemplateImport(Constants.COMMON_GLOBAL_TEMPLATE_NAME));
99     globalImportMap.put(Constants.NOVA_SERVER_TEMPLATE_NAME,
100         GlobalTypesUtil.createServiceTemplateImport(Constants.NOVA_SERVER_TEMPLATE_NAME));
101     globalImportMap.put(Constants.NEUTRON_PORT_TEMPLATE_NAME,
102         GlobalTypesUtil.createServiceTemplateImport(Constants.NEUTRON_PORT_TEMPLATE_NAME));
103     globalImportMap.put(Constants.NEUTRON_SECURITY_RULES_TEMPLATE_NAME, GlobalTypesUtil
104         .createServiceTemplateImport(Constants.NEUTRON_SECURITY_RULES_TEMPLATE_NAME));
105     globalImportMap.put(Constants.NEUTRON_NET_TEMPLATE_NAME,
106         GlobalTypesUtil.createServiceTemplateImport(Constants.NEUTRON_NET_TEMPLATE_NAME));
107     globalImportMap.put(Constants.CINDER_VOLUME_TEMPLATE_NAME,
108         GlobalTypesUtil.createServiceTemplateImport(Constants.CINDER_VOLUME_TEMPLATE_NAME));
109     globalImportMap.put(Constants.CONTRAIL_VIRTUAL_NETWORK_TEMPLATE_NAME, GlobalTypesUtil
110         .createServiceTemplateImport(Constants.CONTRAIL_VIRTUAL_NETWORK_TEMPLATE_NAME));
111     globalImportMap.put(Constants.CONTRAIL_NETWORK_RULE_TEMPLATE_NAME,
112         GlobalTypesUtil.createServiceTemplateImport(Constants.CONTRAIL_NETWORK_RULE_TEMPLATE_NAME));
113     globalImportMap.put(Constants.ABSTRACT_SUBSTITUTE_TEMPLATE_NAME,
114         GlobalTypesUtil.createServiceTemplateImport(Constants.ABSTRACT_SUBSTITUTE_TEMPLATE_NAME));
115     globalImportMap.put(Constants.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_TEMPLATE_NAME,
116         GlobalTypesUtil.createServiceTemplateImport(
117             Constants.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_TEMPLATE_NAME));
118     globalImportMap.put(Constants.CONTRAIL_COMPUTE_TEMPLATE_NAME,
119         GlobalTypesUtil.createServiceTemplateImport(Constants.CONTRAIL_COMPUTE_TEMPLATE_NAME));
120     globalImportMap.put(Constants.CONTRAIL_PORT_TEMPLATE_NAME,
121         GlobalTypesUtil.createServiceTemplateImport(Constants.CONTRAIL_PORT_TEMPLATE_NAME));
122     globalImportMap.put(Constants.CONTRAIL_ABSTRACT_SUBSTITUTE_TEMPLATE_NAME, GlobalTypesUtil
123         .createServiceTemplateImport(Constants.CONTRAIL_ABSTRACT_SUBSTITUTE_TEMPLATE_NAME));
124     return globalImportMap;
125   }
126
127
128 }