Search in sources :

Example 6 with SearchResultItem

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;
}
Also used : Series(org.opencastproject.index.service.impl.index.series.Series) SearchResultItem(org.opencastproject.matterhorn.search.SearchResultItem)

Example 7 with 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;
}
Also used : SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) HashMap(java.util.HashMap) ThemeSearchQuery(org.opencastproject.index.service.impl.index.theme.ThemeSearchQuery) SearchResultItem(org.opencastproject.matterhorn.search.SearchResultItem) Theme(org.opencastproject.index.service.impl.index.theme.Theme) ListProviderException(org.opencastproject.index.service.exception.ListProviderException) SearchResult(org.opencastproject.matterhorn.search.SearchResult)

Aggregations

SearchResultItem (org.opencastproject.matterhorn.search.SearchResultItem)7 Event (org.opencastproject.index.service.impl.index.event.Event)4 Series (org.opencastproject.index.service.impl.index.series.Series)4 SeriesSearchQuery (org.opencastproject.index.service.impl.index.series.SeriesSearchQuery)3 SearchIndexException (org.opencastproject.matterhorn.search.SearchIndexException)3 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 ParseException (org.json.simple.parser.ParseException)2 IndexServiceException (org.opencastproject.index.service.exception.IndexServiceException)2 EventSearchQuery (org.opencastproject.index.service.impl.index.event.EventSearchQuery)2 ThemeSearchQuery (org.opencastproject.index.service.impl.index.theme.ThemeSearchQuery)2 SearchResult (org.opencastproject.matterhorn.search.SearchResult)2 SortCriterion (org.opencastproject.matterhorn.search.SortCriterion)2 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)2 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)2 NotFoundException (org.opencastproject.util.NotFoundException)2 RestQuery (org.opencastproject.util.doc.rest.RestQuery)2