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));
}
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);
}
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);
}
}
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;
}
Aggregations