use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class SolrProviderTest method queryXpathWithPhrase.
private SourceResponse queryXpathWithPhrase(String xpath, String searchPhrase, boolean isCaseSensitive) throws UnsupportedQueryException {
Filter filter;
if (isCaseSensitive) {
filter = filterBuilder.xpath(xpath).is().like().caseSensitiveText(searchPhrase);
} else {
filter = filterBuilder.xpath(xpath).is().like().text(searchPhrase);
}
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
return sourceResponse;
}
use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class SolrProviderTest method testSpatialQueryWithCounterClockwiseRectangle.
@Test
public void testSpatialQueryWithCounterClockwiseRectangle() throws Exception {
deleteAllIn(provider);
MetacardImpl metacard = new MockMetacard(Library.getFlagstaffRecord());
metacard.setLocation(FLAGSTAFF_AIRPORT_POINT_WKT);
List<Metacard> list = Arrays.asList((Metacard) metacard);
/** CREATE **/
create(list);
/** POSITIVE **/
Filter filter = filterBuilder.attribute(Metacard.GEOGRAPHY).intersecting().wkt(COUNTERCLOCKWISE_ARIZONA_RECTANGLE_WKT);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
assertEquals("Failed to find Flagstaff record.", 1, sourceResponse.getResults().size());
for (Result r : sourceResponse.getResults()) {
assertTrue("Wrong record, Flagstaff keyword was not found.", ALL_RESULTS != r.getMetacard().getMetadata().indexOf(FLAGSTAFF_QUERY_PHRASE));
}
}
use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class SolrProviderTest method testSortedPointRadiusWithComplexQuery.
@Test
public void testSortedPointRadiusWithComplexQuery() throws Exception {
deleteAllIn(provider);
MetacardImpl metacard1 = new MockMetacard(Library.getFlagstaffRecord());
MetacardImpl metacard2 = new MockMetacard(Library.getTampaRecord());
MetacardImpl metacard3 = new MockMetacard(Library.getShowLowRecord());
// Add in the geometry
metacard1.setLocation(FLAGSTAFF_AIRPORT_POINT_WKT);
metacard2.setLocation(TAMPA_AIRPORT_POINT_WKT);
metacard3.setLocation(SHOW_LOW_AIRPORT_POINT_WKT);
// Add in a content type
metacard1.setAttribute(Metacard.CONTENT_TYPE, "product");
List<Metacard> list = Arrays.asList((Metacard) metacard1, metacard2, metacard3);
/** CREATE **/
create(list);
// create a filter that has spatial and content type criteria
Filter contentFilter = filterBuilder.attribute(Metacard.CONTENT_TYPE).is().text("product");
Filter spatialFilter = filterBuilder.attribute(Metacard.GEOGRAPHY).intersecting().wkt(FLAGSTAFF_AIRPORT_POINT_WKT);
Filter finalFilter = filterBuilder.allOf(filterBuilder.attribute(Metacard.ANY_TEXT).like().text("flagstaff"), filterBuilder.allOf(contentFilter, spatialFilter));
// sort by distance
QueryImpl query = new QueryImpl(finalFilter);
SortBy sortby = new ddf.catalog.filter.impl.SortByImpl(Result.DISTANCE, org.opengis.filter.sort.SortOrder.DESCENDING);
query.setSortBy(sortby);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
assertEquals(1, sourceResponse.getResults().size());
}
use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class SolrProviderTest method testSpatialCreateAndUpdateWithClockwiseRectangle.
@Test
public void testSpatialCreateAndUpdateWithClockwiseRectangle() throws Exception {
deleteAllIn(provider);
/** CREATE **/
MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
metacard.setLocation(CLOCKWISE_ARIZONA_RECTANGLE_WKT);
CreateResponse createResponse = create(Arrays.asList((Metacard) metacard));
assertEquals(1, createResponse.getCreatedMetacards().size());
Filter filter = filterBuilder.attribute(Metacard.GEOGRAPHY).intersecting().wkt(FLAGSTAFF_AIRPORT_POINT_WKT);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
assertEquals("Failed to find correct record.", 1, sourceResponse.getResults().size());
/** UPDATE **/
MockMetacard updatedMetacard = new MockMetacard(Library.getTampaRecord());
updatedMetacard.setLocation(CLOCKWISE_ARIZONA_RECTANGLE_WKT);
String[] ids = { metacard.getId() };
UpdateResponse updateResponse = update(ids, Arrays.asList((Metacard) updatedMetacard));
assertEquals(1, updateResponse.getUpdatedMetacards().size());
filter = filterBuilder.attribute(Metacard.GEOGRAPHY).intersecting().wkt(FLAGSTAFF_AIRPORT_POINT_WKT);
sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
assertEquals("Failed to find correct record.", 1, sourceResponse.getResults().size());
}
use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class SolrProviderTest method assertNotFilter.
private void assertNotFilter(Filter filter) throws UnsupportedQueryException {
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
assertEquals("Found a metacard and should not have.", 0, sourceResponse.getResults().size());
}
Aggregations