Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / MSOCommonBPMN / src / main / java / org / onap / so / bpmn / servicedecomposition / bbobjects / VpnBondingLink.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.onap.so.bpmn.servicedecomposition.bbobjects;
22
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import com.fasterxml.jackson.annotation.JsonRootName;
25 import javax.persistence.Id;
26 import static org.apache.commons.lang3.StringUtils.*;
27 import java.io.Serializable;
28 import java.util.ArrayList;
29 import java.util.List;
30 import org.apache.commons.lang3.builder.EqualsBuilder;
31 import org.apache.commons.lang3.builder.HashCodeBuilder;
32 import org.onap.so.bpmn.servicedecomposition.ShallowCopy;
33
34 @JsonRootName("vpn-bonding-link")
35 public class VpnBondingLink implements Serializable, ShallowCopy<VpnBondingLink> {
36
37     private static final long serialVersionUID = -8355973761714642727L;
38
39     @Id
40     @JsonProperty("vpn-bonding-link-id")
41     private String vpnBondingLinkId;
42
43     @JsonProperty("configurations")
44     private List<Configuration> configurations = new ArrayList<Configuration>();
45
46     @JsonProperty("service-proxies")
47     private List<ServiceProxy> serviceProxies = new ArrayList<ServiceProxy>();
48
49     public String getVpnBondingLinkId() {
50         return vpnBondingLinkId;
51     }
52
53     public void setVpnBondingLinkId(String vpnBondingLinkId) {
54         this.vpnBondingLinkId = vpnBondingLinkId;
55     }
56
57     public List<Configuration> getConfigurations() {
58         return configurations;
59     }
60
61     public List<ServiceProxy> getServiceProxies() {
62         return serviceProxies;
63     }
64
65     public ServiceProxy getServiceProxy(String id) {
66         ServiceProxy serviceProxy = null;
67         for (ServiceProxy s : serviceProxies) {
68             if (s.getId().equals(id)) {
69                 serviceProxy = s;
70             }
71         }
72         return serviceProxy;
73     }
74
75     // TODO temp solution until references are updated to use getConfigurationByType
76     public Configuration getVnrConfiguration() {
77         Configuration configuration = null;
78         for (Configuration c : configurations) {
79             if (containsIgnoreCase(c.getConfigurationType(), "vlan")
80                     || containsIgnoreCase(c.getConfigurationType(), "vnr")) {
81                 configuration = c;
82             }
83         }
84         return configuration;
85     }
86
87     // TODO temp solution until references are updatedd
88     public void setVnrConfiguration(Configuration vnrConfiguration) {
89         if (vnrConfiguration.getConfigurationType() == null) {
90             vnrConfiguration.setConfigurationType("vlan");
91         }
92         configurations.add(vnrConfiguration);
93     }
94
95     // TODO temp solution until references are updated to use getConfigurationByType
96     public Configuration getVrfConfiguration() {
97         Configuration configuration = null;
98         for (Configuration c : configurations) {
99             if (containsIgnoreCase(c.getConfigurationType(), "vrf")) {
100                 configuration = c;
101             }
102         }
103         return configuration;
104     }
105
106     // TODO temp solution until references are updated
107     public void setVrfConfiguration(Configuration vrfConfiguration) {
108         if (vrfConfiguration.getConfigurationType() == null) {
109             vrfConfiguration.setConfigurationType("vrf");
110         }
111         configurations.add(vrfConfiguration);
112     }
113
114     // TODO temp solution until references are updated to use getServiceProxyByType
115     public ServiceProxy getInfrastructureServiceProxy() {
116         ServiceProxy serviceProxy = null;
117         for (ServiceProxy sp : serviceProxies) {
118             if (sp.getType().equals("infrastructure")) {
119                 serviceProxy = sp;
120             }
121         }
122         return serviceProxy;
123     }
124
125     // TODO temp solution until references are updated
126     public void setInfrastructureServiceProxy(ServiceProxy infrastructureServiceProxy) {
127         infrastructureServiceProxy.setType("infrastructure");
128         serviceProxies.add(infrastructureServiceProxy);
129     }
130
131     // TODO temp solution until references are updated to use getServiceProxyByType
132     public ServiceProxy getTransportServiceProxy() {
133         ServiceProxy serviceProxy = null;
134         for (ServiceProxy sp : serviceProxies) {
135             if (sp != null) {
136                 if (sp.getType().equals("transport")) {
137                     serviceProxy = sp;
138                 }
139             }
140         }
141         return serviceProxy;
142     }
143
144     // TODO temp solution until references are updated
145     public void setTransportServiceProxy(ServiceProxy transportServiceProxy) {
146         transportServiceProxy.setType("transport");
147         serviceProxies.add(transportServiceProxy);
148     }
149
150     @Override
151     public boolean equals(final Object other) {
152         if (!(other instanceof VpnBondingLink)) {
153             return false;
154         }
155         VpnBondingLink castOther = (VpnBondingLink) other;
156         return new EqualsBuilder().append(vpnBondingLinkId, castOther.vpnBondingLinkId).isEquals();
157     }
158
159     @Override
160     public int hashCode() {
161         return new HashCodeBuilder().append(vpnBondingLinkId).toHashCode();
162     }
163 }