ONOS-249 Added summary of flow rules for the selected device.

Change-Id: Ie2903e87e1284bc6fae49b81d9629ce913a1af99
diff --git a/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java
index 3084c5f..2c3f018 100644
--- a/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java
+++ b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java
@@ -37,6 +37,8 @@
 import org.onlab.onos.net.Link;
 import org.onlab.onos.net.device.DeviceEvent;
 import org.onlab.onos.net.device.DeviceService;
+import org.onlab.onos.net.flow.FlowEntry;
+import org.onlab.onos.net.flow.FlowRuleService;
 import org.onlab.onos.net.host.HostEvent;
 import org.onlab.onos.net.host.HostService;
 import org.onlab.onos.net.intent.Intent;
@@ -106,6 +108,7 @@
     protected final HostService hostService;
     protected final MastershipService mastershipService;
     protected final IntentService intentService;
+    protected final FlowRuleService flowService;
     protected final StatisticService statService;
 
     protected final ObjectMapper mapper = new ObjectMapper();
@@ -126,6 +129,7 @@
         hostService = directory.get(HostService.class);
         mastershipService = directory.get(MastershipService.class);
         intentService = directory.get(IntentService.class);
+        flowService = directory.get(FlowRuleService.class);
         statService = directory.get(StatisticService.class);
     }
 
@@ -412,11 +416,13 @@
     protected ObjectNode deviceDetails(DeviceId deviceId, long sid) {
         Device device = deviceService.getDevice(deviceId);
         Annotations annot = device.annotations();
+        String name = annot.value("name");
         int portCount = deviceService.getPorts(deviceId).size();
+        int flowCount = getFlowCount(deviceId);
         return envelope("showDetails", sid,
-                        json(deviceId.toString(),
+                        json(isNullOrEmpty(name) ? deviceId.toString() : name,
                              device.type().toString().toLowerCase(),
-                             new Prop("Name", annot.value("name")),
+                             new Prop("URI", deviceId.toString()),
                              new Prop("Vendor", device.manufacturer()),
                              new Prop("H/W Version", device.hwVersion()),
                              new Prop("S/W Version", device.swVersion()),
@@ -425,20 +431,34 @@
                              new Prop("Latitude", annot.value("latitude")),
                              new Prop("Longitude", annot.value("longitude")),
                              new Prop("Ports", Integer.toString(portCount)),
+                             new Prop("Flows", Integer.toString(flowCount)),
                              new Separator(),
                              new Prop("Master", master(deviceId))));
     }
 
+    protected int getFlowCount(DeviceId deviceId) {
+        int count = 0;
+        Iterator<FlowEntry> it = flowService.getFlowEntries(deviceId).iterator();
+        while (it.hasNext()) {
+            count++;
+            it.next();
+        }
+        return count;
+    }
+
     // Returns host details response.
     protected ObjectNode hostDetails(HostId hostId, long sid) {
         Host host = hostService.getHost(hostId);
         Annotations annot = host.annotations();
         String type = annot.value("type");
+        String name = annot.value("name");
+        String vlan = host.vlan().toString();
         return envelope("showDetails", sid,
-                        json(hostId.toString(), isNullOrEmpty(type) ? "host" : type,
-                             new Prop("Name", annot.value("name")),
+                        json(isNullOrEmpty(name) ? hostId.toString() : name,
+                             isNullOrEmpty(type) ? "host" : type,
                              new Prop("MAC", host.mac().toString()),
-                             new Prop("IP", host.ipAddresses().toString()),
+                             new Prop("IP", host.ipAddresses().toString().replaceAll("[\\[\\]]", "")),
+                             new Prop("VLAN", vlan.equals("-1") ? "none" : vlan),
                              new Separator(),
                              new Prop("Latitude", annot.value("latitude")),
                              new Prop("Longitude", annot.value("longitude"))));