2 * Copyright © 2017 Orange, Inc. and others. All rights reserved.
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
10 package org.opendaylight.transportpce.servicehandler;
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.Constraints;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.CoRoutingOrGeneral;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.CoRouting;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.General;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.general.Diversity;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.general.Exclude;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.general.Include;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.general.Latency;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraints;
21 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints;
22 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.ConstraintsSp;
23 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.co.routing.CoRoutingBuilder;
24 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.DiversityBuilder;
25 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.ExcludeBuilder;
26 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.IncludeBuilder;
27 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.LatencyBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.diversity.existing.service.contraints.sp.ExistingServiceApplicabilityBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.HardConstraintsBuilder;
30 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.SoftConstraintsBuilder;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
36 * Hard/soft constraint from Service 1.2
38 * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
41 public class MappingConstraints {
43 private static final Logger LOG = LoggerFactory.getLogger(MappingConstraints.class);
44 private HardConstraints serviceHardConstraints;
45 private SoftConstraints serviceSoftConstraints;
46 private org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
47 .routing.constraints.rev170426.routing.constraints.sp.HardConstraints servicePathHardConstraints;
48 private org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
49 .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints servicePathSoftConstraints;
52 * MappingConstraints class constructor
53 * for hard/soft from service 1.2.
55 * @param hard HardConstraints
56 * @param soft SoftConstraints
58 public MappingConstraints(HardConstraints hard, SoftConstraints soft) {
59 setServiceHardConstraints(hard);
60 setServiceSoftConstraints(soft);
64 * MappingConstraints class constructor
65 * for hard/soft from servicePath 1.4.
67 * @param hard HardConstraints
68 * @param soft SoftConstraints
70 public MappingConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
71 .routing.constraints.rev170426.routing.constraints.sp.HardConstraints hard,
72 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
73 .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints soft) {
74 setServicePathHardConstraints(hard);
75 setServicePathSoftConstraints(soft);
79 *get all constraints informations
80 *from service constraints to map to
81 *servicePath constraints.
83 * @param input HardConstraints or SoftConstraints
84 * @return ConstraintsSp HardConstraintsSp or HardConstraintsSp
86 private <T> ConstraintsSp getConstraints(T input) {
87 CoRoutingOrGeneral coRoutingOrGeneral = null;
88 HardConstraintsBuilder tempHard = new HardConstraintsBuilder();
89 SoftConstraintsBuilder tempSoft = new SoftConstraintsBuilder();
90 if (input != null && input instanceof Constraints) {
91 Constraints constraints = (Constraints)input;
92 coRoutingOrGeneral = constraints.getCoRoutingOrGeneral();
93 General tmpGeneral = null;
94 CoRouting tmpCoRouting = null;
95 if (coRoutingOrGeneral != null) {
96 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
97 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
98 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
99 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder();
100 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
101 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
102 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
103 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder();
104 if (coRoutingOrGeneral instanceof General) {
105 tmpGeneral = (General) coRoutingOrGeneral;
106 if (tmpGeneral != null) {
107 Diversity tmpDiversity = tmpGeneral.getDiversity();
108 if (tmpDiversity != null) {
109 finalGeneral.setDiversity(
110 new DiversityBuilder()
111 .setExistingService(tmpDiversity.getExistingService())
112 .setExistingServiceApplicability(
113 new ExistingServiceApplicabilityBuilder()
114 .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
115 .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
116 .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
120 Exclude tmpExclude = tmpGeneral.getExclude();
121 if (tmpExclude != null) {
122 finalGeneral.setExclude(
124 .setSupportingServiceName(tmpExclude.getSupportingServiceName())
125 .setClli(tmpExclude.getSite())
126 .setNodeId(tmpExclude.getNodeId())
127 //.setAffinity(value)
131 Include tmpInclude = tmpGeneral.getInclude();
132 if (tmpInclude != null) {
133 finalGeneral.setInclude(
138 Latency tmpLatency = tmpGeneral.getLatency();
139 if (tmpLatency != null) {
140 finalGeneral.setLatency(
142 .setMaxLatency(tmpLatency.getMaxLatency())
146 tempHard.setCoRoutingOrGeneral(finalGeneral.build())
147 .setCustomerCode(constraints.getCustomerCode());
148 tempSoft.setCoRoutingOrGeneral(finalGeneral.build())
149 .setCustomerCode(constraints.getCustomerCode());
150 } else if (coRoutingOrGeneral instanceof CoRouting) {
151 tmpCoRouting = (CoRouting)coRoutingOrGeneral;
152 if (tmpCoRouting != null) {
153 org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
154 .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
155 tmpCoRouting.getCoRouting();
156 if (tmpCoRoutingCoRouting != null) {
157 finalCoRouting.setCoRouting(
158 new CoRoutingBuilder()
159 .setExistingService(tmpCoRoutingCoRouting.getExistingService())
163 tempHard.setCoRoutingOrGeneral(finalCoRouting.build())
164 .setCustomerCode(constraints.getCustomerCode());
165 tempSoft.setCoRoutingOrGeneral(finalCoRouting.build())
166 .setCustomerCode(constraints.getCustomerCode());
170 if (input instanceof HardConstraints) {
171 return tempHard.build();
172 } else if (input instanceof SoftConstraints) {
173 return tempSoft.build();
180 * map hard/soft constraints from Service 1.2
181 * to ServicePath 1.4.
183 public void serviceToServicePathConstarints() {
184 LOG.info("Mapping Service Constraints to ServicePath Constraints");
185 //CoRoutingOrGeneral coRoutingOrGeneral = null;
186 if (serviceHardConstraints != null) {
187 /*HardConstraintsBuilder tempHard = new HardConstraintsBuilder();
188 coRoutingOrGeneral = serviceHardConstraints.getCoRoutingOrGeneral();
189 General tmpGeneral = null;
190 CoRouting tmpCoRouting = null;
191 if (coRoutingOrGeneral != null) {
192 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
193 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
194 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
195 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder();
196 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
197 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
198 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
199 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder();
200 if (coRoutingOrGeneral instanceof General) {
201 tmpGeneral = (General) coRoutingOrGeneral;
202 if (tmpGeneral != null) {
203 Diversity tmpDiversity = tmpGeneral.getDiversity();
204 if (tmpDiversity != null) {
205 finalGeneral.setDiversity(
206 new DiversityBuilder()
207 .setExistingService(tmpDiversity.getExistingService())
208 .setExistingServiceApplicability(
209 new ExistingServiceApplicabilityBuilder()
210 .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
211 .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
212 .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
216 Exclude tmpExclude = tmpGeneral.getExclude();
217 if (tmpExclude != null) {
218 finalGeneral.setExclude(
220 .setSupportingServiceName(tmpExclude.getSupportingServiceName())
221 .setClli(tmpExclude.getSite())
222 .setNodeId(tmpExclude.getNodeId())
223 //.setAffinity(value)
227 Include tmpInclude = tmpGeneral.getInclude();
228 if (tmpInclude != null) {
229 finalGeneral.setInclude(
234 Latency tmpLatency = tmpGeneral.getLatency();
235 if (tmpLatency != null) {
236 finalGeneral.setLatency(
238 .setMaxLatency(tmpLatency.getMaxLatency())
243 .setCoRoutingOrGeneral(finalGeneral.build())
244 .setCustomerCode(serviceHardConstraints.getCustomerCode());
245 } else if (coRoutingOrGeneral instanceof CoRouting) {
246 tmpCoRouting = (CoRouting)coRoutingOrGeneral;
247 if (tmpCoRouting != null) {
248 org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
249 .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
250 tmpCoRouting.getCoRouting();
251 if (tmpCoRoutingCoRouting != null) {
252 finalCoRouting.setCoRouting(
253 new CoRoutingBuilder()
254 .setExistingService(tmpCoRoutingCoRouting.getExistingService())
259 .setCoRoutingOrGeneral(finalCoRouting.build())
260 .setCustomerCode(serviceHardConstraints.getCustomerCode());
264 servicePathHardConstraints = tempHard.build();*/
266 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
267 .rev170426.routing.constraints.sp.HardConstraints tempHard = (org.opendaylight.yang.gen
268 .v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing
269 .constraints.sp.HardConstraints) getConstraints(serviceHardConstraints);
270 if (tempHard != null) {
271 servicePathHardConstraints = tempHard;
273 } else if (serviceSoftConstraints != null) {
274 /*oftConstraintsBuilder tempSoft = new SoftConstraintsBuilder();
275 coRoutingOrGeneral = serviceSoftConstraints.getCoRoutingOrGeneral();
276 General tmpGeneral = null;
277 CoRouting tmpCoRouting = null;
278 if (coRoutingOrGeneral != null) {
279 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
280 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
281 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
282 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder();
283 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
284 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
285 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
286 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder();
287 if (coRoutingOrGeneral instanceof General) {
288 tmpGeneral = (General) coRoutingOrGeneral;
289 if (tmpGeneral != null) {
290 Diversity tmpDiversity = tmpGeneral.getDiversity();
291 if (tmpDiversity != null) {
292 finalGeneral.setDiversity(
293 new DiversityBuilder()
294 .setExistingService(tmpDiversity.getExistingService())
295 .setExistingServiceApplicability(
296 new ExistingServiceApplicabilityBuilder()
297 .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
298 .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
299 .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
303 Exclude tmpExclude = tmpGeneral.getExclude();
304 if (tmpExclude != null) {
305 finalGeneral.setExclude(
307 .setSupportingServiceName(tmpExclude.getSupportingServiceName())
308 .setClli(tmpExclude.getSite())
309 .setNodeId(tmpExclude.getNodeId())
310 //.setAffinity(value)
314 Include tmpInclude = tmpGeneral.getInclude();
315 if (tmpInclude != null) {
316 finalGeneral.setInclude(
321 Latency tmpLatency = tmpGeneral.getLatency();
322 if (tmpLatency != null) {
323 finalGeneral.setLatency(
325 .setMaxLatency(tmpLatency.getMaxLatency())
330 .setCoRoutingOrGeneral(finalGeneral.build())
331 .setCustomerCode(serviceSoftConstraints.getCustomerCode());
332 } else if (coRoutingOrGeneral instanceof CoRouting) {
333 tmpCoRouting = (CoRouting)coRoutingOrGeneral;
334 if (tmpCoRouting != null) {
335 org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
336 .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
337 tmpCoRouting.getCoRouting();
338 if (tmpCoRoutingCoRouting != null) {
339 finalCoRouting.setCoRouting(
340 new CoRoutingBuilder()
341 .setExistingService(tmpCoRoutingCoRouting.getExistingService())
346 .setCoRoutingOrGeneral(finalCoRouting.build())
347 .setCustomerCode(serviceSoftConstraints.getCustomerCode());
351 servicePathSoftConstraints = tempSoft.build();*/
352 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
353 .rev170426.routing.constraints.sp.SoftConstraints tempSoft = (org.opendaylight.yang.gen
354 .v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing
355 .constraints.sp.SoftConstraints) getConstraints(serviceSoftConstraints);
356 if (tempSoft != null) {
357 servicePathSoftConstraints = tempSoft;
363 public HardConstraints getServiceHardConstraints() {
364 return serviceHardConstraints;
368 public void setServiceHardConstraints(HardConstraints serviceHardConstraints) {
369 this.serviceHardConstraints = serviceHardConstraints;
373 public SoftConstraints getServiceSoftConstraints() {
374 return serviceSoftConstraints;
378 public void setServiceSoftConstraints(SoftConstraints serviceSoftConstraints) {
379 this.serviceSoftConstraints = serviceSoftConstraints;
383 public org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
384 .routing.constraints.rev170426.routing.constraints.sp.HardConstraints getServicePathHardConstraints() {
385 return servicePathHardConstraints;
389 public void setServicePathHardConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
390 .routing.constraints.rev170426.routing.constraints.sp.HardConstraints servicePathHardConstraints) {
391 this.servicePathHardConstraints = servicePathHardConstraints;
395 public org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
396 .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints getServicePathSoftConstraints() {
397 return servicePathSoftConstraints;
401 public void setServicePathSoftConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
402 .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints servicePathSoftConstraints) {
403 this.servicePathSoftConstraints = servicePathSoftConstraints;