2 * Copyright © 2018 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
8 package org.opendaylight.transportpce.servicehandler.utils;
10 import java.util.ArrayList;
11 import java.util.Collections;
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.CoRoutingBuilder;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.GeneralBuilder;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.general.DiversityBuilder;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.general.ExcludeBuilder;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.general.IncludeBuilder;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.general.LatencyBuilder;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.diversity.existing.service.constraints.ExistingServiceApplicabilityBuilder;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.HardConstraints;
21 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.HardConstraintsBuilder;
22 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.SoftConstraints;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.SoftConstraintsBuilder;
24 import org.opendaylight.yangtools.yang.common.Uint32;
27 * Utility Class to Build Hard Constraints and Soft Constraints.
29 * @author Ahmed Helmy ( ahmad.helmy@orange.com )
32 public final class ConstraintsUtils {
34 private ConstraintsUtils() {
38 public static SoftConstraints buildSoftConstraintWithCoRouting() {
39 return new SoftConstraintsBuilder()
40 .setCoRoutingOrGeneral(new CoRoutingBuilder()
41 .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
42 .constrains.rev190329.constraints.co.routing.or.general.co.routing
43 .CoRoutingBuilder().setExistingService(
44 new ArrayList<>(Collections.singletonList("existing-service 1"))).build())
46 .setCustomerCode(new ArrayList<>(Collections.singletonList("customer-code 1")))
50 public static HardConstraints buildHardConstraintWithCoRouting() {
51 return new HardConstraintsBuilder()
52 .setCoRoutingOrGeneral(new CoRoutingBuilder()
53 .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
54 .constrains.rev190329.constraints.co.routing.or.general.co.routing
55 .CoRoutingBuilder().setExistingService(
56 new ArrayList<>(Collections.singletonList("existing-service 1"))).build())
58 .setCustomerCode(new ArrayList<>(Collections.singletonList("customer-code 1")))
62 public static HardConstraints buildHardConstraintWithGeneral() {
63 return new HardConstraintsBuilder()
64 .setCoRoutingOrGeneral(new GeneralBuilder()
65 .setExclude(new ExcludeBuilder()
67 new ArrayList<>(Collections.singletonList(new NodeIdType("Ex-Node-Id-1"))))
69 new ArrayList<>(Collections.singletonList("Ex-Fiber-Bundle 1")))
71 new ArrayList<>(Collections.singletonList("Ex-site 1")))
72 .setSupportingServiceName(
73 new ArrayList<>(Collections.singletonList("Ex-supporting-Service 1")))
75 .setInclude(new IncludeBuilder()
77 new ArrayList<>(Collections.singletonList(new NodeIdType("Inc-Node-Id-1"))))
79 new ArrayList<>(Collections.singletonList("Inc-Fiber-Bundle 1")))
80 .setSite(new ArrayList<>(Collections.singletonList("Inc-site 1")))
81 .setSupportingServiceName(
82 new ArrayList<>(Collections.singletonList("Inc-supporting-Service-name 1")))
84 .setDiversity(new DiversityBuilder()
86 new ArrayList<>(Collections.singletonList("div-existing-service 1")))
87 .setExistingServiceApplicability(new ExistingServiceApplicabilityBuilder()
88 .setNode(Boolean.TRUE)
89 .setSite(Boolean.TRUE)
90 .setSrlg(Boolean.TRUE)
93 .setLatency(new LatencyBuilder().setMaxLatency(Uint32.valueOf(1)).build())
95 .setCustomerCode(new ArrayList<>(Collections.singletonList("customer-code 1")))
99 public static HardConstraints buildHardConstraintWithNullGeneral() {
100 return new HardConstraintsBuilder()
101 .setCoRoutingOrGeneral(null)
102 .setCustomerCode(new ArrayList<>(Collections.singletonList("customer-code 1")))
106 public static SoftConstraints buildSoftConstraintWithGeneral() {
107 return new SoftConstraintsBuilder()
108 .setCoRoutingOrGeneral(new GeneralBuilder()
109 .setExclude(new ExcludeBuilder()
110 .setNodeId(new ArrayList<>())
111 .setFiberBundle(new ArrayList<>())
112 .setSite(new ArrayList<>())
113 .setSupportingServiceName(new ArrayList<>())
115 .setInclude(new IncludeBuilder()
116 .setNodeId(new ArrayList<>())
117 .setFiberBundle(new ArrayList<>())
118 .setSite(new ArrayList<>())
119 .setSupportingServiceName(new ArrayList<>())
121 .setDiversity(new DiversityBuilder()
122 .setExistingService(new ArrayList<>())
123 .setExistingServiceApplicability(new ExistingServiceApplicabilityBuilder()
127 .setCustomerCode(new ArrayList<>(Collections.singletonList("customer-code 1")))