Search in sources :

Example 41 with RepositoryManager

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);
}
Also used : ArrayList(java.util.ArrayList) RepositoryManager(org.olat.repository.RepositoryManager) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Example 42 with RepositoryManager

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);
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 43 with RepositoryManager

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);
}
Also used : ArrayList(java.util.ArrayList) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 44 with RepositoryManager

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;
}
Also used : RepositoryStatisticsVO(org.olat.restapi.system.vo.RepositoryStatisticsVO) RepositoryManager(org.olat.repository.RepositoryManager)

Example 45 with RepositoryManager

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();
    }
}
Also used : CourseVO(org.olat.restapi.support.vo.CourseVO) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseVOes(org.olat.restapi.support.vo.CourseVOes) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

RepositoryManager (org.olat.repository.RepositoryManager)136 RepositoryEntry (org.olat.repository.RepositoryEntry)122 Path (javax.ws.rs.Path)42 Identity (org.olat.core.id.Identity)32 Produces (javax.ws.rs.Produces)30 Roles (org.olat.core.id.Roles)30 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)26 ArrayList (java.util.ArrayList)20 Consumes (javax.ws.rs.Consumes)20 PUT (javax.ws.rs.PUT)18 MailPackage (org.olat.core.util.mail.MailPackage)16 GET (javax.ws.rs.GET)14 BaseSecurity (org.olat.basesecurity.BaseSecurity)14 AssertException (org.olat.core.logging.AssertException)14 SearchRepositoryEntryParameters (org.olat.repository.model.SearchRepositoryEntryParameters)14 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)12 Controller (org.olat.core.gui.control.Controller)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 UserRequest (org.olat.core.gui.UserRequest)10 WindowControl (org.olat.core.gui.control.WindowControl)10