Search in sources :

Example 6 with UiRegion

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

the class UiTopoSession method event.

@Override
public void event(UiModelEvent event) {
    // they are created
    if (event.type() == UiModelEvent.Type.DEVICE_ADDED_OR_UPDATED && event.memo().equals("added")) {
        UiRegion uiRegion = sharedModel.getRegion(currentLayout.regionId());
        uiRegion.newDeviceAdded(DeviceId.deviceId(event.subject().idAsString()));
    } else if (event.type() == UiModelEvent.Type.DEVICE_REMOVED) {
        UiRegion uiRegion = sharedModel.getRegion(currentLayout.regionId());
        uiRegion.deviceRemoved(DeviceId.deviceId(event.subject().idAsString()));
    }
    webSocket.sendMessage(TOPO2_UI_MODEL_EVENT, t2json.jsonEvent(event));
}
Also used : UiRegion(org.onosproject.ui.model.topo.UiRegion)

Example 7 with UiRegion

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

the class ModelCacheTest method addRegions.

@Test
public void addRegions() {
    title("addRegions");
    cache.addOrUpdateRegion(REGION_1);
    dispatcher.assertLast(Type.REGION_ADDED_OR_UPDATED, R1);
    dispatcher.assertEventCount(1);
    assertEquals("unex # regions", 1, cache.regionCount());
    cache.addOrUpdateRegion(REGION_2);
    dispatcher.assertLast(Type.REGION_ADDED_OR_UPDATED, R2);
    dispatcher.assertEventCount(2);
    assertEquals("unex # regions", 2, cache.regionCount());
    print(cache);
    cache.removeRegion(REGION_3);
    dispatcher.assertEventCount(2);
    assertEquals("unex # regions", 2, cache.regionCount());
    cache.removeRegion(REGION_1);
    dispatcher.assertLast(Type.REGION_REMOVED, R1);
    dispatcher.assertEventCount(3);
    assertEquals("unex # regions", 1, cache.regionCount());
    print(cache);
    UiRegion region = cache.accessRegion(REGION_2.id());
    assertEquals("wrong id", REGION_2.id(), region.id());
    assertEquals("unex # device IDs", 3, region.deviceIds().size());
    assertContains("missing ID", region.deviceIds(), DEVID_4, DEVID_5, DEVID_6);
}
Also used : UiRegion(org.onosproject.ui.model.topo.UiRegion) Test(org.junit.Test)

Example 8 with UiRegion

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

the class ModelCache method removeRegion.

// invoked from UiSharedTopologyModel region listener
void removeRegion(Region region) {
    RegionId id = region.id();
    UiRegion uiRegion = uiTopology.findRegion(id);
    if (uiRegion != null) {
        uiTopology.remove(uiRegion);
        postEvent(REGION_REMOVED, uiRegion, MEMO_REMOVED);
    } else {
        log.warn(E_NO_ELEMENT, "region", id);
    }
}
Also used : UiRegion(org.onosproject.ui.model.topo.UiRegion) RegionId(org.onosproject.net.region.RegionId)

Example 9 with UiRegion

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

the class ModelCache method addNewRegion.

// === REGIONS
private UiRegion addNewRegion(Region r) {
    UiRegion region = new UiRegion(uiTopology, r);
    uiTopology.add(region);
    log.debug("Region {} added to topology", region);
    return region;
}
Also used : UiRegion(org.onosproject.ui.model.topo.UiRegion)

Aggregations

UiRegion (org.onosproject.ui.model.topo.UiRegion)9 RegionId (org.onosproject.net.region.RegionId)3 Region (org.onosproject.net.region.Region)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 DeviceId (org.onosproject.net.DeviceId)1 HostId (org.onosproject.net.HostId)1 UiDevice (org.onosproject.ui.model.topo.UiDevice)1 UiHost (org.onosproject.ui.model.topo.UiHost)1 UiSynthLink (org.onosproject.ui.model.topo.UiSynthLink)1