use of org.onosproject.net.region.RegionId in project onos by opennetworkinglab.
the class RegionsWebResource method getRegionById.
/**
* Returns the region with the specified identifier.
*
* @param regionId region identifier
* @return 200 OK with a region, 404 not found
* @onos.rsModel Region
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{regionId}")
public Response getRegionById(@PathParam("regionId") String regionId) {
final RegionId rid = RegionId.regionId(regionId);
final Region region = nullIsNotFound(regionService.getRegion(rid), REGION_NOT_FOUND + rid.toString());
return ok(codec(Region.class).encode(region, this)).build();
}
use of org.onosproject.net.region.RegionId in project onos by opennetworkinglab.
the class UiTopoSession method navToRegion.
/**
* Navigates to the specified region by setting the associated layout as
* current.
*
* @param regionId region identifier
*/
public void navToRegion(String regionId) {
// 1. find the layout corresponding to the region ID
// 2. set this layout to be "current"
RegionId r = RegionId.regionId(regionId);
UiTopoLayout layout = layoutService.getLayout(r);
setCurrentLayout(layout);
}
use of org.onosproject.net.region.RegionId 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;
}
use of org.onosproject.net.region.RegionId in project onos by opennetworkinglab.
the class ModelCache method fixupContainmentHierarchy.
private void fixupContainmentHierarchy(UiRegion region) {
UiTopoLayoutService ls = services.layout();
RegionId regionId = region.id();
UiTopoLayout layout = ls.getLayout(regionId);
if (layout == null) {
// no layout backed by this region
log.warn("No layout backed by region {}", regionId);
return;
}
UiTopoLayoutId layoutId = layout.id();
if (!layout.isRoot()) {
UiTopoLayoutId parentId = layout.parent();
UiTopoLayout parentLayout = ls.getLayout(parentId);
RegionId parentRegionId = parentLayout.regionId();
region.setParent(parentRegionId);
}
Set<UiTopoLayout> kids = ls.getChildren(layoutId);
Set<RegionId> kidRegionIds = new HashSet<>(kids.size());
kids.forEach(k -> kidRegionIds.add(k.regionId()));
region.setChildren(kidRegionIds);
}
use of org.onosproject.net.region.RegionId 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);
}
}
Aggregations