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;
13 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZ;
14 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZBuilder;
15 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZKey;
16 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToA;
17 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToABuilder;
18 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToAKey;
19 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.Resource;
20 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.ResourceBuilder;
21 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.Node;
22 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.TerminationPoint;
25 * Class to create structure
30 * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on
33 public class TpNodeTp {
34 private TerminationPoint tpOut;
35 private TerminationPoint tpIn;
37 private List<Resource> resources;
38 private List<AToZ> atoz;
39 private List<ZToA> ztoa;
40 private List<String> ids;
43 * TpNodeTp Constructor.
45 * @param in TerminationPoint input
46 * @param out TerminationPoint output
49 public TpNodeTp(TerminationPoint in, TerminationPoint out, Node node) {
53 this.resources = new ArrayList<Resource>();
54 this.atoz = new ArrayList<AToZ>();
55 this.ztoa = new ArrayList<ZToA>();
56 this.ids = new ArrayList<String>();
61 * create resource List.
63 public void createListResource() {
65 this.resources.clear();
69 this.resources.add(new ResourceBuilder().setResource(this.tpIn).build());
70 this.ids.add(this.tpIn.getTerminationPointIdentifier().getNodeId().concat("-")
71 .concat(this.tpIn.getTerminationPointIdentifier().getTpId()));
72 this.resources.add(new ResourceBuilder().setResource(this.node).build());
73 this.ids.add(this.node.getNodeIdentifier().getNodeId());
74 this.resources.add(new ResourceBuilder().setResource(this.tpOut).build());
75 this.ids.add(this.tpOut.getTerminationPointIdentifier().getNodeId().concat("-")
76 .concat(this.tpOut.getTerminationPointIdentifier().getTpId()));
80 * Create an hop in AtoZList.
81 * @param odr hop number
83 public void createAToZListHop(int odr) {
85 AToZKey atozKey = null;
87 for (Resource resource : this.resources) {
88 atozKey = new AToZKey(Integer.toString(odr));
89 resource = new ResourceBuilder().setResource(resource.getResource()).build();
90 hop = new AToZBuilder()
92 .setResource(resource)
100 * Create an hop in ZtoAList.
101 * @param odr hop number
103 public void createZToAListHop(int odr) {
105 ZToAKey ztoaKey = null;
106 createListResource();
107 for (Resource resource : this.resources) {
108 ztoaKey = new ZToAKey(Integer.toString(odr));
109 resource = new ResourceBuilder().setResource(resource.getResource()).build();
110 hop = new ZToABuilder()
112 .setResource(resource)
119 public TpNodeTp reverse() {
120 return new TpNodeTp(this.tpOut, this.tpIn, this.node);
124 public String toString() {
125 StringBuilder result = new StringBuilder("[ ");
126 result.append("tpIn : " + this.tpIn.getTerminationPointIdentifier().getTpId());
127 result.append(" - Node : " + this.node.getNodeIdentifier().getNodeId());
128 result.append(" - tpOut : " + this.tpOut.getTerminationPointIdentifier().getTpId());
130 return result.toString();
134 public List<AToZ> getAToZ() {
138 public List<ZToA> getZToA() {
142 public Node getNode() {
146 public TerminationPoint getTpIn() {
150 public TerminationPoint getTpOut() {