use of org.apache.rya.indexing.geotemporal.GeoTemporalIndexer.TemporalPolicy in project incubator-rya by apache.
the class GeoTemporalMongoDBStorageStrategy method getTemporalObjs.
private DBObject[] getTemporalObjs(final Collection<IndexingExpr> temporalFilters) {
final List<DBObject> objs = new ArrayList<>();
temporalFilters.forEach(filter -> {
final TemporalPolicy policy = TemporalPolicy.fromURI(filter.getFunction());
final String timeStr = ((Value) filter.getArguments()[0]).stringValue();
final Matcher matcher = TemporalInstantRfc3339.PATTERN.matcher(timeStr);
if (matcher.find()) {
final TemporalInterval interval = TemporalInstantRfc3339.parseInterval(timeStr);
if (policy == TemporalPolicy.INSTANT_AFTER_INSTANT || policy == TemporalPolicy.INSTANT_BEFORE_INSTANT || policy == TemporalPolicy.INSTANT_EQUALS_INSTANT) {
if (interval == null) {
LOG.error("Cannot perform temporal interval based queries on an instant.");
}
}
objs.add(getTemporalObject(interval, policy));
} else {
final TemporalInstant instant = new TemporalInstantRfc3339(DateTime.parse(timeStr));
if (policy != TemporalPolicy.INSTANT_AFTER_INSTANT && policy != TemporalPolicy.INSTANT_BEFORE_INSTANT && policy != TemporalPolicy.INSTANT_EQUALS_INSTANT) {
LOG.error("Cannot perform temporal instant based queries on an interval.");
}
objs.add(getTemporalObject(instant, policy));
}
});
return objs.toArray(new DBObject[] {});
}
Aggregations