+ /**
+ *get all constraints informations
+ *from service constraints to map to
+ *servicePath constraints.
+ *
+ * @param input HardConstraints or SoftConstraints
+ * @return ConstraintsSp HardConstraintsSp or HardConstraintsSp
+ */
+ private <T> ConstraintsSp getConstraints(T input) {
+ CoRoutingOrGeneral coRoutingOrGeneral = null;
+ HardConstraintsBuilder tempHard = new HardConstraintsBuilder();
+ SoftConstraintsBuilder tempSoft = new SoftConstraintsBuilder();
+ if (input != null && input instanceof Constraints) {
+ Constraints constraints = (Constraints)input;
+ coRoutingOrGeneral = constraints.getCoRoutingOrGeneral();
+ General tmpGeneral = null;
+ CoRouting tmpCoRouting = null;
+ if (coRoutingOrGeneral != null) {
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
+ .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
+ new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
+ .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder();
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
+ .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
+ new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
+ .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder();
+ if (coRoutingOrGeneral instanceof General) {
+ tmpGeneral = (General) coRoutingOrGeneral;
+ if (tmpGeneral != null) {
+ Diversity tmpDiversity = tmpGeneral.getDiversity();
+ if (tmpDiversity != null) {
+ finalGeneral.setDiversity(
+ new DiversityBuilder()
+ .setExistingService(tmpDiversity.getExistingService())
+ .setExistingServiceApplicability(
+ new ExistingServiceApplicabilityBuilder()
+ .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
+ .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
+ .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
+ .build())
+ .build());
+ }
+ Exclude tmpExclude = tmpGeneral.getExclude();
+ if (tmpExclude != null) {
+ finalGeneral.setExclude(
+ new ExcludeBuilder()
+ .setSupportingServiceName(tmpExclude.getSupportingServiceName())
+ .setClli(tmpExclude.getSite())
+ .setNodeId(tmpExclude.getNodeId())
+ //.setAffinity(value)
+ //.setSRLG(value)
+ .build());
+ }
+ Include tmpInclude = tmpGeneral.getInclude();
+ if (tmpInclude != null) {
+ finalGeneral.setInclude(
+ new IncludeBuilder()
+ //.setOrderedHops()
+ .build());
+ }
+ Latency tmpLatency = tmpGeneral.getLatency();
+ if (tmpLatency != null) {
+ finalGeneral.setLatency(
+ new LatencyBuilder()
+ .setMaxLatency(tmpLatency.getMaxLatency())
+ .build());
+ }
+ }
+ tempHard.setCoRoutingOrGeneral(finalGeneral.build())
+ .setCustomerCode(constraints.getCustomerCode());
+ tempSoft.setCoRoutingOrGeneral(finalGeneral.build())
+ .setCustomerCode(constraints.getCustomerCode());
+ } else if (coRoutingOrGeneral instanceof CoRouting) {
+ tmpCoRouting = (CoRouting)coRoutingOrGeneral;
+ if (tmpCoRouting != null) {
+ org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
+ .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
+ tmpCoRouting.getCoRouting();
+ if (tmpCoRoutingCoRouting != null) {
+ finalCoRouting.setCoRouting(
+ new CoRoutingBuilder()
+ .setExistingService(tmpCoRoutingCoRouting.getExistingService())
+ .build());
+ }
+ }
+ tempHard.setCoRoutingOrGeneral(finalCoRouting.build())
+ .setCustomerCode(constraints.getCustomerCode());
+ tempSoft.setCoRoutingOrGeneral(finalCoRouting.build())
+ .setCustomerCode(constraints.getCustomerCode());
+ }
+ }
+ }
+ if (input instanceof HardConstraints) {
+ return tempHard.build();
+ } else if (input instanceof SoftConstraints) {
+ return tempSoft.build();
+ } else {
+ return null;
+ }
+ }
+