Search in sources :

Example 1 with FilterAdapter

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

the class CopyFilterDelegateTest method assertFilterEquals.

private void assertFilterEquals(Filter filterIn) {
    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);
    // Verify object references are different, indicating a copy was made of the filter
    assertNotSame(filterIn, filterCopy);
    assertFilterContentsEqual(filterIn, filterCopy);
    // Verify filter contents (attributes, operands, etc) are identical
    assertThat(filterCopy, is(filterIn));
}
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 2 with FilterAdapter

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

the class CopyFilterDelegateTest method testFilterModification.

@Test
public void testFilterModification() {
    Filter filterIn = FF.equals(TEST_PROPERTY, FOO_LITERAL);
    FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
    FilterDelegate<Filter> delegate = new FilterModifierDelegate(filterBuilder);
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    Filter modifiedFilter = null;
    try {
        modifiedFilter = fa.adapt(filterIn, delegate);
    } catch (UnsupportedQueryException e) {
        fail(e.getMessage());
    }
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("testFeatureType");
    b.add(TEST_PROPERTY_VALUE, String.class);
    b.add("classification", String.class);
    SimpleFeatureType featureType = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
    builder.add(FOO_LITERAL_VALUE);
    builder.add("UNCLASS");
    SimpleFeature feature = builder.buildFeature("test");
    assertTrue(modifiedFilter.evaluate(feature));
}
Also used : SimpleFeatureTypeBuilder(org.geotools.feature.simple.SimpleFeatureTypeBuilder) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) 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) SimpleFeature(org.opengis.feature.simple.SimpleFeature) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder) Test(org.junit.Test)

Example 3 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 4 with FilterAdapter

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

the class CswQueryFactoryTest method testQueryTags.

@Test
public void testQueryTags() throws Exception {
    queryFactory.setSchemaToTagsMapping(new String[] { CswConstants.CSW_OUTPUT_SCHEMA + "=myTag" });
    List<String> ids = new ArrayList<>();
    ids.add("someId");
    FilterAdapter adapter = new GeotoolsFilterAdapterImpl();
    assertThat(adapter.adapt(queryFactory.updateQueryRequestTags(queryFactory.getQueryById(ids), CswConstants.CSW_OUTPUT_SCHEMA).getQuery(), new TagsFilterDelegate("myTag")), is(true));
}
Also used : TagsFilterDelegate(ddf.catalog.filter.delegate.TagsFilterDelegate) ArrayList(java.util.ArrayList) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) Test(org.junit.Test)

Example 5 with FilterAdapter

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

the class CswQueryFactoryTest method setUp.

@org.junit.Before
public void setUp() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException {
    filterBuilder = new GeotoolsFilterBuilder();
    FilterAdapter filterAdapter = new GeotoolsFilterAdapterImpl();
    metacardTypeList = new ArrayList<>();
    queryFactory = new CswQueryFactory(filterBuilder, filterAdapter, getCswMetacardType(), metacardTypeList);
    AttributeRegistry mockAttributeRegistry = mock(AttributeRegistry.class);
    when(mockAttributeRegistry.lookup(TITLE_TEST_ATTRIBUTE)).thenReturn(Optional.of(mock(AttributeDescriptor.class)));
    queryFactory.setAttributeRegistry(mockAttributeRegistry);
    polygon = new WKTReader().read(POLYGON_STR);
    gmlObjectFactory = new net.opengis.gml.v_3_1_1.ObjectFactory();
    filterObjectFactory = new ObjectFactory();
}
Also used : ObjectFactory(net.opengis.filter.v_1_1_0.ObjectFactory) AttributeRegistry(ddf.catalog.data.AttributeRegistry) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) WKTReader(com.vividsolutions.jts.io.WKTReader)

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