Search in sources :

Example 6 with DefaultResultInfos

use of org.olat.core.commons.persistence.DefaultResultInfos in project OpenOLAT by OpenOLAT.

the class DefaultRepositoryEntryDataSource method getRows.

@Override
public final ResultInfos<RepositoryEntryRow> getRows(String query, List<FlexiTableFilter> filters, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
    if (filters != null && filters.size() > 0 && filters.get(0) != null) {
        String filter = filters.get(0).getFilter();
        if (StringHelper.containsNonWhitespace(filter)) {
            searchParams.setFilters(Collections.singletonList(Filter.valueOf(filter)));
        } else {
            searchParams.setFilters(null);
        }
    } else {
        searchParams.setFilters(null);
    }
    if (orderBy != null && orderBy.length > 0 && orderBy[0] != null) {
        OrderBy o = OrderBy.valueOf(orderBy[0].getKey());
        searchParams.setOrderBy(o);
        searchParams.setOrderByAsc(orderBy[0].isAsc());
    }
    if (StringHelper.containsNonWhitespace(query)) {
        searchParams.setIdRefsAndTitle(query);
    } else {
        searchParams.setIdRefsAndTitle(null);
    }
    List<RepositoryEntryMyView> views = repositoryService.searchMyView(searchParams, firstResult, maxResults);
    List<RepositoryEntryRow> rows = processViewModel(views);
    ResultInfos<RepositoryEntryRow> results = new DefaultResultInfos<RepositoryEntryRow>(firstResult + rows.size(), -1, rows);
    if (firstResult == 0 && views.size() < maxResults) {
        count = new Integer(views.size());
    }
    return results;
}
Also used : OrderBy(org.olat.repository.model.SearchMyRepositoryEntryViewParams.OrderBy) DefaultResultInfos(org.olat.core.commons.persistence.DefaultResultInfos) RepositoryEntryMyView(org.olat.repository.RepositoryEntryMyView)

Example 7 with DefaultResultInfos

use of org.olat.core.commons.persistence.DefaultResultInfos in project OpenOLAT by OpenOLAT.

the class QuestionPoolServiceImpl method searchByAuthor.

private ResultInfos<QuestionItemView> searchByAuthor(SearchQuestionItemParams searchParams, int firstResult, int maxResults, SortKey... orderBy) {
    Identity author = searchParams.getAuthor();
    if (searchParams.isFulltextSearch()) {
        try {
            String queryString = searchParams.getSearchString();
            List<String> condQueries = new ArrayList<String>();
            if (searchParams.getCondQueries() != null) {
                condQueries.addAll(searchParams.getCondQueries());
            }
            condQueries.add(QItemDocument.OWNER_FIELD + ":" + author.getKey());
            List<Long> results = searchClient.doSearch(queryString, condQueries, searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS);
            if (results.isEmpty()) {
                return new DefaultResultInfos<QuestionItemView>();
            }
            List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, results, firstResult, maxResults, orderBy);
            return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items);
        } catch (Exception e) {
            log.error("", e);
        }
        return new DefaultResultInfos<QuestionItemView>();
    } else {
        List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy);
        return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items);
    }
}
Also used : DefaultResultInfos(org.olat.core.commons.persistence.DefaultResultInfos) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) QuestionItemView(org.olat.modules.qpool.QuestionItemView)

Example 8 with DefaultResultInfos

use of org.olat.core.commons.persistence.DefaultResultInfos in project OpenOLAT by OpenOLAT.

the class AbstractItemListController method getRows.

@Override
public ResultInfos<ItemRow> getRows(String query, List<FlexiTableFilter> filters, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
    ResultInfos<QuestionItemView> items = itemsSource.getItems(query, condQueries, firstResult, maxResults, orderBy);
    List<ItemRow> rows = new ArrayList<>(items.getObjects().size());
    List<ResourceLicense> licenses = licenseService.loadLicenses(items.getObjects());
    for (QuestionItemView item : items.getObjects()) {
        ItemRow row = forgeRow(item, licenses);
        rows.add(row);
    }
    return new DefaultResultInfos<>(items.getNextFirstResult(), items.getCorrectedRowCount(), rows);
}
Also used : DefaultResultInfos(org.olat.core.commons.persistence.DefaultResultInfos) ArrayList(java.util.ArrayList) QuestionItemView(org.olat.modules.qpool.QuestionItemView) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 9 with DefaultResultInfos

use of org.olat.core.commons.persistence.DefaultResultInfos in project openolat by klemens.

the class AbstractItemListController method getRows.

@Override
public ResultInfos<ItemRow> getRows(String query, List<FlexiTableFilter> filters, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
    ResultInfos<QuestionItemView> items = itemsSource.getItems(query, condQueries, firstResult, maxResults, orderBy);
    List<ItemRow> rows = new ArrayList<>(items.getObjects().size());
    List<ResourceLicense> licenses = licenseService.loadLicenses(items.getObjects());
    for (QuestionItemView item : items.getObjects()) {
        ItemRow row = forgeRow(item, licenses);
        rows.add(row);
    }
    return new DefaultResultInfos<>(items.getNextFirstResult(), items.getCorrectedRowCount(), rows);
}
Also used : DefaultResultInfos(org.olat.core.commons.persistence.DefaultResultInfos) ArrayList(java.util.ArrayList) QuestionItemView(org.olat.modules.qpool.QuestionItemView) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 10 with DefaultResultInfos

use of org.olat.core.commons.persistence.DefaultResultInfos in project openolat by klemens.

the class QuestionPoolServiceImpl method searchByAuthor.

private ResultInfos<QuestionItemView> searchByAuthor(SearchQuestionItemParams searchParams, int firstResult, int maxResults, SortKey... orderBy) {
    Identity author = searchParams.getAuthor();
    if (searchParams.isFulltextSearch()) {
        try {
            String queryString = searchParams.getSearchString();
            List<String> condQueries = new ArrayList<String>();
            if (searchParams.getCondQueries() != null) {
                condQueries.addAll(searchParams.getCondQueries());
            }
            condQueries.add(QItemDocument.OWNER_FIELD + ":" + author.getKey());
            List<Long> results = searchClient.doSearch(queryString, condQueries, searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS);
            if (results.isEmpty()) {
                return new DefaultResultInfos<QuestionItemView>();
            }
            List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, results, firstResult, maxResults, orderBy);
            return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items);
        } catch (Exception e) {
            log.error("", e);
        }
        return new DefaultResultInfos<QuestionItemView>();
    } else {
        List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy);
        return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items);
    }
}
Also used : DefaultResultInfos(org.olat.core.commons.persistence.DefaultResultInfos) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) QuestionItemView(org.olat.modules.qpool.QuestionItemView)

Aggregations

DefaultResultInfos (org.olat.core.commons.persistence.DefaultResultInfos)10 ArrayList (java.util.ArrayList)4 QuestionItemView (org.olat.modules.qpool.QuestionItemView)4 RepositoryEntryMyView (org.olat.repository.RepositoryEntryMyView)4 OrderBy (org.olat.repository.model.SearchMyRepositoryEntryViewParams.OrderBy)4 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)2 Identity (org.olat.core.id.Identity)2 RepositoryEntryAuthorView (org.olat.repository.RepositoryEntryAuthorView)2 OrderBy (org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy)2 RepositoryEntryRow (org.olat.repository.ui.list.RepositoryEntryRow)2