2 * Copyright © 2016-2018 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.unifiedmodel.consolidation;
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;
23 import java.util.Optional;
25 public class SubInterfaceTemplateConsolidationData extends EntityConsolidationData {
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;
34 public Object getResourceGroupCount() {
35 return resourceGroupCount;
38 public void setResourceGroupCount(Object resourceGroupCount) {
39 this.resourceGroupCount = resourceGroupCount;
42 public String getNetworkRole() {
46 public void setNetworkRole(String networkRole) {
47 this.networkRole = networkRole;
50 public String getParentPortNodeTemplateId() {
51 return parentPortNodeTemplateId;
54 public void setParentPortNodeTemplateId(String parentPortNodeTemplateId) {
55 this.parentPortNodeTemplateId = parentPortNodeTemplateId;
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);
67 return Optional.ofNullable(portTemplateConsolidationData);
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();
77 return Optional.ofNullable(subInterfacePortTemplateConsolidationData.get().getNetworkRole());