Add "type" attributes to Topology elements

Add type attributes to Topology elements (ONOS-1575, ONOS-1391)
- add "type" as String attributes
- add "type" to JSON representation

Change-Id: I0ab790cfd18eba17e352780b336e5cd49c6fcb1e
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
index 1d5b8a6..b82c86f 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
@@ -141,6 +141,9 @@
         // FIXME should be merging, with existing attrs, etc..
         // TODO define attr name as constant somewhere.
         // TODO populate appropriate attributes.
+        linkEvent.createStringAttribute(TopologyElement.TYPE,
+                                        TopologyElement.TYPE_PACKET);
+
         linkEvent.freeze();
 
         if (!registryService.hasControl(link.getDst())) {
@@ -162,6 +165,8 @@
         // FIXME should be merging, with existing attrs, etc..
         // TODO define attr name as constant somewhere.
         // TODO populate appropriate attributes.
+        linkEvent.createStringAttribute(TopologyElement.TYPE,
+                                        TopologyElement.TYPE_PACKET);
         linkEvent.freeze();
 
         if (!registryService.hasControl(link.getDst())) {
@@ -181,6 +186,8 @@
         // FIXME should be merging, with existing attrs, etc..
         // TODO define attr name as constant somewhere.
         // TODO populate appropriate attributes.
+        portEvent.createStringAttribute(TopologyElement.TYPE,
+                                        TopologyElement.TYPE_PACKET);
         portEvent.createStringAttribute("name", port.getName());
 
         portEvent.freeze();
@@ -199,6 +206,15 @@
         final Dpid dpid = new Dpid(switchId);
 
         PortEvent portEvent = new PortEvent(dpid, new PortNumber(port.getPortNumber()));
+        // FIXME should be merging, with existing attrs, etc..
+        // TODO define attr name as constant somewhere.
+        // TODO populate appropriate attributes.
+        portEvent.createStringAttribute(TopologyElement.TYPE,
+                                        TopologyElement.TYPE_PACKET);
+        portEvent.createStringAttribute("name", port.getName());
+
+        portEvent.freeze();
+
         if (registryService.hasControl(switchId)) {
             topologyDiscoveryInterface.removePortDiscoveryEvent(portEvent);
         } else {
@@ -214,6 +230,8 @@
         // FIXME should be merging, with existing attrs, etc..
         // TODO define attr name as constant somewhere.
         // TODO populate appropriate attributes.
+        switchEvent.createStringAttribute(TopologyElement.TYPE,
+                                          TopologyElement.TYPE_PACKET);
         switchEvent.createStringAttribute("ConnectedSince",
                 sw.getConnectedSince().toString());
 
@@ -233,6 +251,8 @@
             // TODO define attr name as constant somewhere.
             // TODO populate appropriate attributes.
             portEvent.createStringAttribute("name", port.getName());
+            portEvent.createStringAttribute(TopologyElement.TYPE,
+                                            TopologyElement.TYPE_PACKET);
 
             portEvent.freeze();
             portEvents.add(portEvent);