BUG-1089: convert CompatibleTopologyManager 15/7715/4
authorRobert Varga <rovarga@cisco.com>
Wed, 4 Jun 2014 20:24:07 +0000 (22:24 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Fri, 6 Jun 2014 09:50:51 +0000 (09:50 +0000)
Converts CompatibleTopologyManager from xtend to java.

Change-Id: I2df7cdcd9dcbe4a8decaa6d197045303fa05aeee
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.xtend [deleted file]

diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.java b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.java
new file mode 100644 (file)
index 0000000..184c06e
--- /dev/null
@@ -0,0 +1,145 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.compatibility.topologymanager;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader;
+import org.opendaylight.controller.sal.core.Edge;
+import org.opendaylight.controller.sal.core.Host;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.topologymanager.ITopologyManager;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+
+@SuppressWarnings("all")
+public class CompatibleTopologyManager extends ConfigurableLinkManager implements ITopologyManager {
+    private AdSalTopologyMapping topologyMapping;
+    private TypeSafeDataReader dataReader;
+
+    public TypeSafeDataReader getDataReader() {
+        return dataReader;
+    }
+
+    public void setDataReader(final TypeSafeDataReader dataReader) {
+        this.dataReader = dataReader;
+    }
+
+    public AdSalTopologyMapping getTopologyMapping() {
+        return topologyMapping;
+    }
+
+    public void setTopologyMapping(final AdSalTopologyMapping topologyMapping) {
+        this.topologyMapping = topologyMapping;
+    }
+
+    @Override
+    public Map<Edge,Set<Property>> getEdges() {
+        final Topology topology = getDataReader().readOperationalData(topologyMapping.getTopologyPath());
+        return this.topologyMapping.toEdgePropertiesMap(topology.getLink());
+    }
+
+    @Override
+    public Map<org.opendaylight.controller.sal.core.Node, Set<Edge>> getNodeEdges() {
+        final Topology topology = getDataReader().readOperationalData(topologyMapping.getTopologyPath());
+        final HashMap<org.opendaylight.controller.sal.core.Node, Set<Edge>> ret = new HashMap<>();
+        for (final Node node : topology.getNode()) {
+            final org.opendaylight.controller.sal.core.Node adNode = topologyMapping.toAdNode(node);
+            ret.put(adNode, topologyMapping.toEdges(
+                    FluentIterable.from(topology.getLink()).filter(new Predicate<Link>() {
+                        @Override
+                        public boolean apply(final Link input) {
+                            final NodeId nodeId = node.getNodeId();
+                            if (nodeId.equals(input.getSource().getSourceNode())) {
+                                return true;
+                            }
+                            if (nodeId.equals(input.getDestination().getDestNode())) {
+                                return true;
+                            }
+
+                            return false;
+                        }
+                    })));
+        }
+        return ret;
+    }
+
+    /**
+     * Returns true if point is connected to link
+     */
+    public boolean isInternal(final TerminationPoint point) {
+        final Topology topology = getDataReader().readConfigurationData(topologyMapping.getTopologyPath());
+        final TpId tpId = point.getKey().getTpId();
+        return FluentIterable.from(topology.getLink()).anyMatch(new Predicate<Link>() {
+            @Override
+            public boolean apply(final Link input) {
+                if (tpId.equals(input.getSource().getSourceTp())) {
+                    return true;
+                }
+                if (tpId.equals(input.getDestination().getDestTp())) {
+                    return true;
+                }
+                return false;
+            }
+        });
+    }
+
+    @Override
+    public Set<NodeConnector> getNodeConnectorWithHost() {
+        return null;
+    }
+
+    @Override
+    public Host getHostAttachedToNodeConnector(final NodeConnector p) {
+        final InstanceIdentifier<TerminationPoint> tpPath = topologyMapping.toTerminationPoint(p);
+        throw new UnsupportedOperationException("TODO: auto-generated method stub");
+    }
+
+    @Override
+    public List<Host> getHostsAttachedToNodeConnector(final NodeConnector p) {
+        final Topology topology = getDataReader().readOperationalData(topologyMapping.getTopologyPath());
+        throw new UnsupportedOperationException("Hosts not mapped yet");
+    }
+
+    @Override
+    public Map<org.opendaylight.controller.sal.core.Node, Set<NodeConnector>> getNodesWithNodeConnectorHost() {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub");
+    }
+
+    @Override
+    public boolean isInternal(final NodeConnector p) {
+        final TerminationPoint connector = getDataReader()
+                .readConfigurationData(topologyMapping.toTerminationPoint(p));
+        return this.isInternal(connector);
+    }
+
+    @Override
+    public void updateHostLink(final NodeConnector p, final Host h, final UpdateType t, final Set<Property> props) {
+        // Update app defined topology
+    }
+
+    @Override
+    public Status saveConfig() {
+        // FIXME: commit configuration
+        return null;
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.xtend
deleted file mode 100644 (file)
index 4fdea4b..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.compatibility.topologymanager
-
-import org.opendaylight.controller.topologymanager.ITopologyManager
-import org.opendaylight.controller.sal.core.NodeConnector
-import org.opendaylight.controller.sal.core.Host
-import org.opendaylight.controller.sal.core.UpdateType
-import java.util.Set
-import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader
-import java.util.HashMap
-import org.opendaylight.controller.sal.core.Edge
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint
-import com.google.common.collect.FluentIterable
-
-class CompatibleTopologyManager extends ConfigurableLinkManager implements ITopologyManager {
-
-    @Property
-    var TypeSafeDataReader dataReader;
-
-    @Property
-    var extension AdSalTopologyMapping topologyMapping;
-
-    override getEdges() {
-        val topology = dataReader.readOperationalData(topologyPath);
-        return topology.link.toEdgePropertiesMap();
-    }
-
-    override getNodeEdges() {
-        val topology = dataReader.readOperationalData(topologyPath);
-        val ret = new HashMap<org.opendaylight.controller.sal.core.Node, Set<Edge>>;
-        for (node : topology.node) {
-            val adNode = node.toAdNode();
-            val adEdges = FluentIterable.from(topology.link).filter[
-                source.sourceNode == node.nodeId || destination.destNode == node.nodeId].toEdges();
-            ret.put(adNode, adEdges)
-        }
-        return ret;
-    }
-
-    /**
-     *   Returns true if point is connected to link
-    */
-    def isInternal(TerminationPoint point) {
-        val topology = dataReader.readConfigurationData(topologyPath);
-        val tpId = point.key.tpId;
-        return FluentIterable.from(topology.link).anyMatch(
-            [
-                source.sourceTp == tpId || destination.destTp == tpId
-            ])
-    }
-
-    override getNodeConnectorWithHost() {
-    }
-
-    override getHostAttachedToNodeConnector(NodeConnector p) {
-        val tpPath = p.toTerminationPoint();
-        throw new UnsupportedOperationException("TODO: auto-generated method stub")
-    }
-
-    override getHostsAttachedToNodeConnector(NodeConnector p) {
-        val topology = dataReader.readOperationalData(topologyPath);
-
-        throw new UnsupportedOperationException("Hosts not mapped yet")
-    }
-
-    override getNodesWithNodeConnectorHost() {
-        throw new UnsupportedOperationException("TODO: auto-generated method stub")
-
-    }
-
-    override isInternal(NodeConnector p) {
-        val tpPath = p.toTerminationPoint();
-        val connector = dataReader.readConfigurationData(tpPath);
-        return connector.isInternal();
-    }
-
-    override updateHostLink(NodeConnector p, Host h, UpdateType t,
-        Set<org.opendaylight.controller.sal.core.Property> props) {
-        // Update app defined topology
-    }
-
-    override saveConfig() {
-        // FIXME: commit configuration
-    }
-
-}

©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.