use of ddf.catalog.operation.impl.QueryImpl 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.QueryImpl 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.QueryImpl 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());
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class SolrProviderTest method queryXpathExists.
private SourceResponse queryXpathExists(String xpath) throws UnsupportedQueryException {
Filter filter = filterBuilder.xpath(xpath).exists();
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
return sourceResponse;
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class CatalogFrameworkImplTest method testFederatedQueryPermissionsNoSubject.
@Test(expected = FederationException.class)
public void testFederatedQueryPermissionsNoSubject() throws Exception {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<>(), true, new Date());
Map<String, CatalogStore> storeMap = new HashMap<>();
Map<String, FederatedSource> sourceMap = new HashMap<>();
Map<String, Set<String>> securityAttributes = new HashMap<>();
securityAttributes.put("role", Collections.singleton("myRole"));
MockCatalogStore store = new MockCatalogStore("catalogStoreId-1", true, securityAttributes);
storeMap.put(store.getId(), store);
sourceMap.put(store.getId(), store);
CatalogFramework framework = createDummyCatalogFramework(provider, storeMap, sourceMap, eventAdmin);
FilterBuilder builder = new GeotoolsFilterBuilder();
QueryImpl query = new QueryImpl(builder.attribute(Metacard.CONTENT_TYPE).is().like().text("someType"));
QueryRequestImpl request = new QueryRequestImpl(query, Collections.singletonList("catalogStoreId-1"));
framework.query(request);
}
Aggregations