Search in sources :

Example 41 with FilterFactory

use of org.opengis.filter.FilterFactory in project ddf by codice.

the class SolrProviderQuery method contextualLogicalOrPositiveCase.

@Test
public void contextualLogicalOrPositiveCase() throws UnsupportedQueryException, IngestException {
    createContextualMetacards();
    FilterFactory filterFactory = new FilterFactoryImpl();
    Filter filter = filterFactory.or(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 OR Tampa", 2, 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 42 with FilterFactory

use of org.opengis.filter.FilterFactory in project ddf by codice.

the class SolrProviderQuery method contextualLogicalNestedOrAndPositiveCase.

@Test
public void contextualLogicalNestedOrAndPositiveCase() throws UnsupportedQueryException, IngestException {
    createContextualMetacards();
    FilterFactory filterFactory = new FilterFactoryImpl();
    Filter filter = filterFactory.or(filterFactory.and(filterFactory.like(filterFactory.property(Metacard.METADATA), Library.AIRPORT_QUERY_PHRASE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false), filterFactory.like(filterFactory.property(Metacard.METADATA), "AZ", DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false)), filterFactory.or(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), "AZ", DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false)));
    SourceResponse sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
    assertEquals("Failed: ( Airport )  AND  ( AZ )  OR  ( Flagstaff )  OR  ( AZ ) ", ONE_HIT, 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 43 with FilterFactory

use of org.opengis.filter.FilterFactory 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 44 with FilterFactory

use of org.opengis.filter.FilterFactory 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)

Example 45 with FilterFactory

use of org.opengis.filter.FilterFactory in project ddf by codice.

the class SolrProviderCreate method testCreateOperation.

/**
 * Testing that if we create a record, it is truly ingested and we can retrieve all the fields we
 * intend to be retrievable.
 */
@Test
public void testCreateOperation() throws IngestException, UnsupportedQueryException {
    deleteAll(provider);
    MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
    create(metacard, provider);
    FilterFactory filterFactory = new FilterFactoryImpl();
    // SIMPLE TITLE SEARCH
    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();
    assertEquals(1, results.size());
    assertNotNull(mResult.getId());
    assertEquals(MockMetacard.DEFAULT_TITLE, mResult.getTitle());
    assertEquals(MockMetacard.DEFAULT_LOCATION, mResult.getLocation());
    assertEquals(MockMetacard.DEFAULT_TYPE, mResult.getContentTypeName());
    assertEquals(MockMetacard.DEFAULT_VERSION, mResult.getContentTypeVersion());
    assertNotNull(mResult.getMetadata());
    assertThat(mResult.getMetadata(), containsString("<title>Flagstaff Chamber of Commerce</title>"));
    assertTrue(!mResult.getMetadata().isEmpty());
    assertFalse(mResult.getCreatedDate().after(new Date()));
    assertFalse(mResult.getModifiedDate().after(new Date()));
    assertEquals(metacard.getEffectiveDate(), mResult.getEffectiveDate());
    assertEquals(metacard.getExpirationDate(), mResult.getExpirationDate());
    assertTrue(Arrays.equals(metacard.getThumbnail(), mResult.getThumbnail()));
    assertEquals(metacard.getLocation(), mResult.getLocation());
    assertEquals(MASKED_ID, mResult.getSourceId());
    // --- Simple KEYWORD SEARCH
    filter = filterFactory.like(filterFactory.property(Metacard.METADATA), MockMetacard.DEFAULT_TITLE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false);
    query = new QueryImpl(filter);
    query.setStartIndex(1);
    sourceResponse = provider.query(new QueryRequestImpl(query));
    results = sourceResponse.getResults();
    mResult = results.get(0).getMetacard();
    assertEquals(1, results.size());
    assertNotNull(mResult.getId());
    assertEquals(MockMetacard.DEFAULT_TITLE, mResult.getTitle());
    assertEquals(MockMetacard.DEFAULT_LOCATION, mResult.getLocation());
    assertEquals(MockMetacard.DEFAULT_TYPE, mResult.getContentTypeName());
    assertEquals(MockMetacard.DEFAULT_VERSION, mResult.getContentTypeVersion());
    assertNotNull(mResult.getMetadata());
    assertTrue(!mResult.getMetadata().isEmpty());
    assertFalse(mResult.getCreatedDate().after(new Date()));
    assertFalse(mResult.getModifiedDate().after(new Date()));
    assertEquals(metacard.getEffectiveDate(), mResult.getEffectiveDate());
    assertEquals(metacard.getExpirationDate(), mResult.getExpirationDate());
    assertTrue(Arrays.equals(metacard.getThumbnail(), mResult.getThumbnail()));
    assertEquals(metacard.getLocation(), mResult.getLocation());
    assertEquals(MASKED_ID, mResult.getSourceId());
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Metacard(ddf.catalog.data.Metacard) 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) Date(java.util.Date) Result(ddf.catalog.data.Result) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest) Test(org.junit.Test)

Aggregations

FilterFactory (org.opengis.filter.FilterFactory)88 Test (org.junit.Test)72 FilterFactoryImpl (org.geotools.filter.FilterFactoryImpl)42 Filter (org.opengis.filter.Filter)38 QueryImpl (ddf.catalog.operation.impl.QueryImpl)33 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)30 Expression (org.opengis.filter.expression.Expression)24 SourceResponse (ddf.catalog.operation.SourceResponse)21 ArrayList (java.util.ArrayList)18 Metacard (ddf.catalog.data.Metacard)17 SolrProviderTest (ddf.catalog.source.solr.SolrProviderTest)17 ContrastEnhancement (org.geotools.styling.ContrastEnhancement)12 SelectedChannelType (org.geotools.styling.SelectedChannelType)12 Date (java.util.Date)11 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)11 ChannelSelection (org.geotools.styling.ChannelSelection)10 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)8 Result (ddf.catalog.data.Result)8 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 QueryResponse (ddf.catalog.operation.QueryResponse)8