Search in sources :

Example 6 with StringListFilter

use of org.opencastproject.index.service.resources.list.query.StringListFilter in project opencast by opencast.

the class ServiceTest method testNegativeFreetextFilter.

@Test
public void testNegativeFreetextFilter() {
    ResourceListQueryImpl query = makeQuery(new StringListFilter("doesnt exist"));
    assertFalse(service.isCompliant(query));
}
Also used : ResourceListQueryImpl(org.opencastproject.index.service.resources.list.query.ResourceListQueryImpl) StringListFilter(org.opencastproject.index.service.resources.list.query.StringListFilter) Test(org.junit.Test)

Example 7 with StringListFilter

use of org.opencastproject.index.service.resources.list.query.StringListFilter in project opencast by opencast.

the class ServiceTest method testNegativeConcreteFilter.

@Test
public void testNegativeConcreteFilter() {
    ResourceListQueryImpl query = makeQuery(new StringListFilter("name", "HOST 1"));
    assertFalse(service.isCompliant(query));
}
Also used : ResourceListQueryImpl(org.opencastproject.index.service.resources.list.query.ResourceListQueryImpl) StringListFilter(org.opencastproject.index.service.resources.list.query.StringListFilter) Test(org.junit.Test)

Example 8 with StringListFilter

use of org.opencastproject.index.service.resources.list.query.StringListFilter in project opencast by opencast.

the class ListProvidersServiceTest method testQuery.

@Test
public void testQuery() throws ListProviderException {
    ResourceListQueryImpl query = new ResourceListQueryImpl();
    final String providerName1 = "test1";
    final Map<String, String> list1 = new HashMap<String, String>();
    list1.put("1", "x test34");
    list1.put("2", "a test12");
    list1.put("3", "c ok");
    list1.put("4", "z essai test");
    listProviderService.addProvider(getResourceListProvider(providerName1, list1));
    query.setLimit(2);
    query.setOffset(1);
    Assert.assertEquals(2, listProviderService.getList(providerName1, query, null, false).size());
    query.setLimit(1);
    query.setOffset(5);
    Assert.assertEquals(0, listProviderService.getList(providerName1, query, null, false).size());
    query.setLimit(2);
    query.setOffset(1);
    Assert.assertEquals(2, listProviderService.getList(providerName1, query, null, false).size());
    query.setLimit(12);
    query.setOffset(0);
    query.addFilter(new StringListFilter(TEST_FILTER_NAME, "test"));
    Assert.assertEquals(3, listProviderService.getList(providerName1, query, null, false).size());
// query.setSortedBy(TEST_SORTBY);
// Map<String, String> list = listProviderService.getList(providerName1, query, null);
// int i = 0;
// Iterator<Entry<String, String>> iterator = list.entrySet().iterator();
// Assert.assertEquals(list1.get("2"), iterator.next().getValue());
}
Also used : HashMap(java.util.HashMap) ResourceListQueryImpl(org.opencastproject.index.service.resources.list.query.ResourceListQueryImpl) StringListFilter(org.opencastproject.index.service.resources.list.query.StringListFilter) Test(org.junit.Test)

Example 9 with StringListFilter

use of org.opencastproject.index.service.resources.list.query.StringListFilter in project opencast by opencast.

the class EndpointUtil method addRequestFiltersToQuery.

/**
 * Add the string based filters to the given list query.
 *
 * @param filterString
 *          The string based filters
 * @param query
 *          The query to update with the filters
 */
public static void addRequestFiltersToQuery(final String filterString, ResourceListQueryImpl query) {
    if (filterString != null) {
        String[] filters = filterString.split(",");
        for (String filter : filters) {
            String[] splitFilter = filter.split(":", 2);
            if (splitFilter != null && splitFilter.length == 2) {
                String key = splitFilter[0].trim();
                String value = splitFilter[1].trim();
                query.addFilter(new StringListFilter(key, value));
            }
        }
    }
}
Also used : StringListFilter(org.opencastproject.index.service.resources.list.query.StringListFilter)

Aggregations

StringListFilter (org.opencastproject.index.service.resources.list.query.StringListFilter)9 Test (org.junit.Test)7 ResourceListQueryImpl (org.opencastproject.index.service.resources.list.query.ResourceListQueryImpl)7 HashMap (java.util.HashMap)3 ArrayList (java.util.ArrayList)2 ListProviderException (org.opencastproject.index.service.exception.ListProviderException)2 JValue (com.entwinemedia.fn.data.json.JValue)1 SimpleSerializer (com.entwinemedia.fn.data.json.SimpleSerializer)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Calendar (java.util.Calendar)1 Map (java.util.Map)1 StreamingOutput (javax.ws.rs.core.StreamingOutput)1 ResourceListFilter (org.opencastproject.index.service.resources.list.api.ResourceListFilter)1 ResourceListProvider (org.opencastproject.index.service.resources.list.api.ResourceListProvider)1 ResourceListQuery (org.opencastproject.index.service.resources.list.api.ResourceListQuery)1 ListProvidersServiceImpl (org.opencastproject.index.service.resources.list.impl.ListProvidersServiceImpl)1 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)1 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)1 JaxbOrganization (org.opencastproject.security.api.JaxbOrganization)1 Organization (org.opencastproject.security.api.Organization)1