ONOS-4326: Working on topology topo2start processing.
- Added getPeers() to UiTopoLayoutService.
- Fixed wipe-out command to leave the default layout alone.
- Fixed handling of null-region (associated with default layout).
- Added refresh() method to model cache.
- Fixed regions-topo-2 device IDs

Change-Id: Iee49b47ff6702bed9751be7b63392577422d4763
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 7f44244..5449d93 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
@@ -17,7 +17,6 @@
 package org.onosproject.ui.impl.topo;
 
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import org.onlab.osgi.ServiceDirectory;
 import org.onosproject.ui.RequestHandler;
@@ -25,9 +24,6 @@
 import org.onosproject.ui.UiMessageHandler;
 import org.onosproject.ui.impl.UiWebSocket;
 import org.onosproject.ui.model.topo.UiClusterMember;
-import org.onosproject.ui.model.topo.UiDevice;
-import org.onosproject.ui.model.topo.UiHost;
-import org.onosproject.ui.model.topo.UiLink;
 import org.onosproject.ui.model.topo.UiRegion;
 import org.onosproject.ui.model.topo.UiTopoLayout;
 import org.slf4j.Logger;
@@ -37,8 +33,6 @@
 import java.util.List;
 import java.util.Set;
 
-import static org.onosproject.ui.model.topo.UiNode.LAYER_DEFAULT;
-
 /*
  NOTES:
 
@@ -69,7 +63,6 @@
     private static final String CURRENT_LAYOUT = "topo2CurrentLayout";
     private static final String CURRENT_REGION = "topo2CurrentRegion";
     private static final String PEER_REGIONS = "topo2PeerRegions";
-    private static final String ORPHANS = "topo2Orphans";
     private static final String TOPO_START_DONE = "topo2StartDone";
 
 
@@ -109,6 +102,12 @@
 
             log.debug("topo2Start: {}", payload);
 
+            // this may be a little heavyweight, but it might be safer to do
+            //  this than make assumptions about the order in which devices
+            //  and regions are added... and thus internal linkages set up
+            //  correctly
+            topoSession.refreshModel();
+
             // this is the list of ONOS cluster members
             List<UiClusterMember> instances = topoSession.getAllInstances();
             sendMessage(ALL_INSTANCES, t2json.instances(instances));
@@ -131,14 +130,7 @@
             peersPayload.set("peers", t2json.closedRegions(peers));
             sendMessage(PEER_REGIONS, peersPayload);
 
-            // return devices, hosts, links belonging to no region
-            Set<UiDevice> oDevices = topoSession.getOrphanDevices();
-            Set<UiHost> oHosts = topoSession.getOrphanHosts();
-            Set<UiLink> oLinks = topoSession.getOrphanLinks();
-            List<String> oLayers = getOrphanLayerOrder();
-            sendMessage(ORPHANS, t2json.orphans(oDevices, oHosts, oLinks, oLayers));
-
-            // finally, tell the UI that we are done
+            // finally, tell the UI that we are done : TODO review / delete??
             sendMessage(TOPO_START_DONE, null);
 
 
@@ -154,14 +146,6 @@
 
     }
 
-    // TODO: we need to decide on how this should really get populated.
-    // For example, to be "backward compatible", this should really be
-    //  [ LAYER_OPTICAL, LAYER_PACKET, LAYER_DEFAULT ]
-    private List<String> getOrphanLayerOrder() {
-        // NOTE that LAYER_DEFAULT must always be last in the array
-        return ImmutableList.of(LAYER_DEFAULT);
-    }
-
     private final class Topo2Stop extends RequestHandler {
         private Topo2Stop() {
             super(TOPO2_STOP);