Search in sources :

Example 6 with FilterAdapter

use of ddf.catalog.filter.FilterAdapter in project ddf by codice.

the class FilterAdapterTest method assertFilterEquals.

private void assertFilterEquals(String expected, Filter filter) {
    FilterDelegate<String> delegate = new FilterToTextDelegate();
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    String result = null;
    try {
        result = fa.adapt(filter, delegate);
    } catch (UnsupportedQueryException e) {
        fail(e.getMessage());
    }
    assertThat(result, is(expected));
}
Also used : FilterToTextDelegate(ddf.catalog.filter.delegate.FilterToTextDelegate) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Example 7 with FilterAdapter

use of ddf.catalog.filter.FilterAdapter in project ddf by codice.

the class FilterAdapterTest method assertFilterFails.

private void assertFilterFails(Filter filter) {
    FilterDelegate<String> delegate = new FilterToTextDelegate();
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    try {
        fa.adapt(filter, delegate);
        fail("Expected UnsupportedQueryException");
    } catch (UnsupportedQueryException e) {
    // pass
    }
}
Also used : FilterToTextDelegate(ddf.catalog.filter.delegate.FilterToTextDelegate) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Example 8 with FilterAdapter

use of ddf.catalog.filter.FilterAdapter in project ddf by codice.

the class CopyFilterDelegateTest method assertFilterException.

private void assertFilterException(Filter filterIn) {
    FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
    FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    // the UnsupportedQueryException thrown by the FilterAdapter.
    try {
        fa.adapt(filterIn, delegate);
        fail("Should have gotten an UnsupportedQueryException");
    } catch (UnsupportedQueryException e) {
        assertTrue(e.getCause() instanceof UnsupportedOperationException);
    }
}
Also used : Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Example 9 with FilterAdapter

use of ddf.catalog.filter.FilterAdapter in project ddf by codice.

the class CopyFilterDelegateTest method assertFilterContentsEqual.

private void assertFilterContentsEqual(Filter filterIn, Filter filterCopy) {
    FilterDelegate<String> delegate = new FilterToTextDelegate();
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    String filterInString = null;
    String filterCopyString = null;
    try {
        filterInString = fa.adapt(filterIn, delegate);
        filterCopyString = fa.adapt(filterCopy, delegate);
    } catch (UnsupportedQueryException e) {
        fail(e.getMessage());
    }
    LOGGER.debug("filterInString: {}", filterInString);
    LOGGER.debug("filterCopyString: {}", filterCopyString);
    assertNotNull(filterInString);
    assertNotNull(filterCopyString);
    assertEquals(filterInString, filterCopyString);
}
Also used : UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Example 10 with FilterAdapter

use of ddf.catalog.filter.FilterAdapter in project ddf by codice.

the class CopyFilterDelegateTest method testExcludeFilter.

@Test
public void testExcludeFilter() {
    Filter filterIn = Filter.EXCLUDE;
    FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
    FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    Filter filterCopy = null;
    try {
        filterCopy = fa.adapt(filterIn, delegate);
    } catch (UnsupportedQueryException e) {
        fail(e.getMessage());
    }
    assertNotNull(filterCopy);
    assertSame(filterIn, filterCopy);
}
Also used : Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) Test(org.junit.Test)

Aggregations

FilterAdapter (ddf.catalog.filter.FilterAdapter)13 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)10 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)8 FilterBuilder (ddf.catalog.filter.FilterBuilder)7 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)7 Test (org.junit.Test)6 Filter (org.opengis.filter.Filter)6 FilterToTextDelegate (ddf.catalog.filter.delegate.FilterToTextDelegate)2 Query (ddf.catalog.operation.Query)2 DeleteRequestImpl (ddf.catalog.operation.impl.DeleteRequestImpl)2 CatalogProvider (ddf.catalog.source.CatalogProvider)2 ArrayList (java.util.ArrayList)2 WKTReader (com.vividsolutions.jts.io.WKTReader)1 ValidationQueryFactory (ddf.catalog.cache.solr.impl.ValidationQueryFactory)1 StorageProvider (ddf.catalog.content.StorageProvider)1 MockMemoryStorageProvider (ddf.catalog.content.impl.MockMemoryStorageProvider)1 AttributeRegistry (ddf.catalog.data.AttributeRegistry)1 Metacard (ddf.catalog.data.Metacard)1 Result (ddf.catalog.data.Result)1 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)1