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.getTerminationPointIdentifier().getNodeId().concat("-")
72 .concat(tpIn.getTerminationPointIdentifier().getTpId()));
73 resources.add(new ResourceBuilder().setResource(node).build());
74 ids.add(node.getNodeIdentifier().getNodeId());
75 resources.add(new ResourceBuilder().setResource(tpOut).build());
76 ids.add(tpOut.getTerminationPointIdentifier().getNodeId().concat("-")
77 .concat(tpOut.getTerminationPointIdentifier().getTpId()));
81 * Create an hop in AtoZList.
82 * @param odr hop number
84 public void createAToZListHop(int odr) {
86 AToZKey atozKey = null;
88 for (Resource resource : resources) {
89 atozKey = new AToZKey(Integer.toString(odr));
90 resource = new ResourceBuilder().setResource(resource.getResource()).build();
91 hop = new AToZBuilder()
93 .setResource(resource)
101 * Create an hop in ZtoAList.
102 * @param odr hop number
104 public void createZToAListHop(int odr) {
106 ZToAKey ztoaKey = null;
107 createListResource();
108 for (Resource resource : resources) {
109 ztoaKey = new ZToAKey(Integer.toString(odr));
110 resource = new ResourceBuilder().setResource(resource.getResource()).build();
111 hop = new ZToABuilder()
113 .setResource(resource)
120 public TpNodeTp reverse() {
121 return new TpNodeTp(tpOut, tpIn, node);
125 public String toString() {
126 StringBuilder result = new StringBuilder("[ ");
127 result.append("tpIn : " + tpIn.getTerminationPointIdentifier().getTpId());
128 result.append(" - Node : " + node.getNodeIdentifier().getNodeId());
129 result.append(" - tpOut : " + tpOut.getTerminationPointIdentifier().getTpId());
131 return result.toString();
135 public List<AToZ> getAToZ() {
139 public List<ZToA> getZToA() {
143 public Node getNode() {
147 public TerminationPoint getTpIn() {
151 public TerminationPoint getTpOut() {