Added Inventory Reader for SwitchManager
[controller.git] / opendaylight / md-sal / compatibility / inventory-topology-compatibility / src / main / java / org / opendaylight / controller / md / compatibility / topology / TopologyMapping.xtend
index 2ae74de..5a4aae3 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.LinkId
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Node
-
+import org.opendaylight.controller.sal.compatibility.InventoryMapping
 class TopologyMapping {
 
     new(TopologyKey path, InstanceIdentifier<Topology> key) {
@@ -29,32 +29,32 @@ class TopologyMapping {
     def Edge toAdTopologyEdge(InstanceIdentifier<Link> identifier) {
         val linkKey = (identifier.path.last as IdentifiableItem<Link,LinkKey>).key;
         val components = linkKey.linkId.value.split("::::");
-        val tail = nodeConnectorFromString(components.get(0).split("::"));
-        val head = nodeConnectorFromString(components.get(1).split("::"));
+        val tail = InventoryMapping.nodeConnectorFromId(components.get(0));
+        val head = InventoryMapping.nodeConnectorFromId(components.get(1));
         return new Edge(tail, head);
     }
 
     def NodeConnector toAdTopologyNodeConnector(InstanceIdentifier<TerminationPoint> identifier) {
         val tpKey = (identifier.path.last as IdentifiableItem<TerminationPoint,TerminationPointKey>).key;
-        return nodeConnectorFromString(tpKey.tpId.value.split("::"));
+        return InventoryMapping.nodeConnectorFromId(tpKey.tpId.value);
     }
 
     def org.opendaylight.controller.sal.core.Node toAdTopologyNode(
         InstanceIdentifier<Node> identifier) {
         val tpKey = (identifier.path.last as IdentifiableItem<Node,NodeKey>).key;
-        return nodeFromString(tpKey.nodeId.value.split("::"));
+        return InventoryMapping.nodeFromNodeId(tpKey.nodeId.value);
     }
     
 
 
     def NodeKey toTopologyNodeKey(org.opendaylight.controller.sal.core.Node node) {
-        val nodeId = new NodeId('''ad-sal:«node.type»::«node.nodeIDString»''')
+        val nodeId = new NodeId(InventoryMapping.toNodeId(node));
         return new NodeKey(nodeId);
     }
 
     def TerminationPointKey toTopologyTerminationPointKey(NodeConnector nc) {
         val node = nc.node;
-        val nodeId = new TpId('''ad-sal:«node.type»::«node.nodeIDString»::«nc.nodeConnectorIDString»''')
+        val nodeId = new TpId(InventoryMapping.toNodeConnectorId(nc))
         return new TerminationPointKey(nodeId);
     }
 
@@ -64,14 +64,4 @@ class TopologyMapping {
         val linkId = new LinkId('''«sourceTp.tpId»::::«destTp.tpId»''')
         return new LinkKey(linkId);
     }
-
-    def NodeConnector nodeConnectorFromString(String[] string) {
-        val node = nodeFromString(string.subList(0,1));
-        return NodeConnector.fromStringNoNode(string.get(2),node);
-    }
-    
-    def org.opendaylight.controller.sal.core.Node nodeFromString(String[] strings) {
-        val type = strings.get(0).substring(6);
-        org.opendaylight.controller.sal.core.Node.fromString(type,strings.get(1))
-    }
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.