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.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;
34 * Hard/soft constraint from Service 1.2
36 * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
39 public class MappingConstraints {
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;
50 * MappingConstraints class constructor
51 * for hard/soft from service 1.2.
53 * @param hard HardConstraints
54 * @param soft SoftConstraints
56 public MappingConstraints(HardConstraints hard, SoftConstraints soft) {
57 setServiceHardConstraints(hard);
58 setServiceSoftConstraints(soft);
62 * MappingConstraints class constructor
63 * for hard/soft from servicePath 1.4.
65 * @param hard HardConstraints
66 * @param soft SoftConstraints
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);
77 * map hard/soft constraints from Service 1.2
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())
113 Exclude tmpExclude = tmpGeneral.getExclude();
114 if (tmpExclude != null) {
115 finalGeneral.setExclude(
117 .setSupportingServiceName(tmpExclude.getSupportingServiceName())
118 .setClli(tmpExclude.getSite())
119 .setNodeId(tmpExclude.getNodeId())
120 //.setAffinity(value)
124 Include tmpInclude = tmpGeneral.getInclude();
125 if (tmpInclude != null) {
126 finalGeneral.setInclude(
131 Latency tmpLatency = tmpGeneral.getLatency();
132 if (tmpLatency != null) {
133 finalGeneral.setLatency(
135 .setMaxLatency(tmpLatency.getMaxLatency())
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())
156 .setCoRoutingOrGeneral(finalCoRouting.build())
157 .setCustomerCode(serviceHardConstraints.getCustomerCode());
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())
192 Exclude tmpExclude = tmpGeneral.getExclude();
193 if (tmpExclude != null) {
194 finalGeneral.setExclude(
196 .setSupportingServiceName(tmpExclude.getSupportingServiceName())
197 .setClli(tmpExclude.getSite())
198 .setNodeId(tmpExclude.getNodeId())
199 //.setAffinity(value)
203 Include tmpInclude = tmpGeneral.getInclude();
204 if (tmpInclude != null) {
205 finalGeneral.setInclude(
210 Latency tmpLatency = tmpGeneral.getLatency();
211 if (tmpLatency != null) {
212 finalGeneral.setLatency(
214 .setMaxLatency(tmpLatency.getMaxLatency())
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())
235 .setCoRoutingOrGeneral(finalCoRouting.build())
236 .setCustomerCode(serviceSoftConstraints.getCustomerCode());
240 servicePathSoftConstraints = tempSoft.build();
245 public HardConstraints getServiceHardConstraints() {
246 return serviceHardConstraints;
250 public void setServiceHardConstraints(HardConstraints serviceHardConstraints) {
251 this.serviceHardConstraints = serviceHardConstraints;
255 public SoftConstraints getServiceSoftConstraints() {
256 return serviceSoftConstraints;
260 public void setServiceSoftConstraints(SoftConstraints serviceSoftConstraints) {
261 this.serviceSoftConstraints = serviceSoftConstraints;
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;
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;
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;
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;