use of ddf.catalog.impl.filter.TemporalFilter in project ddf by codice.
the class OpenSearchQueryTest method testCompoundFilter.
@Test
public void testCompoundFilter() throws Exception {
String searchTerm = "cat";
String selectors = "//fileTitle,//nitf";
OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
query.addContextualFilter(searchTerm, selectors);
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);
String type = "nitf";
String versions = "v20,invalid_version,*";
query.addTypeFilter(type, versions);
String lon = "10";
String lat = "20";
String radius = "5000";
query.addSpatialDistanceFilter(lon, lat, radius);
// Filter filter = query.getFilter();
// String filterXml = getFilterAsXml( filter );
}
use of ddf.catalog.impl.filter.TemporalFilter in project ddf by codice.
the class OpenSearchQueryTest method testTemporalFilterAbsoluteSearch.
@Test
public void testTemporalFilterAbsoluteSearch() throws Exception {
String startDate = "2011-10-4T05:48:27.891-07:00";
String endDate = "2011-10-4T06:18:27.581-07:00";
TemporalFilter temporalFilter = new TemporalFilter(startDate, endDate);
LOGGER.debug(temporalFilter.toString());
OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
query.addTemporalFilter(temporalFilter);
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);
List<Filter> filters = getFilters(map, DuringImpl.class.getName());
assertEquals(1, filters.size());
verifyTemporalFilter(filters.get(0), startDate, endDate);
}
use of ddf.catalog.impl.filter.TemporalFilter in project ddf by codice.
the class OpenSearchQueryTest method testTemporalFilterAbsoluteSearchStringDates.
@Test
public void testTemporalFilterAbsoluteSearchStringDates() throws Exception {
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());
OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
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();
printFilterStatusMap(map);
List<Filter> filters = getFilters(map, DuringImpl.class.getName());
assertEquals(1, filters.size());
verifyTemporalFilter(filters.get(0), startDate, endDate);
}
use of ddf.catalog.impl.filter.TemporalFilter 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);
}
use of ddf.catalog.impl.filter.TemporalFilter in project ddf by codice.
the class MockQuery method addTemporalFilter.
public void addTemporalFilter(String dateStart, String dateEnd, String dateOffset) {
TemporalFilter temporalFilter = null;
if (dateStart != null || dateEnd != null) {
temporalFilter = new TemporalFilter(dateStart, dateEnd);
} else if (dateOffset != null) {
temporalFilter = new TemporalFilter(Long.parseLong(dateOffset));
}
addTemporalFilter(temporalFilter);
}
Aggregations