Search in sources :

Example 26 with FilterFactoryImpl

use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.

the class SolrProviderQuery method contextualLogicalAndNegativeCase.

@Test
public void contextualLogicalAndNegativeCase() throws UnsupportedQueryException, IngestException {
    createContextualMetacards();
    FilterFactory filterFactory = new FilterFactoryImpl();
    Filter filter = filterFactory.and(filterFactory.like(filterFactory.property(Metacard.METADATA), Library.FLAGSTAFF_QUERY_PHRASE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false), filterFactory.like(filterFactory.property(Metacard.METADATA), Library.TAMPA_QUERY_PHRASE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false));
    SourceResponse sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
    assertEquals("Flagstaff and Tampa", 0, sourceResponse.getResults().size());
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) SourceResponse(ddf.catalog.operation.SourceResponse) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) FilterFactory(org.opengis.filter.FilterFactory) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest) Test(org.junit.Test)

Example 27 with FilterFactoryImpl

use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.

the class PropertyMapperVisitorTest method testPropertyMapperVisitPassThrough.

@Test
public void testPropertyMapperVisitPassThrough() {
    Map<String, String> map = new HashMap<>();
    map.put("prop", "newProp");
    PropertyMapperVisitor mapper = new PropertyMapperVisitor(map);
    PropertyName propertyName = new PropertyNameImpl("myprop");
    AttributeExpressionImpl exp = (AttributeExpressionImpl) mapper.visit(propertyName, new FilterFactoryImpl());
    assertThat(exp.getPropertyName(), equalTo("myprop"));
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) HashMap(java.util.HashMap) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) PropertyNameImpl(ddf.catalog.filter.impl.PropertyNameImpl) Test(org.junit.Test)

Example 28 with FilterFactoryImpl

use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.

the class PropertyMapperVisitorTest method testPropertyMapperVisit.

@Test
public void testPropertyMapperVisit() {
    Map<String, String> map = new HashMap<>();
    map.put("prop", "newProp");
    PropertyMapperVisitor mapper = new PropertyMapperVisitor(map);
    PropertyName propertyName = new PropertyNameImpl("prop");
    AttributeExpressionImpl exp = (AttributeExpressionImpl) mapper.visit(propertyName, new FilterFactoryImpl());
    assertThat(exp.getPropertyName(), equalTo("newProp"));
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) HashMap(java.util.HashMap) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) PropertyNameImpl(ddf.catalog.filter.impl.PropertyNameImpl) Test(org.junit.Test)

Example 29 with FilterFactoryImpl

use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.

the class PropertyMapperVisitorTest method testPropertyMapperVisitNullProperty.

@Test
public void testPropertyMapperVisitNullProperty() {
    Map<String, String> map = new HashMap<>();
    PropertyMapperVisitor mapper = new PropertyMapperVisitor(map);
    AttributeExpressionImpl exp = (AttributeExpressionImpl) mapper.visit((PropertyName) null, new FilterFactoryImpl());
    assertThat(exp, nullValue());
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) HashMap(java.util.HashMap) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) Test(org.junit.Test)

Example 30 with FilterFactoryImpl

use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.

the class SolrProviderCreate method testCreateMultivaluedAttribute.

/**
 * Tests that multivalued attributes are stored and returned
 */
@Test
public void testCreateMultivaluedAttribute() throws UnsupportedQueryException, IngestException {
    deleteAll(provider);
    FilterFactory filterFactory = new FilterFactoryImpl();
    MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
    List<Serializable> a = new ArrayList<>();
    a.add("sample-validator");
    a.add("sample-validator2");
    AttributeImpl attribute = new AttributeImpl(Validation.VALIDATION_WARNINGS, a);
    metacard.setAttribute(attribute);
    create(metacard, provider);
    Filter filter = filterFactory.like(filterFactory.property(Metacard.TITLE), MockMetacard.DEFAULT_TITLE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false);
    QueryImpl query = new QueryImpl(filter);
    query.setStartIndex(1);
    SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
    List<Result> results = sourceResponse.getResults();
    Metacard mResult = results.get(0).getMetacard();
    assertThat(mResult.getAttribute(Validation.VALIDATION_WARNINGS).getValues().size(), is(2));
}
Also used : Serializable(java.io.Serializable) SourceResponse(ddf.catalog.operation.SourceResponse) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList) FilterFactory(org.opengis.filter.FilterFactory) Result(ddf.catalog.data.Result) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Metacard(ddf.catalog.data.Metacard) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest) Test(org.junit.Test)

Aggregations

FilterFactoryImpl (org.geotools.filter.FilterFactoryImpl)58 Test (org.junit.Test)50 FilterFactory (org.opengis.filter.FilterFactory)42 Filter (org.opengis.filter.Filter)39 QueryImpl (ddf.catalog.operation.impl.QueryImpl)35 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)33 SourceResponse (ddf.catalog.operation.SourceResponse)21 Metacard (ddf.catalog.data.Metacard)18 SolrProviderTest (ddf.catalog.source.solr.SolrProviderTest)17 Date (java.util.Date)12 ArrayList (java.util.ArrayList)11 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)9 QueryResponse (ddf.catalog.operation.QueryResponse)9 Result (ddf.catalog.data.Result)8 CreateResponse (ddf.catalog.operation.CreateResponse)8 QueryRequest (ddf.catalog.operation.QueryRequest)8 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)8 Calendar (java.util.Calendar)6 DateTime (org.joda.time.DateTime)6 Ignore (org.junit.Ignore)6