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
9 package org.opendaylight.transportpce.stubpce;
11 import java.util.ArrayList;
12 import java.util.List;
14 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZ;
15 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZBuilder;
16 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZKey;
17 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToA;
18 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToABuilder;
19 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToAKey;
20 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.Resource;
21 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.ResourceBuilder;
22 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.Node;
23 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.TerminationPoint;
26 * Class to create structure
31 * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on
34 public class TpNodeTp {
35 private TerminationPoint tpOut;
36 private TerminationPoint tpIn;
38 private List<Resource> resources;
39 private List<AToZ> atoz;
40 private List<ZToA> ztoa;
41 private List<String> ids;
44 * TpNodeTp Constructor.
46 * @param in TerminationPoint input
47 * @param out TerminationPoint output
50 public TpNodeTp(TerminationPoint in, TerminationPoint out, Node node) {
54 resources = new ArrayList<Resource>();
55 atoz = new ArrayList<AToZ>();
56 ztoa = new ArrayList<ZToA>();
57 ids = new ArrayList<String>();
62 * create resource List.
64 public void createListResource() {
70 resources.add(new ResourceBuilder().setResource(tpIn).build());
71 ids.add(tpIn.getTpNodeId().concat("-").concat(tpIn.getTpId()));
72 resources.add(new ResourceBuilder().setResource(node).build());
73 ids.add(node.getNodeId());
74 resources.add(new ResourceBuilder().setResource(tpOut).build());
75 ids.add(tpOut.getTpNodeId().concat("-").concat(tpOut.getTpId()));
79 * Create an hop in AtoZList.
80 * @param odr hop number
82 public void createAToZListHop(int odr) {
84 AToZKey atozKey = null;
86 for (Resource resource : resources) {
87 atozKey = new AToZKey(Integer.toString(odr));
88 resource = new ResourceBuilder().setResource(resource.getResource()).build();
89 hop = new AToZBuilder()
91 .setResource(resource)
99 * Create an hop in ZtoAList.
100 * @param odr hop number
102 public void createZToAListHop(int odr) {
104 ZToAKey ztoaKey = null;
105 createListResource();
106 for (Resource resource : resources) {
107 ztoaKey = new ZToAKey(Integer.toString(odr));
108 resource = new ResourceBuilder().setResource(resource.getResource()).build();
109 hop = new ZToABuilder()
111 .setResource(resource)
118 public TpNodeTp reverse() {
119 return new TpNodeTp(tpOut, tpIn, node);
123 public String toString() {
124 StringBuilder result = new StringBuilder("[ ");
125 result.append("tpIn : " + tpIn.getTpId());
126 result.append(" - Node : " + node.getNodeId());
127 result.append(" - tpOut : " + tpOut.getTpId());
129 return result.toString();
133 public List<AToZ> getAToZ() {
137 public List<ZToA> getZToA() {
141 public Node getNode() {
145 public TerminationPoint getTpIn() {
149 public TerminationPoint getTpOut() {