Added endPortA/B to UiLink class.
Removed 'online' property from UiDevice, choosing to look up availability on the fly from device service.

Change-Id: Ib14ab371a11c442a30cf407f11d366271d087c68
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java
index c029c2b..c05d27b 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java
@@ -32,7 +32,6 @@
 
     private RegionId regionId;
     private NodeId masterId;
-    private boolean online;
 
     /**
      * Creates a new UI device.
@@ -63,15 +62,6 @@
         this.masterId = masterId;
     }
 
-    /**
-     * Sets a flag indicating whether the backing device is online.
-     *
-     * @param online boolen flag
-     */
-    public void setOnline(boolean online) {
-        this.online = online;
-    }
-
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(this)
@@ -136,15 +126,6 @@
     }
 
     /**
-     * Returns a boolean indicating whether the backing device is online.
-     *
-     * @return true if device is online, false otherwise
-     */
-    public boolean isOnline() {
-        return online;
-    }
-
-    /**
      * Returns the identifier for the cluster member that has
      * mastership over this device.
      *
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiDeviceLink.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiDeviceLink.java
index 4575678..3eaa827 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiDeviceLink.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiDeviceLink.java
@@ -59,6 +59,16 @@
         return deviceB + UiLinkId.ID_PORT_DELIMITER + portB;
     }
 
+    @Override
+    public String endPortA() {
+        return portA.toString();
+    }
+
+    @Override
+    public String endPortB() {
+        return portB.toString();
+    }
+
 
     @Override
     protected void destroy() {
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiEdgeLink.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiEdgeLink.java
index 909ef1a..f52fbcb 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiEdgeLink.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiEdgeLink.java
@@ -53,6 +53,13 @@
         return edgeDevice + UiLinkId.ID_PORT_DELIMITER + edgePort;
     }
 
+    // no port for end-point A
+
+    @Override
+    public String endPortB() {
+        return edgePort.toString();
+    }
+
     @Override
     protected void destroy() {
         edgeDevice = null;
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiLink.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiLink.java
index 0f65e9f..76ed5ff 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiLink.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiLink.java
@@ -96,4 +96,28 @@
      * @return end point B identifier
      */
     public abstract String endPointB();
+
+    /**
+     * Returns the port number (as a string) for end-point A, if applicable.
+     * This default implementation returns null, indicating not-applicable.
+     * Subclasses only need to override this method if end-point A has an
+     * associated port.
+     *
+     * @return port number for end-point A
+     */
+    public String endPortA() {
+        return null;
+    }
+
+    /**
+     * Returns the port number (as a string) for end-point B, if applicable.
+     * This default implementation returns null, indicating not-applicable.
+     * Subclasses only need to override this method if end-point B has an
+     * associated port.
+     *
+     * @return port number for end-point B
+     */
+    public String endPortB() {
+        return null;
+    }
 }
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionDeviceLink.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionDeviceLink.java
index f749473..e907fbc 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionDeviceLink.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionDeviceLink.java
@@ -63,6 +63,13 @@
         return device + UiLinkId.ID_PORT_DELIMITER + port;
     }
 
+    // no port for end-point A
+
+    @Override
+    public String endPortB() {
+        return port.toString();
+    }
+
     /**
      * Returns the identity of the region.
      *
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionLink.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionLink.java
index 7c3456c..45a27b9 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionLink.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionLink.java
@@ -58,6 +58,8 @@
         return regionB.id();
     }
 
+    // no ports for end-points A and B
+
     /**
      * Returns the identity of the first region.
      *
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2Jsonifier.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2Jsonifier.java
index 6f436a5..8ff3bb6 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2Jsonifier.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2Jsonifier.java
@@ -281,7 +281,7 @@
                 .put("id", device.idAsString())
                 .put("nodeType", DEVICE)
                 .put("type", device.type())
-                .put("online", device.isOnline())
+                .put("online", deviceService.isAvailable(device.id()))
                 .put("master", nullIsEmpty(device.master()))
                 .put("layer", device.layer());
 
@@ -364,11 +364,20 @@
 
     private ObjectNode json(UiSynthLink sLink) {
         UiLink uLink = sLink.link();
-        return objectNode()
+        ObjectNode data = objectNode()
                 .put("id", uLink.idAsString())
                 .put("epA", uLink.endPointA())
                 .put("epB", uLink.endPointB())
                 .put("type", uLink.type());
+        String pA = uLink.endPortA();
+        String pB = uLink.endPortB();
+        if (pA != null) {
+            data.put("portA", pA);
+        }
+        if (pB != null) {
+            data.put("portB", pB);
+        }
+        return data;
     }
 
 
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2ViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2ViewMessageHandler.java
index 0d4d6aa..c1f6e03 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2ViewMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2ViewMessageHandler.java
@@ -136,22 +136,10 @@
             peersPayload.set("peers", t2json.closedNodes(peers));
             sendMessage(PEER_REGIONS, peersPayload);
 
-            // TODO: send breadcrumb message
-
             // finally, tell the UI that we are done : TODO review / delete??
             sendMessage(TOPO_START_DONE, null);
-
-
-            // OLD CODE DID THE FOLLOWING...
-//            addListeners();
-//            sendAllInstances(null);
-//            sendAllDevices();
-//            sendAllLinks();
-//            sendAllHosts();
-//            sendTopoStartDone();
         }
 
-
     }
 
     private final class Topo2NavRegion extends RequestHandler {