use of org.opencastproject.matterhorn.search.SearchResultItem in project opencast by opencast.
the class TestThemesEndpoint method getSeriesSearchResultItem.
private SearchResultItem<Series> getSeriesSearchResultItem(String seriesId, String title) {
Series series = new Series(seriesId, defaultOrg.getId());
series.setTitle(title);
SearchResultItem<Series> searchResultItem = EasyMock.createNiceMock(SearchResultItem.class);
EasyMock.expect(searchResultItem.getSource()).andReturn(series);
EasyMock.expect(searchResultItem.compareTo(EasyMock.anyObject(SearchResultItem.class))).andReturn(1);
EasyMock.replay(searchResultItem);
return searchResultItem;
}
use of org.opencastproject.matterhorn.search.SearchResultItem in project opencast by opencast.
the class ThemesListProvider method getList.
@Override
public Map<String, String> getList(String listName, ResourceListQuery query, Organization organization) throws ListProviderException {
Map<String, String> list = new HashMap<String, String>();
if (NAME.equals(listName)) {
ThemeSearchQuery themeQuery = new ThemeSearchQuery(securityService.getOrganization().getId(), securityService.getUser());
themeQuery.withOffset(query.getOffset().getOrElse(0));
int limit = query.getLimit().getOrElse(Integer.MAX_VALUE - themeQuery.getOffset());
themeQuery.withLimit(limit);
themeQuery.sortByName(SearchQuery.Order.Ascending);
SearchResult<Theme> results = null;
try {
results = searchIndex.getByQuery(themeQuery);
} catch (SearchIndexException e) {
logger.error("The admin UI Search Index was not able to get the themes: {}", ExceptionUtils.getStackTrace(e));
throw new ListProviderException("No themes list for list name " + listName + " found!");
}
for (SearchResultItem<Theme> item : results.getItems()) {
Theme theme = item.getSource();
list.put(Long.toString(theme.getIdentifier()), theme.getName());
}
} else if (DESCRIPTION.equals(listName)) {
ThemeSearchQuery themeQuery = new ThemeSearchQuery(securityService.getOrganization().getId(), securityService.getUser());
themeQuery.withOffset(query.getOffset().getOrElse(0));
int limit = query.getLimit().getOrElse(Integer.MAX_VALUE - themeQuery.getOffset());
themeQuery.withLimit(limit);
themeQuery.sortByName(SearchQuery.Order.Ascending);
SearchResult<Theme> results = null;
try {
results = searchIndex.getByQuery(themeQuery);
} catch (SearchIndexException e) {
logger.error("The admin UI Search Index was not able to get the themes: {}", ExceptionUtils.getStackTrace(e));
throw new ListProviderException("No themes list for list name " + listName + " found!");
}
for (SearchResultItem<Theme> item : results.getItems()) {
Theme theme = item.getSource();
if (theme.getDescription() == null) {
theme.setDescription("");
} else {
theme.getDescription();
}
list.put(Long.toString(theme.getIdentifier()), theme.getDescription());
}
}
return list;
}
Aggregations