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