Topo2: Updated collection to ignore models with the same Id

Change-Id: Ic2faadb76f865921092217bda0aac636349cc1af
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Collection.js b/web/gui/src/main/webapp/app/view/topo2/topo2Collection.js
index 1166fb8..3218988 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Collection.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Collection.js
@@ -53,6 +53,10 @@
                 return data;
             }
 
+            if (this._byId[data.id]) {
+                return this._byId[data.id];
+            }
+
             var CollectionModel = this.model;
             var model = new CollectionModel(data, this);
             model.collection = this;
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Layout.js b/web/gui/src/main/webapp/app/view/topo2/topo2Layout.js
index 97fac88..a64a75b 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Layout.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Layout.js
@@ -230,7 +230,7 @@
                         var regionLinks = t2rs.regionLinks();
 
                         this.link = this.elements.linkG.selectAll('.link')
-                            .data(regionLinks, function (d) { return d.get('key'); });
+                            .data(regionLinks, function (d) { return d.get('id'); });
 
                         // operate on entering links:
                         var entering = this.link.enter()
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Link.js b/web/gui/src/main/webapp/app/view/topo2/topo2Link.js
index eb0da8f..6954920 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Link.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Link.js
@@ -343,7 +343,7 @@
                             width = scale(label[1]);
                             break;
                         case 'portStatsBitSec':
-                            scale.domain(['Kbps', 'Mbps', 'Gbps'])
+                            scale.domain(['Kbps', 'Mbps', 'Gbps']);
                             width = scale(label[1]);
                             break;
                         case 'portStatsPktSec':
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Overlay.js b/web/gui/src/main/webapp/app/view/topo2/topo2Overlay.js
index 222e837..de85acf 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Overlay.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Overlay.js
@@ -140,12 +140,10 @@
         _.each(data.links, function (link) {
             // TODO: Inconsistent host id's (currentRegion and LinkLabel)
             var id = link.id.replace('/None/0', '/None').replace('-', '~'),
-                lab = t2rs.getLink(id);
-                // DONE: There's a bug in backend where link id is in reverse
-                //       This is fixed -- SDH
-                if (lab) {
+                nodeLink = t2rs.getLink(id);
+                if (nodeLink) {
                     t2lc.addLabel(LinkLabel, link, linkLabelsDOM, {
-                        link: lab
+                        link: nodeLink
                     });
                 }
         });
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Region.js b/web/gui/src/main/webapp/app/view/topo2/topo2Region.js
index 68b1ad1..cd4a75b 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Region.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Region.js
@@ -86,6 +86,8 @@
                     this.sortMultiLinks();
                     this.assignPeerLocations();
 
+                    // TODO: RegionLinks are dublicated in JSON Payload
+
                     this.model.set({ subregions: t2sr.createSubRegionCollection(this.regionData.subregions, this) });
                     this.model.set({ devices: t2ds.createDeviceCollection(this.regionData.devices, this) });
                     this.model.set({ hosts: t2hs.createHostCollection(this.regionData.hosts, this) });