Search in sources :

Example 1 with UiNode

use of org.onosproject.ui.model.topo.UiNode in project onos by opennetworkinglab.

the class Topo2Jsonifier method splitByLayer.

// package-private for unit testing
List<Set<UiNode>> splitByLayer(List<String> layerTags, Set<? extends UiNode> nodes) {
    final int nLayers = layerTags.size();
    if (!layerTags.get(nLayers - 1).equals(LAYER_DEFAULT)) {
        throw new IllegalArgumentException(E_DEF_NOT_LAST);
    }
    List<Set<UiNode>> splitList = new ArrayList<>(layerTags.size());
    Map<String, Set<UiNode>> byLayer = new HashMap<>(layerTags.size());
    for (String tag : layerTags) {
        Set<UiNode> set = new HashSet<>();
        byLayer.put(tag, set);
        splitList.add(set);
    }
    for (UiNode n : nodes) {
        String which = n.layer();
        if (!layerTags.contains(which)) {
            which = LAYER_DEFAULT;
        }
        byLayer.get(which).add(n);
    }
    return splitList;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LayoutLocation.fromCompactListString(org.onosproject.ui.topo.LayoutLocation.fromCompactListString) UiNode(org.onosproject.ui.model.topo.UiNode) HashSet(java.util.HashSet)

Example 2 with UiNode

use of org.onosproject.ui.model.topo.UiNode in project onos by opennetworkinglab.

the class Topo2ViewMessageHandler method mkPeersMessage.

private ObjectNode mkPeersMessage(UiTopoLayout currentLayout) {
    Set<UiNode> peers = topoSession.getPeerNodes(currentLayout);
    ObjectNode peersPayload = objectNode();
    String rid = currentLayout.regionId().toString();
    peersPayload.set("peers", t2json.closedNodes(rid, peers));
    return peersPayload;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) UiNode(org.onosproject.ui.model.topo.UiNode)

Example 3 with UiNode

use of org.onosproject.ui.model.topo.UiNode in project onos by opennetworkinglab.

the class UiTopoSession method getPeerNodes.

/**
 * Returns the regions/devices that are "peers" to this region. That is,
 * based on the layout the user is viewing, all the regions/devices that
 * are associated with layouts that share the same parent layout as this
 * layout, AND that are linked to an element within this region.
 *
 * @param layout the layout being viewed
 * @return all regions/devices that are "siblings" to this layout's region
 */
public Set<UiNode> getPeerNodes(UiTopoLayout layout) {
    Set<UiNode> peers = new HashSet<>();
    // first, get the peer regions
    Set<UiTopoLayout> peerLayouts = layoutService.getPeerLayouts(layout.id());
    peerLayouts.forEach(l -> {
        RegionId peerRegion = l.regionId();
        peers.add(sharedModel.getRegion(peerRegion));
    });
    // now add the devices that reside in the parent region
    if (!layout.isRoot()) {
        UiTopoLayout parentLayout = layoutService.getLayout(layout.parent());
        peers.addAll(getRegion(parentLayout).devices());
    }
    // directly to this region by an implicit link
    return peers;
}
Also used : RegionId(org.onosproject.net.region.RegionId) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout) UiNode(org.onosproject.ui.model.topo.UiNode) HashSet(java.util.HashSet)

Aggregations

UiNode (org.onosproject.ui.model.topo.UiNode)3 HashSet (java.util.HashSet)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 RegionId (org.onosproject.net.region.RegionId)1 UiTopoLayout (org.onosproject.ui.model.topo.UiTopoLayout)1 LayoutLocation.fromCompactListString (org.onosproject.ui.topo.LayoutLocation.fromCompactListString)1