Corrects various javadoc problems
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / MappingConstraints.java
1 /*
2  * Copyright © 2017 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9
10 package org.opendaylight.transportpce.servicehandler;
11
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.CoRoutingOrGeneral;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.CoRouting;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.General;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.general.Diversity;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.general.Exclude;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.general.Include;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.general.Latency;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraints;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints;
21 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.co.routing.CoRoutingBuilder;
22 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.DiversityBuilder;
23 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.ExcludeBuilder;
24 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.IncludeBuilder;
25 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.LatencyBuilder;
26 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.diversity.existing.service.contraints.sp.ExistingServiceApplicabilityBuilder;
27 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.HardConstraintsBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.SoftConstraintsBuilder;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 /**
33  * Class for mapping
34  * Hard/soft constraint from Service 1.2
35  * to servicePath 1.4.
36  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
37  *
38  */
39 public class MappingConstraints {
40     /* Logging. */
41     private static final Logger LOG = LoggerFactory.getLogger(MappingConstraints.class);
42     private HardConstraints serviceHardConstraints;
43     private SoftConstraints serviceSoftConstraints;
44     private org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
45         .routing.constraints.rev170426.routing.constraints.sp.HardConstraints servicePathHardConstraints;
46     private org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
47         .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints servicePathSoftConstraints;
48
49     /**
50      * MappingConstraints class constructor
51      * for hard/soft from service 1.2.
52      *
53      * @param hard HardConstraints
54      * @param soft SoftConstraints
55      */
56     public MappingConstraints(HardConstraints hard, SoftConstraints soft) {
57         setServiceHardConstraints(hard);
58         setServiceSoftConstraints(soft);
59     }
60
61     /**
62      * MappingConstraints class constructor
63      * for hard/soft from servicePath 1.4.
64      *
65      * @param hard HardConstraints
66      * @param soft SoftConstraints
67      */
68     public MappingConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
69             .routing.constraints.rev170426.routing.constraints.sp.HardConstraints hard,
70             org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
71             .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints soft) {
72         setServicePathHardConstraints(hard);
73         setServicePathSoftConstraints(soft);
74     }
75
76     /**
77      * map hard/soft constraints from Service 1.2
78      * to ServicePath 1.4.
79      */
80     public void serviceToServicePathConstarints() {
81         LOG.info("Mapping Service Constraints to ServicePath Constraints");
82         CoRoutingOrGeneral coRoutingOrGeneral = null;
83         if (serviceHardConstraints  !=  null) {
84             HardConstraintsBuilder tempHard = new HardConstraintsBuilder();
85             coRoutingOrGeneral = serviceHardConstraints.getCoRoutingOrGeneral();
86             General tmpGeneral = null;
87             CoRouting tmpCoRouting = null;
88             if (coRoutingOrGeneral  !=  null) {
89                 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
90                     .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
91                     new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
92                     .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder();
93                 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
94                     .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
95                     new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
96                     .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder();
97                 if (coRoutingOrGeneral instanceof General) {
98                     tmpGeneral = (General) coRoutingOrGeneral;
99                     if (tmpGeneral  !=  null) {
100                         Diversity tmpDiversity =  tmpGeneral.getDiversity();
101                         if (tmpDiversity  !=  null) {
102                             finalGeneral.setDiversity(
103                                     new DiversityBuilder()
104                                         .setExistingService(tmpDiversity.getExistingService())
105                                         .setExistingServiceApplicability(
106                                                 new ExistingServiceApplicabilityBuilder()
107                                                 .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
108                                                 .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
109                                                 .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
110                                                 .build())
111                                         .build());
112                         }
113                         Exclude tmpExclude = tmpGeneral.getExclude();
114                         if (tmpExclude  !=  null) {
115                             finalGeneral.setExclude(
116                                     new ExcludeBuilder()
117                                         .setSupportingServiceName(tmpExclude.getSupportingServiceName())
118                                         .setClli(tmpExclude.getSite())
119                                         .setNodeId(tmpExclude.getNodeId())
120                                         //.setAffinity(value)
121                                         //.setSRLG(value)
122                                         .build());
123                         }
124                         Include tmpInclude = tmpGeneral.getInclude();
125                         if (tmpInclude  !=  null) {
126                             finalGeneral.setInclude(
127                                     new IncludeBuilder()
128                                         //.setOrderedHops()
129                                         .build());
130                         }
131                         Latency tmpLatency = tmpGeneral.getLatency();
132                         if (tmpLatency != null) {
133                             finalGeneral.setLatency(
134                                     new LatencyBuilder()
135                                         .setMaxLatency(tmpLatency.getMaxLatency())
136                                         .build());
137                         }
138                     }
139                     tempHard
140                         .setCoRoutingOrGeneral(finalGeneral.build())
141                         .setCustomerCode(serviceHardConstraints.getCustomerCode());
142                 } else if (coRoutingOrGeneral instanceof CoRouting) {
143                     tmpCoRouting = (CoRouting)coRoutingOrGeneral;
144                     if (tmpCoRouting  !=  null) {
145                         org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
146                             .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
147                             tmpCoRouting.getCoRouting();
148                         if (tmpCoRoutingCoRouting  !=  null) {
149                             finalCoRouting.setCoRouting(
150                                     new CoRoutingBuilder()
151                                         .setExistingService(tmpCoRoutingCoRouting.getExistingService())
152                                         .build());
153                         }
154                     }
155                     tempHard
156                         .setCoRoutingOrGeneral(finalCoRouting.build())
157                         .setCustomerCode(serviceHardConstraints.getCustomerCode());
158
159                 }
160             }
161             servicePathHardConstraints = tempHard.build();
162         } else if (serviceSoftConstraints  !=  null) {
163             SoftConstraintsBuilder tempSoft = new SoftConstraintsBuilder();
164             coRoutingOrGeneral = serviceSoftConstraints.getCoRoutingOrGeneral();
165             General tmpGeneral = null;
166             CoRouting tmpCoRouting = null;
167             if (coRoutingOrGeneral  !=  null) {
168                 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
169                     .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
170                     new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
171                     .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder();
172                 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
173                     .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
174                     new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
175                     .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder();
176                 if (coRoutingOrGeneral instanceof General) {
177                     tmpGeneral = (General) coRoutingOrGeneral;
178                     if (tmpGeneral  !=  null) {
179                         Diversity tmpDiversity =  tmpGeneral.getDiversity();
180                         if (tmpDiversity  !=  null) {
181                             finalGeneral.setDiversity(
182                                     new DiversityBuilder()
183                                         .setExistingService(tmpDiversity.getExistingService())
184                                         .setExistingServiceApplicability(
185                                                 new ExistingServiceApplicabilityBuilder()
186                                                 .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
187                                                 .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
188                                                 .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
189                                                 .build())
190                                         .build());
191                         }
192                         Exclude tmpExclude = tmpGeneral.getExclude();
193                         if (tmpExclude  !=  null) {
194                             finalGeneral.setExclude(
195                                     new ExcludeBuilder()
196                                         .setSupportingServiceName(tmpExclude.getSupportingServiceName())
197                                         .setClli(tmpExclude.getSite())
198                                         .setNodeId(tmpExclude.getNodeId())
199                                         //.setAffinity(value)
200                                         //.setSRLG(value)
201                                         .build());
202                         }
203                         Include tmpInclude = tmpGeneral.getInclude();
204                         if (tmpInclude  !=  null) {
205                             finalGeneral.setInclude(
206                                     new IncludeBuilder()
207                                         //.setOrderedHops()
208                                         .build());
209                         }
210                         Latency tmpLatency = tmpGeneral.getLatency();
211                         if (tmpLatency  !=  null) {
212                             finalGeneral.setLatency(
213                                     new LatencyBuilder()
214                                         .setMaxLatency(tmpLatency.getMaxLatency())
215                                         .build());
216                         }
217                     }
218                     tempSoft
219                         .setCoRoutingOrGeneral(finalGeneral.build())
220                         .setCustomerCode(serviceSoftConstraints.getCustomerCode());
221                 } else if (coRoutingOrGeneral instanceof CoRouting) {
222                     tmpCoRouting = (CoRouting)coRoutingOrGeneral;
223                     if (tmpCoRouting != null) {
224                         org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
225                             .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
226                             tmpCoRouting.getCoRouting();
227                         if (tmpCoRoutingCoRouting != null) {
228                             finalCoRouting.setCoRouting(
229                                     new CoRoutingBuilder()
230                                         .setExistingService(tmpCoRoutingCoRouting.getExistingService())
231                                         .build());
232                         }
233                     }
234                     tempSoft
235                         .setCoRoutingOrGeneral(finalCoRouting.build())
236                         .setCustomerCode(serviceSoftConstraints.getCustomerCode());
237
238                 }
239             }
240             servicePathSoftConstraints = tempSoft.build();
241         }
242     }
243
244
245     public HardConstraints getServiceHardConstraints() {
246         return serviceHardConstraints;
247     }
248
249
250     public void setServiceHardConstraints(HardConstraints serviceHardConstraints) {
251         this.serviceHardConstraints = serviceHardConstraints;
252     }
253
254
255     public SoftConstraints getServiceSoftConstraints() {
256         return serviceSoftConstraints;
257     }
258
259
260     public void setServiceSoftConstraints(SoftConstraints serviceSoftConstraints) {
261         this.serviceSoftConstraints = serviceSoftConstraints;
262     }
263
264
265     public org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
266         .routing.constraints.rev170426.routing.constraints.sp.HardConstraints getServicePathHardConstraints() {
267         return servicePathHardConstraints;
268     }
269
270
271     public void setServicePathHardConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
272             .routing.constraints.rev170426.routing.constraints.sp.HardConstraints servicePathHardConstraints) {
273         this.servicePathHardConstraints = servicePathHardConstraints;
274     }
275
276
277     public org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
278         .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints getServicePathSoftConstraints() {
279         return servicePathSoftConstraints;
280     }
281
282
283     public void setServicePathSoftConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
284             .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints servicePathSoftConstraints) {
285         this.servicePathSoftConstraints = servicePathSoftConstraints;
286     }
287
288 }