/**
* Get a list of the individual 'child resources' of that autogroup.
*/
private List<AutoGroupComposite> getAutoGroupChildren(Subject subject, int parentId, int resourceTypeId) {
List<AutoGroupComposite> children = new ArrayList<AutoGroupComposite>();
ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
ResourceTypeManagerLocal resourceTypeMananger = LookupUtil.getResourceTypeManager();
Resource parentResource = resourceManager.getResourceById(subject, parentId);
ResourceType resourceType = null;
try {
resourceType = resourceTypeMananger.getResourceTypeById(subject, resourceTypeId);
} catch (ResourceTypeNotFoundException e) {
return children; // empty list if we don't know the child type
}
if ((resourceType != null) && (parentResource != null)) {
// first get the resources in the autogroup
List<ResourceWithAvailability> resourcesForAutoGroup = resourceManager.findResourcesByParentAndType(subject,
parentResource, resourceType);
int i = 0;
int[] resourceIds = new int[resourcesForAutoGroup.size()];
for (ResourceWithAvailability resourceInAutoGroup : resourcesForAutoGroup) {
int id = resourceInAutoGroup.getResource().getId();
resourceIds[i++] = id;
}
// And then the composite to return
List<AutoGroupComposite> composites = resourceManager.findResourcesAutoGroups(subject, resourceIds);
return composites;
}
return children; // empty