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;
51 * MappingConstraints class constructor
52 * for hard/soft from service 1.2.
54 * @param hard HardConstraints
55 * @param soft SoftConstraints
57 public MappingConstraints(HardConstraints hard, SoftConstraints soft) {
58 setServiceHardConstraints(hard);
59 setServiceSoftConstraints(soft);
63 * MappingConstraints class constructor
64 * for hard/soft from servicePath 1.4.
66 * @param hard HardConstraints
67 * @param soft SoftConstraints
69 public MappingConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
70 .routing.constraints.rev170426.routing.constraints.sp.HardConstraints hard,
71 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
72 .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints soft) {
73 setServicePathHardConstraints(hard);
74 setServicePathSoftConstraints(soft);
78 * map hard/soft constraints from Service 1.2
81 public void serviceToServicePathConstarints() {
82 LOG.info("Mapping Service Constraints to ServicePath Constraints");
83 CoRoutingOrGeneral coRoutingOrGeneral = null;
84 if (serviceHardConstraints != null) {
85 HardConstraintsBuilder tempHard = new HardConstraintsBuilder();
86 coRoutingOrGeneral = serviceHardConstraints.getCoRoutingOrGeneral();
87 General tmpGeneral = null;
88 CoRouting tmpCoRouting = null;
89 if (coRoutingOrGeneral != null) {
90 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
91 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
92 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
93 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder();
94 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
95 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
96 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
97 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder();
98 if (coRoutingOrGeneral instanceof General) {
99 tmpGeneral = (General) coRoutingOrGeneral;
100 if (tmpGeneral != null) {
101 Diversity tmpDiversity = tmpGeneral.getDiversity();
102 if (tmpDiversity != null) {
103 finalGeneral.setDiversity(
104 new DiversityBuilder()
105 .setExistingService(tmpDiversity.getExistingService())
106 .setExistingServiceApplicability(
107 new ExistingServiceApplicabilityBuilder()
108 .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
109 .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
110 .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
114 Exclude tmpExclude = tmpGeneral.getExclude();
115 if (tmpExclude != null) {
116 finalGeneral.setExclude(
118 .setSupportingServiceName(tmpExclude.getSupportingServiceName())
119 .setClli(tmpExclude.getSite())
120 .setNodeId(tmpExclude.getNodeId())
121 //.setAffinity(value)
125 Include tmpInclude = tmpGeneral.getInclude();
126 if (tmpInclude != null) {
127 finalGeneral.setInclude(
132 Latency tmpLatency = tmpGeneral.getLatency();
133 if (tmpLatency != null) {
134 finalGeneral.setLatency(
136 .setMaxLatency(tmpLatency.getMaxLatency())
141 .setCoRoutingOrGeneral(finalGeneral.build())
142 .setCustomerCode(serviceHardConstraints.getCustomerCode());
143 } else if (coRoutingOrGeneral instanceof CoRouting) {
144 tmpCoRouting = (CoRouting)coRoutingOrGeneral;
145 if (tmpCoRouting != null) {
146 org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
147 .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
148 tmpCoRouting.getCoRouting();
149 if (tmpCoRoutingCoRouting != null) {
150 finalCoRouting.setCoRouting(
151 new CoRoutingBuilder()
152 .setExistingService(tmpCoRoutingCoRouting.getExistingService())
157 .setCoRoutingOrGeneral(finalCoRouting.build())
158 .setCustomerCode(serviceHardConstraints.getCustomerCode());
162 servicePathHardConstraints = tempHard.build();
163 } else if (serviceSoftConstraints != null) {
164 SoftConstraintsBuilder tempSoft = new SoftConstraintsBuilder();
165 coRoutingOrGeneral = serviceSoftConstraints.getCoRoutingOrGeneral();
166 General tmpGeneral = null;
167 CoRouting tmpCoRouting = null;
168 if (coRoutingOrGeneral != null) {
169 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
170 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
171 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
172 .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder();
173 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
174 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
175 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
176 .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder();
177 if (coRoutingOrGeneral instanceof General) {
178 tmpGeneral = (General) coRoutingOrGeneral;
179 if (tmpGeneral != null) {
180 Diversity tmpDiversity = tmpGeneral.getDiversity();
181 if (tmpDiversity != null) {
182 finalGeneral.setDiversity(
183 new DiversityBuilder()
184 .setExistingService(tmpDiversity.getExistingService())
185 .setExistingServiceApplicability(
186 new ExistingServiceApplicabilityBuilder()
187 .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
188 .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
189 .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
193 Exclude tmpExclude = tmpGeneral.getExclude();
194 if (tmpExclude != null) {
195 finalGeneral.setExclude(
197 .setSupportingServiceName(tmpExclude.getSupportingServiceName())
198 .setClli(tmpExclude.getSite())
199 .setNodeId(tmpExclude.getNodeId())
200 //.setAffinity(value)
204 Include tmpInclude = tmpGeneral.getInclude();
205 if (tmpInclude != null) {
206 finalGeneral.setInclude(
211 Latency tmpLatency = tmpGeneral.getLatency();
212 if (tmpLatency != null) {
213 finalGeneral.setLatency(
215 .setMaxLatency(tmpLatency.getMaxLatency())
220 .setCoRoutingOrGeneral(finalGeneral.build())
221 .setCustomerCode(serviceSoftConstraints.getCustomerCode());
222 } else if (coRoutingOrGeneral instanceof CoRouting) {
223 tmpCoRouting = (CoRouting)coRoutingOrGeneral;
224 if (tmpCoRouting != null) {
225 org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
226 .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
227 tmpCoRouting.getCoRouting();
228 if (tmpCoRoutingCoRouting != null) {
229 finalCoRouting.setCoRouting(
230 new CoRoutingBuilder()
231 .setExistingService(tmpCoRoutingCoRouting.getExistingService())
236 .setCoRoutingOrGeneral(finalCoRouting.build())
237 .setCustomerCode(serviceSoftConstraints.getCustomerCode());
241 servicePathSoftConstraints = tempSoft.build();
246 public HardConstraints getServiceHardConstraints() {
247 return serviceHardConstraints;
251 public void setServiceHardConstraints(HardConstraints serviceHardConstraints) {
252 this.serviceHardConstraints = serviceHardConstraints;
256 public SoftConstraints getServiceSoftConstraints() {
257 return serviceSoftConstraints;
261 public void setServiceSoftConstraints(SoftConstraints serviceSoftConstraints) {
262 this.serviceSoftConstraints = serviceSoftConstraints;
266 public org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
267 .routing.constraints.rev170426.routing.constraints.sp.HardConstraints getServicePathHardConstraints() {
268 return servicePathHardConstraints;
272 public void setServicePathHardConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
273 .routing.constraints.rev170426.routing.constraints.sp.HardConstraints servicePathHardConstraints) {
274 this.servicePathHardConstraints = servicePathHardConstraints;
278 public org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
279 .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints getServicePathSoftConstraints() {
280 return servicePathSoftConstraints;
284 public void setServicePathSoftConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
285 .routing.constraints.rev170426.routing.constraints.sp.SoftConstraints servicePathSoftConstraints) {
286 this.servicePathSoftConstraints = servicePathSoftConstraints;