use of ddf.catalog.pubsub.predicate.TemporalPredicate in project ddf by codice.
the class SubscriptionFilterVisitor method visit.
/**
* During filter maps to a Temporal (Absolute and Modified) search criteria.
*/
@Override
public Object visit(During filter, Object data) {
LOGGER.debug("ENTERING: During filter");
AttributeExpressionImpl temporalTypeAttribute = (AttributeExpressionImpl) filter.getExpression1();
String temporalType = temporalTypeAttribute.getPropertyName();
LiteralExpressionImpl timePeriodLiteral = (LiteralExpressionImpl) filter.getExpression2();
Object literal = timePeriodLiteral.getValue();
Predicate returnPredicate = null;
if (literal instanceof Period) {
Period timePeriod = (Period) literal;
// Extract the start and end dates from the OGC TOverlaps filter
Date start = timePeriod.getBeginning().getPosition().getDate();
Date end = timePeriod.getEnding().getPosition().getDate();
LOGGER.debug("time period lowerBound = {}", start);
LOGGER.debug("time period upperBound = {}", end);
LOGGER.debug("EXITING: (temporal) filter");
returnPredicate = new TemporalPredicate(start, end, DateType.getDateType(temporalType));
// CREATE RELATIVE
} else if (literal instanceof PeriodDuration) {
DefaultPeriodDuration duration = (DefaultPeriodDuration) literal;
long offset = duration.getTimeInMillis();
LOGGER.debug("EXITING: (temporal) filter");
returnPredicate = new TemporalPredicate(offset, DateType.getDateType(temporalType));
}
LOGGER.debug("temporalType: {}", temporalType);
LOGGER.debug("Temporal Predicate: {}", returnPredicate);
LOGGER.debug("EXITING: During filter");
return returnPredicate;
}
Aggregations