Search in sources :

Example 1 with RepositoryEntryAuthorImpl

use of org.olat.repository.model.RepositoryEntryAuthorImpl in project OpenOLAT by OpenOLAT.

the class RepositoryEntryAuthorQueries method searchViews.

public List<RepositoryEntryAuthorView> searchViews(SearchAuthorRepositoryEntryViewParams params, int firstResult, int maxResults) {
    if (params.getIdentity() == null) {
        log.error("No identity defined for query");
        return Collections.emptyList();
    }
    TypedQuery<Object[]> query = createViewQuery(params, Object[].class);
    query.setFirstResult(firstResult);
    if (maxResults > 0) {
        query.setMaxResults(maxResults);
    }
    List<Object[]> objects = query.getResultList();
    List<RepositoryEntryAuthorView> views = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        RepositoryEntry re = (RepositoryEntry) object[0];
        Number numOfMarks = (Number) object[1];
        boolean hasMarks = numOfMarks == null ? false : numOfMarks.longValue() > 0;
        Number numOffers = (Number) object[2];
        long offers = numOffers == null ? 0l : numOffers.longValue();
        Number numOfReferences = (Number) object[3];
        int references = numOfReferences == null ? 0 : numOfReferences.intValue();
        String deletedByName = null;
        if (params.isDeleted()) {
            Identity deletedBy = re.getDeletedBy();
            if (deletedBy != null) {
                deletedByName = userManager.getUserDisplayName(deletedBy);
            }
        }
        views.add(new RepositoryEntryAuthorImpl(re, hasMarks, offers, references, deletedByName));
    }
    return views;
}
Also used : ArrayList(java.util.ArrayList) RepositoryEntryAuthorImpl(org.olat.repository.model.RepositoryEntryAuthorImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryAuthorView(org.olat.repository.RepositoryEntryAuthorView) Identity(org.olat.core.id.Identity)

Example 2 with RepositoryEntryAuthorImpl

use of org.olat.repository.model.RepositoryEntryAuthorImpl in project openolat by klemens.

the class RepositoryEntryAuthorQueries method searchViews.

public List<RepositoryEntryAuthorView> searchViews(SearchAuthorRepositoryEntryViewParams params, int firstResult, int maxResults) {
    if (params.getIdentity() == null) {
        log.error("No identity defined for query");
        return Collections.emptyList();
    }
    TypedQuery<Object[]> query = createViewQuery(params, Object[].class);
    query.setFirstResult(firstResult);
    if (maxResults > 0) {
        query.setMaxResults(maxResults);
    }
    List<Object[]> objects = query.getResultList();
    List<RepositoryEntryAuthorView> views = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        RepositoryEntry re = (RepositoryEntry) object[0];
        Number numOfMarks = (Number) object[1];
        boolean hasMarks = numOfMarks == null ? false : numOfMarks.longValue() > 0;
        Number numOffers = (Number) object[2];
        long offers = numOffers == null ? 0l : numOffers.longValue();
        Number numOfReferences = (Number) object[3];
        int references = numOfReferences == null ? 0 : numOfReferences.intValue();
        String deletedByName = null;
        if (params.isDeleted()) {
            Identity deletedBy = re.getDeletedBy();
            if (deletedBy != null) {
                deletedByName = userManager.getUserDisplayName(deletedBy);
            }
        }
        views.add(new RepositoryEntryAuthorImpl(re, hasMarks, offers, references, deletedByName));
    }
    return views;
}
Also used : ArrayList(java.util.ArrayList) RepositoryEntryAuthorImpl(org.olat.repository.model.RepositoryEntryAuthorImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryAuthorView(org.olat.repository.RepositoryEntryAuthorView) Identity(org.olat.core.id.Identity)

Aggregations

ArrayList (java.util.ArrayList)2 Identity (org.olat.core.id.Identity)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryEntryAuthorView (org.olat.repository.RepositoryEntryAuthorView)2 RepositoryEntryAuthorImpl (org.olat.repository.model.RepositoryEntryAuthorImpl)2