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());
}
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());
}
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());
}
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));
}
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());
}
Aggregations