use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor in project geowave by locationtech.
the class ExtractTimeFilterVisitorTest method testAfter.
@Test
public void testAfter() throws CQLException, ParseException {
final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
final Date time = DateUtilities.parseISO("2005-05-19T20:32:56Z");
final Filter filter = CQL.toFilter("when after 2005-05-19T20:32:56Z");
final Query query = new Query("type", filter);
TemporalConstraints range = (TemporalConstraints) query.getFilter().accept(visitor, null);
assertNotNull(range);
assertEquals(new Date(time.getTime() + 1), range.getStartRange().getStartTime());
range = (TemporalConstraints) query.getFilter().accept(visitorWithDescriptor, null);
assertNotNull(range);
assertEquals(new Date(time.getTime() + 1), range.getStartRange().getStartTime());
assertEquals("when", range.getName());
}
use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor in project geowave by locationtech.
the class ExtractTimeFilterVisitorTest method testGreaterThan.
@Test
public void testGreaterThan() throws CQLException, ParseException {
final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
final Date stimeNotEqual = new Date(DateUtilities.parseISO("2005-05-19T20:32:56Z").getTime() + 1);
final Date stime = DateUtilities.parseISO("2005-05-19T20:32:56Z");
Filter filter = ECQL.toFilter("when > 2005-05-19T20:32:56Z");
Query query = new Query("type", filter);
TemporalConstraints range = (TemporalConstraints) query.getFilter().accept(visitor, null);
assertNotNull(range);
assertEquals(stimeNotEqual, range.getStartRange().getStartTime());
assertEquals(TemporalRange.END_TIME, range.getEndRange().getEndTime());
assertEquals("when", range.getName());
filter = ECQL.toFilter("2005-05-19T20:32:56Z < when");
query = new Query("type", filter);
range = (TemporalConstraints) query.getFilter().accept(visitor, null);
assertNotNull(range);
assertEquals(stimeNotEqual, range.getStartRange().getStartTime());
assertEquals(TemporalRange.END_TIME, range.getEndRange().getEndTime());
assertEquals("when", range.getName());
filter = ECQL.toFilter("2005-05-19T20:32:56Z <= when");
query = new Query("type", filter);
range = (TemporalConstraints) query.getFilter().accept(visitor, null);
assertNotNull(range);
assertEquals(stime, range.getStartRange().getStartTime());
assertEquals(TemporalRange.END_TIME, range.getEndRange().getEndTime());
assertEquals("when", range.getName());
}
use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor in project geowave by locationtech.
the class ExtractTimeFilterVisitorTest method testBefore.
@Test
public void testBefore() throws CQLException, ParseException {
final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
final Date etime = new Date(DateUtilities.parseISO("2005-05-19T20:32:56Z").getTime() - 1);
final Filter filter = CQL.toFilter("when before 2005-05-19T20:32:56Z");
final Query query = new Query("type", filter);
TemporalConstraints range = (TemporalConstraints) query.getFilter().accept(visitor, null);
assertNotNull(range);
assertEquals(TemporalRange.START_TIME, range.getStartRange().getStartTime());
assertEquals(etime, range.getStartRange().getEndTime());
range = (TemporalConstraints) query.getFilter().accept(visitorWithDescriptor, null);
assertNotNull(range);
assertEquals(TemporalRange.START_TIME, range.getStartRange().getStartTime());
assertEquals(etime, range.getStartRange().getEndTime());
}
use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor in project geowave by locationtech.
the class ExtractTimeFilterVisitorTest method testNotBetween.
@Test
public void testNotBetween() throws CQLException, ParseException {
final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
final Date sTime2 = new Date(DateUtilities.parseISO("2005-05-19T20:32:56Z").getTime() + 1);
final Date eTime1 = new Date(DateUtilities.parseISO("2005-05-17T20:32:56Z").getTime() - 1);
final Filter filter = CQL.toFilter("not (when before 2005-05-17T20:32:56Z or when after 2005-05-19T20:32:56Z)");
final Query query = new Query("type", filter);
final TemporalConstraintsSet rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitor, null);
assertNotNull(rangeSet);
assertEquals(eTime1, rangeSet.getConstraintsFor("when").getStartRange().getStartTime());
assertEquals(new Date(sTime2.getTime() - 1), rangeSet.getConstraintsFor("when").getStartRange().getEndTime());
}
use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor in project geowave by locationtech.
the class ExtractTimeFilterVisitorTest method testBeforeOrDuring.
@Test
public void testBeforeOrDuring() throws CQLException, ParseException {
final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
final Date stime = new Date(DateUtilities.parseISO("2005-05-19T21:32:56Z").getTime() - 1);
final Filter filter = CQL.toFilter("when BEFORE OR DURING 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z");
final Query query = new Query("type", filter);
TemporalConstraintsSet rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitor, null);
assertNotNull(rangeSet);
assertEquals(TemporalRange.START_TIME, rangeSet.getConstraintsFor("when").getStartRange().getStartTime());
assertEquals(stime, rangeSet.getConstraintsFor("when").getEndRange().getEndTime());
rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitorWithDescriptor, null);
assertNotNull(rangeSet);
assertEquals(TemporalRange.START_TIME, rangeSet.getConstraintsFor("when").getStartRange().getStartTime());
assertEquals(stime, rangeSet.getConstraintsFor("when").getEndRange().getEndTime());
}
Aggregations