use of org.opengis.temporal.Instant in project ddf by codice.
the class CswRecordMapperFilterVisitor method visit.
@Override
public Object visit(PropertyIsGreaterThan filter, Object extraData) {
Expression expr1 = visit(filter.getExpression1(), extraData);
Expression expr2 = visit(filter.getExpression2(), expr1);
// work around since Solr Provider doesn't support greater on temporal (DDF-311)
if (isTemporalQuery(expr1, expr2)) {
// also not supported by provider (DDF-311)
//TODO: work around 1: return getFactory(extraData).after(expr1, expr2);
Object val = null;
Expression other = null;
if (expr2 instanceof Literal) {
val = ((Literal) expr2).getValue();
other = expr1;
} else if (expr1 instanceof Literal) {
val = ((Literal) expr1).getValue();
other = expr2;
}
if (val != null) {
Date orig = (Date) val;
orig.setTime(orig.getTime() + 1);
Instant start = new DefaultInstant(new DefaultPosition(orig));
Instant end = new DefaultInstant(new DefaultPosition(new Date()));
DefaultPeriod period = new DefaultPeriod(start, end);
Literal literal = getFactory(extraData).literal(period);
return getFactory(extraData).during(other, literal);
}
} else {
AttributeType type = attributeTypes.get(((PropertyName) filter.getExpression1()).getPropertyName());
LiteralExpressionImpl typedExpression = (LiteralExpressionImpl) filter.getExpression2();
setExpressionType(type, typedExpression);
expr2 = visit((Expression) typedExpression, expr1);
}
return getFactory(extraData).greater(expr1, expr2);
}
use of org.opengis.temporal.Instant in project ddf by codice.
the class CswRecordMapperFilterVisitor method visit.
@Override
public Object visit(PropertyIsGreaterThanOrEqualTo filter, Object extraData) {
Expression expr1 = visit(filter.getExpression1(), extraData);
Expression expr2 = visit(filter.getExpression2(), expr1);
// work around since Solr Provider doesn't support greaterOrEqual on temporal (DDF-311)
if (isTemporalQuery(expr1, expr2)) {
// also not supported by provider (DDF-311)
//TEquals tEquals = getFactory(extraData).tequals(expr1, expr2);
//After after = getFactory(extraData).after(expr1, expr2);
//return getFactory(extraData).or(tEquals, after);
Object val = null;
Expression other = null;
if (expr2 instanceof Literal) {
val = ((Literal) expr2).getValue();
other = expr1;
} else if (expr1 instanceof Literal) {
val = ((Literal) expr1).getValue();
other = expr2;
}
if (val != null) {
Date orig = (Date) val;
Instant start = new DefaultInstant(new DefaultPosition(orig));
Instant end = new DefaultInstant(new DefaultPosition(new Date()));
DefaultPeriod period = new DefaultPeriod(start, end);
Literal literal = getFactory(extraData).literal(period);
return getFactory(extraData).during(other, literal);
}
} else {
AttributeType type = attributeTypes.get(((PropertyName) filter.getExpression1()).getPropertyName());
LiteralExpressionImpl typedExpression = (LiteralExpressionImpl) filter.getExpression2();
setExpressionType(type, typedExpression);
expr2 = visit((Expression) typedExpression, expr1);
}
return getFactory(extraData).greaterOrEqual(expr1, expr2);
}
use of org.opengis.temporal.Instant in project ddf by codice.
the class SolrFilterBuilderTest method makePeriod.
private Period makePeriod(Date start, Date end) {
DefaultPosition defaultPosition = new DefaultPosition(start);
Instant startInstant = new DefaultInstant(defaultPosition);
Instant endInstant = new DefaultInstant(new DefaultPosition(end));
Period period = new DefaultPeriod(startInstant, endInstant);
return period;
}
use of org.opengis.temporal.Instant in project sldeditor by robward-scisys.
the class TimePeriod method decode.
/**
* Decode a DefaultPeriod object.
*
* @param objValue the obj value
*/
public void decode(DefaultPeriod objValue) {
DefaultPeriod defaultPeriod = (DefaultPeriod) objValue;
Instant beginning = defaultPeriod.getBeginning();
Duration startDuration = new Duration();
startDuration.setDate(beginning.getPosition().getDate());
setStart(startDuration);
Instant end = defaultPeriod.getEnding();
Duration endDuration = new Duration();
endDuration.setDate(end.getPosition().getDate());
setEnd(endDuration);
}
use of org.opengis.temporal.Instant in project ddf by codice.
the class OpenSearchQuery method addTemporalFilter.
private void addTemporalFilter(TemporalFilter temporalFilter) {
if (temporalFilter != null) {
// t1.start < timeType instance < t1.end
Instant startInstant = new DefaultInstant(new DefaultPosition(temporalFilter.getStartDate()));
Instant endInstant = new DefaultInstant(new DefaultPosition(temporalFilter.getEndDate()));
Period period = new DefaultPeriod(startInstant, endInstant);
Filter filter = FILTER_FACTORY.during(FILTER_FACTORY.property(OpenSearchConstants.SUPPORTED_TEMPORAL_SEARCH_TERM), FILTER_FACTORY.literal(period));
LOGGER.trace("Adding temporal filter");
filters.add(filter);
}
}
Aggregations