Rename packages from openecomp to onap.
[sdc.git] / openecomp-be / lib / openecomp-sdc-translator-lib / openecomp-sdc-translator-core / src / main / java / org / openecomp / sdc / translator / datatypes / heattotosca / unifiedmodel / consolidation / SubInterfaceTemplateConsolidationData.java
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation;
18
19 import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
20 import org.openecomp.sdc.tosca.services.ToscaUtil;
21 import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
22
23 import java.util.Optional;
24
25 public class SubInterfaceTemplateConsolidationData extends EntityConsolidationData {
26
27   //Value of the property count in the resource group representing the sub-interface
28   private Object resourceGroupCount;
29   //Network role of the sub-interface
30   private String networkRole;
31   //Parent port node template id
32   private String parentPortNodeTemplateId;
33
34   public Object getResourceGroupCount() {
35     return resourceGroupCount;
36   }
37
38   public void setResourceGroupCount(Object resourceGroupCount) {
39     this.resourceGroupCount = resourceGroupCount;
40   }
41
42   public String getNetworkRole() {
43     return networkRole;
44   }
45
46   public void setNetworkRole(String networkRole) {
47     this.networkRole = networkRole;
48   }
49
50   public String getParentPortNodeTemplateId() {
51     return parentPortNodeTemplateId;
52   }
53
54   public void setParentPortNodeTemplateId(String parentPortNodeTemplateId) {
55     this.parentPortNodeTemplateId = parentPortNodeTemplateId;
56   }
57
58   public Optional<PortTemplateConsolidationData> getParentPortTemplateConsolidationData(ServiceTemplate serviceTemplate,
59                                                                                         TranslationContext context) {
60     FilePortConsolidationData filePortConsolidationData = context.getConsolidationData().getPortConsolidationData()
61         .getFilePortConsolidationData(ToscaUtil.getServiceTemplateFileName(serviceTemplate));
62     PortTemplateConsolidationData portTemplateConsolidationData = null;
63     if (filePortConsolidationData != null) {
64       portTemplateConsolidationData = filePortConsolidationData
65           .getPortTemplateConsolidationData(parentPortNodeTemplateId);
66     }
67     return Optional.ofNullable(portTemplateConsolidationData);
68   }
69
70   public Optional<String> getParentPortNetworkRole(ServiceTemplate serviceTemplate,
71                                                                 TranslationContext context) {
72     Optional<PortTemplateConsolidationData> subInterfacePortTemplateConsolidationData =
73         getParentPortTemplateConsolidationData(serviceTemplate, context);
74     if (!subInterfacePortTemplateConsolidationData.isPresent()) {
75       return Optional.empty();
76     }
77     return Optional.ofNullable(subInterfacePortTemplateConsolidationData.get().getNetworkRole());
78   }
79
80 }