*/
package org.opendaylight.transportpce.renderer;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import java.util.concurrent.Future;
-import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
+import org.opendaylight.transportpce.common.StringConstants;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.ServicePathInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.ServicePathInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.PathDescription;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZ;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToA;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.TerminationPoint;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.atoz.direction.AToZ;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ztoa.direction.ZToA;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.TerminationPoint;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.renderer.input.Nodes;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.renderer.input.NodesBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.renderer.input.NodesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
return cmBldr.build();
}
- public static Future<RpcResult<ServiceImplementationRequestOutput>>
- createRpcResponse(ServiceImplementationRequestOutput payload) {
+ public static ListenableFuture<RpcResult<ServiceImplementationRequestOutput>>
+ createServiceImplementationRpcResponse(ServiceImplementationRequestOutput payload) {
+ return RpcResultBuilder.success(payload).buildFuture();
+ }
+
+ public static ListenableFuture<RpcResult<ServiceDeleteOutput>>
+ createServiceDeleteRpcResponse(ServiceDeleteOutput payload) {
return RpcResultBuilder.success(payload).buildFuture();
}
while (iterator.hasNext()) {
ZToA pathDesObj = iterator.next();
resourceType = pathDesObj.getResource().getResource().getImplementedInterface().getSimpleName();
- LOG.info("Inside AtoZ {}", resourceType);
+ LOG.info("Inside ZtoA {}", resourceType);
try {
if (TERMINATION_POINT.equals(resourceType)) {
tp = (TerminationPoint) pathDesObj.getResource().getResource();
- LOG.info(" TP is {} {}", tp.getTerminationPointIdentifier().getTpId(),
- tp.getTerminationPointIdentifier().getNodeId());
- tpID = tp.getTerminationPointIdentifier().getTpId();
- nodeID = tp.getTerminationPointIdentifier().getNodeId();
+ LOG.info(" TP is {} {}", tp.getTpId(),
+ tp.getTpNodeId());
+ tpID = tp.getTpId();
+ nodeID = tp.getTpNodeId();
sortId = pathDesObj.getId();
//TODO: do not rely on ID to be in certain format
int[] pos = findTheLongestSubstring(nodeID, tpID);
//TODO: do not rely on nodeId to be integer
int id = Integer.parseInt(sortId);
- treeMap.put(id, new NodeIdPair(nodeID.substring(pos[0], pos[1]), tpID));
+ treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
} else if (resourceType.equals("Link")) {
LOG.info("The type is link");
} else {
} else if (desID == null) {
desID = values.getTpID();
NodesBuilder nb = new NodesBuilder();
- nb.setKey(new NodesKey(values.getNodeID()));
+ nb.withKey(new NodesKey(values.getNodeID()));
nb.setDestTp(desID);
nb.setSrcTp(srcID);
list.add(nb.build());
try {
if (TERMINATION_POINT.equals(resourceType)) {
tp = (TerminationPoint) pathDesObj.getResource().getResource();
- LOG.info(" TP is {} {}", tp.getTerminationPointIdentifier().getTpId(),
- tp.getTerminationPointIdentifier().getNodeId());
- tpID = tp.getTerminationPointIdentifier().getTpId();
- nodeID = tp.getTerminationPointIdentifier().getNodeId();
+ LOG.info(" TP is {} {}", tp.getTpId(),
+ tp.getTpNodeId());
+ tpID = tp.getTpId();
+ nodeID = tp.getTpNodeId();
sortId = pathDesObj.getId();
//TODO: do not rely on ID to be in certain format
if (tpID.contains("CTP") || tpID.contains("CP")) {
continue;
}
- if (!tpID.contains(OpenRoadmInterfacesImpl.TTP_TOKEN)
- && !tpID.contains(OpenRoadmInterfacesImpl.PP_TOKEN)
- && !tpID.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)
- && !tpID.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
+ if (!tpID.contains(StringConstants.TTP_TOKEN)
+ && !tpID.contains(StringConstants.PP_TOKEN)
+ && !tpID.contains(StringConstants.NETWORK_TOKEN)
+ && !tpID.contains(StringConstants.CLIENT_TOKEN)) {
continue;
}
int[] pos = findTheLongestSubstring(nodeID, tpID);
//TODO: do not rely on nodeId to be integer
int id = Integer.parseInt(sortId);
- treeMap.put(id, new NodeIdPair(nodeID.substring(pos[0], pos[1]), tpID));
+ treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
} else if (resourceType.equals("Link")) {
LOG.info("The type is link");
} else {
} else if (desID == null) {
desID = values.getTpID();
NodesBuilder nb = new NodesBuilder();
- nb.setKey(new NodesKey(values.getNodeID()));
+ nb.withKey(new NodesKey(values.getNodeID()));
nb.setDestTp(desID);
nb.setSrcTp(srcID);
list.add(nb.build());
}
public static int[] findTheLongestSubstring(String s1, String s2) {
- if (s1 == null || s2 == null) {
+ if ((s1 == null) || (s2 == null)) {
return null;
}
int[][] dp = new int[s1.length() + 1][s2.length() + 1];