use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class RepositorySearchController method doSearchAllReferencables.
/**
* Implementation of referencable search: find repo entries that are
* owned by the uer or set to referencable and have at lease BA settings
* @param ureq
*/
private void doSearchAllReferencables(UserRequest ureq, String limitType, boolean updateFilters) {
searchType = SearchType.searchForm;
RepositoryManager rm = RepositoryManager.getInstance();
List<String> restrictedTypes;
if (limitType != null) {
restrictedTypes = Collections.singletonList(limitType);
} else {
Collection<String> s = searchForm.getRestrictedTypes();
restrictedTypes = (s == null) ? null : new ArrayList<String>(s);
}
Roles roles = ureq.getUserSession().getRoles();
Identity ident = ureq.getIdentity();
String name = searchForm.getDisplayName();
String author = searchForm.getAuthor();
String desc = searchForm.getDescription();
List<RepositoryEntry> entries;
if (searchForm.isAdminSearch()) {
entries = rm.queryResourcesLimitType(null, restrictedTypes, name, author, desc, true, false);
} else if (enableSearchforAllInSearchForm == Can.referenceable) {
entries = rm.queryReferencableResourcesLimitType(ident, roles, restrictedTypes, name, author, desc);
} else if (enableSearchforAllInSearchForm == Can.copyable) {
entries = rm.queryCopyableResourcesLimitType(ident, roles, restrictedTypes, name, author, desc);
} else {
entries = new ArrayList<RepositoryEntry>();
}
filterRepositoryEntries(entries);
repoTableModel.setObjects(entries);
if (updateFilters) {
updateFilters(entries, null);
}
tableCtr.modelChanged();
displaySearchResults(ureq);
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class RepositorySearchController method doSearchByOwnerLimitAccess.
/**
* Do search for all resources of a given type where identity is owner.
* @param owner
* @param access
*/
public void doSearchByOwnerLimitAccess(Identity owner) {
RepositoryManager rm = RepositoryManager.getInstance();
List<RepositoryEntry> entries = rm.queryByOwnerLimitAccess(owner, RepositoryEntry.ACC_USERS, Boolean.TRUE);
filterRepositoryEntries(entries);
repoTableModel.setObjects(entries);
tableCtr.setFilters(null, null);
tableCtr.modelChanged();
displaySearchResults(null);
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class RepositorySearchController method doSearchForCopyableResourcesLimitType.
/**
* Do search for all resources that the user can copy either because he
* is the owner of the resource or because he has author rights and the resource
* is set to at least BA in the BARG settings and the resource has the flag
* 'canCopy' set to true.
* @param owner The current identity
* @param limitTypes List of Types to limit the search
* @param roles The users roles
*/
public void doSearchForCopyableResourcesLimitType(Identity owner, String[] limitTypes, Roles roles) {
RepositoryManager rm = RepositoryManager.getInstance();
List<String> restrictedTypes = new ArrayList<String>();
if (limitTypes == null) {
restrictedTypes = null;
} else {
restrictedTypes.addAll(Arrays.asList(limitTypes));
}
List<RepositoryEntry> entries = rm.queryCopyableResourcesLimitType(owner, roles, restrictedTypes, null, null, null);
filterRepositoryEntries(entries);
repoTableModel.setObjects(entries);
tableCtr.setFilters(null, null);
tableCtr.modelChanged();
displaySearchResults(null);
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class OpenOLATStatisticsWebService method getRepositoryStatisticsVO.
private RepositoryStatisticsVO getRepositoryStatisticsVO() {
RepositoryStatisticsVO stats = new RepositoryStatisticsVO();
RepositoryManager repoMgr = CoreSpringFactory.getImpl(RepositoryManager.class);
int allCourses = repoMgr.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_OWNERS);
int publishedCourses = repoMgr.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_USERS);
stats.setCoursesCount(allCourses);
stats.setPublishedCoursesCount(publishedCourses);
return stats;
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class UserCoursesWebService method getTeachedCourses.
/**
* Retrieves the list of "My supervised courses" but limited to courses.
* @response.representation.200.qname {http://www.example.com}courseVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The courses
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_COURSEVOes}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param start The first result
* @param limit Max result
* @param httpRequest The HTTP request
* @param request The REST request
* @return The list of my supervised entries
*/
@GET
@Path("teached")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getTeachedCourses(@QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("limit") @DefaultValue("25") Integer limit, @Context HttpServletRequest httpRequest, @Context Request request) {
RepositoryManager rm = RepositoryManager.getInstance();
if (MediaTypeVariants.isPaged(httpRequest, request)) {
List<RepositoryEntry> repoEntries = rm.getLearningResourcesAsTeacher(identity, start, limit, RepositoryEntryOrder.nameAsc);
int totalCount = rm.countLearningResourcesAsTeacher(identity);
CourseVO[] vos = toCourseVo(repoEntries);
CourseVOes voes = new CourseVOes();
voes.setCourses(vos);
voes.setTotalCount(totalCount);
return Response.ok(voes).build();
} else {
List<RepositoryEntry> repoEntries = rm.getLearningResourcesAsTeacher(identity, 0, -1);
CourseVO[] vos = toCourseVo(repoEntries);
return Response.ok(vos).build();
}
}
Aggregations