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;
}
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);
}
}
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);
}
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);
}
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);
}
}
Aggregations