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.rev171017.ConstraintsSp;
23 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.constraints.sp.co.routing.or.general.co.routing.CoRoutingBuilder;
24 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.constraints.sp.co.routing.or.general.general.DiversityBuilder;
25 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.constraints.sp.co.routing.or.general.general.ExcludeBuilder;
26 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.constraints.sp.co.routing.or.general.general.IncludeBuilder;
27 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.constraints.sp.co.routing.or.general.general.LatencyBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.diversity.existing.service.contraints.sp.ExistingServiceApplicabilityBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing.constraints.sp.HardConstraintsBuilder;
30 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.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.rev171017.routing.constraints.sp.HardConstraints servicePathHardConstraints;
48 private org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
49 .routing.constraints.rev171017.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.rev171017.routing.constraints.sp.HardConstraints hard,
72 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
73 .routing.constraints.rev171017.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 .rev171017.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
98 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
99 .rev171017.constraints.sp.co.routing.or.general.GeneralBuilder();
100 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
101 .rev171017.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
102 new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
103 .rev171017.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 if (serviceHardConstraints != null) {
186 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
187 .rev171017.routing.constraints.sp.HardConstraints tempHard = (org.opendaylight.yang.gen
188 .v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing
189 .constraints.sp.HardConstraints) getConstraints(serviceHardConstraints);
190 if (tempHard != null) {
191 servicePathHardConstraints = tempHard;
193 } else if (serviceSoftConstraints != null) {
194 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
195 .rev171017.routing.constraints.sp.SoftConstraints tempSoft = (org.opendaylight.yang.gen
196 .v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing
197 .constraints.sp.SoftConstraints) getConstraints(serviceSoftConstraints);
198 if (tempSoft != null) {
199 servicePathSoftConstraints = tempSoft;
205 public HardConstraints getServiceHardConstraints() {
206 return serviceHardConstraints;
210 public void setServiceHardConstraints(HardConstraints serviceHardConstraints) {
211 this.serviceHardConstraints = serviceHardConstraints;
215 public SoftConstraints getServiceSoftConstraints() {
216 return serviceSoftConstraints;
220 public void setServiceSoftConstraints(SoftConstraints serviceSoftConstraints) {
221 this.serviceSoftConstraints = serviceSoftConstraints;
225 public org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
226 .routing.constraints.rev171017.routing.constraints.sp.HardConstraints getServicePathHardConstraints() {
227 return servicePathHardConstraints;
231 public void setServicePathHardConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
232 .routing.constraints.rev171017.routing.constraints.sp.HardConstraints servicePathHardConstraints) {
233 this.servicePathHardConstraints = servicePathHardConstraints;
237 public org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
238 .routing.constraints.rev171017.routing.constraints.sp.SoftConstraints getServicePathSoftConstraints() {
239 return servicePathSoftConstraints;
243 public void setServicePathSoftConstraints(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
244 .routing.constraints.rev171017.routing.constraints.sp.SoftConstraints servicePathSoftConstraints) {
245 this.servicePathSoftConstraints = servicePathSoftConstraints;