use of org.olat.resource.accesscontrol.model.ACResourceInfo in project OpenOLAT by OpenOLAT.
the class ACFrontendManager method getResourceInfos.
@Override
public List<ACResourceInfo> getResourceInfos(List<OLATResource> resources) {
if (resources == null || resources.isEmpty()) {
return Collections.emptyList();
}
List<OLATResource> groupResources = new ArrayList<OLATResource>(resources.size());
List<OLATResource> repositoryResources = new ArrayList<OLATResource>(resources.size());
for (OLATResource resource : resources) {
String resourceType = resource.getResourceableTypeName();
if ("BusinessGroup".equals(resourceType)) {
groupResources.add(resource);
} else {
repositoryResources.add(resource);
}
}
List<ACResourceInfo> resourceInfos = new ArrayList<ACResourceInfo>(resources.size());
if (!groupResources.isEmpty()) {
List<Long> groupKeys = new ArrayList<Long>(groupResources.size());
Map<Long, OLATResource> groupMapKeys = new HashMap<Long, OLATResource>(groupResources.size() * 2 + 1);
for (OLATResource groupResource : groupResources) {
groupKeys.add(groupResource.getResourceableId());
}
List<BusinessGroup> groups = businessGroupService.loadBusinessGroups(groupKeys);
for (BusinessGroup group : groups) {
ACResourceInfoImpl info = new ACResourceInfoImpl();
info.setResource(groupMapKeys.get(group.getKey()));
info.setName(group.getName());
info.setDescription(group.getDescription());
info.setResource(group.getResource());
resourceInfos.add(info);
}
}
if (!repositoryResources.isEmpty()) {
List<RepositoryEntryShort> repoEntries = repositoryManager.loadRepositoryEntryShorts(repositoryResources);
for (RepositoryEntryShort repoEntry : repoEntries) {
ACResourceInfoImpl info = new ACResourceInfoImpl();
info.setName(repoEntry.getDisplayname());
info.setDescription(((RepositoryEntryShortImpl) repoEntry).getDescription());
info.setResource(((RepositoryEntryShortImpl) repoEntry).getOlatResource());
resourceInfos.add(info);
}
}
return resourceInfos;
}
use of org.olat.resource.accesscontrol.model.ACResourceInfo in project openolat by klemens.
the class ACFrontendManager method getResourceInfos.
@Override
public List<ACResourceInfo> getResourceInfos(List<OLATResource> resources) {
if (resources == null || resources.isEmpty()) {
return Collections.emptyList();
}
List<OLATResource> groupResources = new ArrayList<OLATResource>(resources.size());
List<OLATResource> repositoryResources = new ArrayList<OLATResource>(resources.size());
for (OLATResource resource : resources) {
String resourceType = resource.getResourceableTypeName();
if ("BusinessGroup".equals(resourceType)) {
groupResources.add(resource);
} else {
repositoryResources.add(resource);
}
}
List<ACResourceInfo> resourceInfos = new ArrayList<ACResourceInfo>(resources.size());
if (!groupResources.isEmpty()) {
List<Long> groupKeys = new ArrayList<Long>(groupResources.size());
Map<Long, OLATResource> groupMapKeys = new HashMap<Long, OLATResource>(groupResources.size() * 2 + 1);
for (OLATResource groupResource : groupResources) {
groupKeys.add(groupResource.getResourceableId());
}
List<BusinessGroup> groups = businessGroupService.loadBusinessGroups(groupKeys);
for (BusinessGroup group : groups) {
ACResourceInfoImpl info = new ACResourceInfoImpl();
info.setResource(groupMapKeys.get(group.getKey()));
info.setName(group.getName());
info.setDescription(group.getDescription());
info.setResource(group.getResource());
resourceInfos.add(info);
}
}
if (!repositoryResources.isEmpty()) {
List<RepositoryEntryShort> repoEntries = repositoryManager.loadRepositoryEntryShorts(repositoryResources);
for (RepositoryEntryShort repoEntry : repoEntries) {
ACResourceInfoImpl info = new ACResourceInfoImpl();
info.setName(repoEntry.getDisplayname());
info.setDescription(((RepositoryEntryShortImpl) repoEntry).getDescription());
info.setResource(((RepositoryEntryShortImpl) repoEntry).getOlatResource());
resourceInfos.add(info);
}
}
return resourceInfos;
}
Aggregations