use of org.geotools.filter.AndImpl in project ddf by codice.
the class OpenSearchQueryTest method testTypeFilterWildcardTypeAndMultipleVersions.
@Test
public void testTypeFilterWildcardTypeAndMultipleVersions() throws Exception {
String type = "*";
String versions = "v20,invalid_version,*";
OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
query.addTypeFilter(type, versions);
Filter filter = query.getFilter();
// String filterXml = getFilterAsXml( filter );
VerificationVisitor verificationVisitor = new VerificationVisitor();
filter.accept(verificationVisitor, null);
HashMap<String, FilterStatus> map = (HashMap<String, FilterStatus>) verificationVisitor.getMap();
printFilterStatusMap(map);
String[] expectedVersions = versions.split(",");
List<Filter> orFilters = getFilters(map, OrImpl.class.getName());
assertEquals(1, orFilters.size());
List<Filter> andFilters = getFilters(map, AndImpl.class.getName());
assertEquals(expectedVersions.length, andFilters.size());
List<Filter> equalsFilters = getFilters(map, IsEqualsToImpl.class.getName());
assertEquals(2, equalsFilters.size());
List<Filter> likeFilters = getFilters(map, LikeFilterImpl.class.getName());
assertEquals(4, likeFilters.size());
int i = 0;
for (Filter f : andFilters) {
List<Filter> childFilters = ((AndImpl) f).getChildren();
verifyTypeVersionFilter(childFilters, type, expectedVersions[i]);
i++;
}
// Requires gt-jdbc.jar dependency in POM, but whn that JAR is loaded it causes
// IncompatibleClassChangeError class loader issues in OpenSearchQuery.addTemporalFilter()
// HUGH filter.accept( new FilterToSQL( new PrintWriter( System.out, true ) ), null );
}
use of org.geotools.filter.AndImpl in project ddf by codice.
the class OpenSearchQueryTest method testTypeFilterWildcardTypeAndVersion.
@Test
public void testTypeFilterWildcardTypeAndVersion() throws Exception {
String type = "*";
String versions = "collectorPosition";
OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
query.addTypeFilter(type, versions);
Filter filter = query.getFilter();
// String filterXml = getFilterAsXml( filter );
VerificationVisitor verificationVisitor = new VerificationVisitor();
filter.accept(verificationVisitor, null);
HashMap<String, FilterStatus> map = (HashMap<String, FilterStatus>) verificationVisitor.getMap();
printFilterStatusMap(map);
String[] expectedVersions = versions.split(",");
List<Filter> andFilters = getFilters(map, AndImpl.class.getName());
assertEquals(expectedVersions.length, andFilters.size());
List<Filter> equalsFilters = getFilters(map, IsEqualsToImpl.class.getName());
assertEquals((expectedVersions.length), equalsFilters.size());
List<Filter> likeFilters = getFilters(map, LikeFilterImpl.class.getName());
assertEquals((expectedVersions.length), likeFilters.size());
int i = 0;
for (Filter f : andFilters) {
List<Filter> childFilters = ((AndImpl) f).getChildren();
verifyTypeVersionFilter(childFilters, type, expectedVersions[i]);
i++;
}
}
use of org.geotools.filter.AndImpl in project ddf by codice.
the class OpenSearchQueryTest method testContextualTemporalFilter.
@Test
public void testContextualTemporalFilter() throws Exception {
String searchTerm = "cat";
String selector = null;
OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
query.addContextualFilter(searchTerm, selector);
String startDate = "2011-10-4T05:48:27.891-07:00";
String endDate = "2011-10-4T06:18:27.581-07:00";
String dateOffset = null;
TemporalFilter temporalFilter = new TemporalFilter(startDate, endDate);
LOGGER.debug(temporalFilter.toString());
query.addTemporalFilter(startDate, endDate, dateOffset);
Filter filter = query.getFilter();
// String filterXml = getFilterAsXml( filter );
VerificationVisitor verificationVisitor = new VerificationVisitor();
filter.accept(verificationVisitor, null);
HashMap<String, FilterStatus> map = (HashMap<String, FilterStatus>) verificationVisitor.getMap();
List<Filter> andFilters = getFilters(map, AndImpl.class.getName());
assertEquals(1, andFilters.size());
AndImpl andFilter = (AndImpl) andFilters.get(0);
List<Filter> childFilters = andFilter.getChildren();
assertTrue(childFilters.size() == 2);
verifyContextualFilter(childFilters.get(0), "anyText", searchTerm);
verifyTemporalFilter(childFilters.get(1), startDate, endDate);
}
Aggregations