use of org.opengis.temporal.PeriodDuration in project ddf by codice.
the class OpenSearchFilterVisitor method handleTemporal.
private void handleTemporal(BinaryTemporalOperator filter) {
Literal literalWrapper = (Literal) filter.getExpression2();
LOGGER.trace("literalWrapper.getValue() = {}", literalWrapper.getValue());
Object literal = literalWrapper.evaluate(null);
if (literal instanceof Period) {
Period period = (Period) literal;
// Extract the start and end dates from the filter
Date start = period.getBeginning().getPosition().getDate();
Date end = period.getEnding().getPosition().getDate();
temporalSearch = new TemporalFilter(start, end);
filters.add(filter);
} else if (literal instanceof PeriodDuration) {
DefaultPeriodDuration duration = (DefaultPeriodDuration) literal;
// Extract the start and end dates from the filter
Date end = Calendar.getInstance().getTime();
Date start = new Date(end.getTime() - duration.getTimeInMillis());
temporalSearch = new TemporalFilter(start, end);
filters.add(filter);
}
}
use of org.opengis.temporal.PeriodDuration 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;
}
use of org.opengis.temporal.PeriodDuration in project ddf by codice.
the class TwitterFilterVisitor method handleTemporal.
private void handleTemporal(BinaryTemporalOperator filter) {
Literal literalWrapper = (Literal) filter.getExpression2();
LOGGER.debug("literalWrapper.getValue() = {}", literalWrapper.getValue());
Object literal = literalWrapper.evaluate(null);
if (literal instanceof Period) {
Period period = (Period) literal;
// Extract the start and end dates from the filter
Date start = period.getBeginning().getPosition().getDate();
Date end = period.getEnding().getPosition().getDate();
temporalSearch = new TemporalFilter(start, end);
filters.add(filter);
} else if (literal instanceof PeriodDuration) {
DefaultPeriodDuration duration = (DefaultPeriodDuration) literal;
// Extract the start and end dates from the filter
Date end = Calendar.getInstance().getTime();
Date start = new Date(end.getTime() - duration.getTimeInMillis());
temporalSearch = new TemporalFilter(start, end);
filters.add(filter);
}
}
Aggregations