Search in sources :

Example 6 with FilterDelegate

use of ddf.catalog.filter.FilterDelegate in project ddf by codice.

the class GeotoolsFilterAdapterImpl method visit.

public Object visit(Begins begins, Object delegate) {
    ExpressionValues filterValues = getExpressions(begins, delegate);
    if (filterValues.literal instanceof Period) {
        Period period = (Period) filterValues.literal;
        Date start = period.getBeginning().getPosition().getDate();
        Date end = period.getEnding().getPosition().getDate();
        return ((FilterDelegate<?>) delegate).begins(filterValues.propertyName, start, end);
    } else {
        throw new UnsupportedOperationException(Begins.NAME + "filter not supported by Filter Adapter.");
    }
}
Also used : FilterDelegate(ddf.catalog.filter.FilterDelegate) Period(org.opengis.temporal.Period) Date(java.util.Date)

Example 7 with FilterDelegate

use of ddf.catalog.filter.FilterDelegate in project ddf by codice.

the class GeotoolsFilterAdapterImpl method visit.

public Object visit(PropertyIsLessThan filter, Object delegate) {
    ExpressionValues filterValues = getExpressions(filter, delegate);
    String propertyName = filterValues.propertyName;
    Object literal = filterValues.literal;
    // Are property name and literal reversed?
    if (filter.getExpression1() instanceof Literal) {
        // convert literal < property to property > literal
        Filter greaterThan = FF.greater(FF.property(propertyName), FF.literal(literal));
        return greaterThan.accept(this, delegate);
    }
    if (literal instanceof String) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, (String) literal);
    } else if (literal instanceof Date) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, (Date) literal);
    } else if (literal instanceof Integer) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, ((Integer) literal).intValue());
    } else if (literal instanceof Short) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, ((Short) literal).shortValue());
    } else if (literal instanceof Long) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, ((Long) literal).longValue());
    } else if (literal instanceof Float) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, ((Float) literal).floatValue());
    } else if (literal instanceof Double) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, ((Double) literal).doubleValue());
    } else if (literal instanceof Boolean) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, literal);
    } else if (literal instanceof byte[]) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, literal);
    } else {
        return ((FilterDelegate<?>) delegate).propertyIsLessThan(propertyName, literal);
    }
}
Also used : FilterDelegate(ddf.catalog.filter.FilterDelegate) Date(java.util.Date) IncludeFilter(org.opengis.filter.IncludeFilter) ExcludeFilter(org.opengis.filter.ExcludeFilter) Filter(org.opengis.filter.Filter) Literal(org.opengis.filter.expression.Literal)

Example 8 with FilterDelegate

use of ddf.catalog.filter.FilterDelegate in project ddf by codice.

the class GeotoolsFilterAdapterImpl method visit.

public Object visit(PropertyIsLessThanOrEqualTo filter, Object delegate) {
    ExpressionValues filterValues = getExpressions(filter, delegate);
    String propertyName = filterValues.propertyName;
    Object literal = filterValues.literal;
    // Are property name and literal reversed?
    if (filter.getExpression1() instanceof Literal) {
        // convert literal <= property to property >= literal
        Filter greaterThanOrEqual = FF.greaterOrEqual(FF.property(propertyName), FF.literal(literal));
        return greaterThanOrEqual.accept(this, delegate);
    }
    if (literal instanceof String) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, (String) literal);
    } else if (literal instanceof Date) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, (Date) literal);
    } else if (literal instanceof Integer) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Integer) literal).intValue());
    } else if (literal instanceof Short) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Short) literal).shortValue());
    } else if (literal instanceof Long) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Long) literal).longValue());
    } else if (literal instanceof Float) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Float) literal).floatValue());
    } else if (literal instanceof Double) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Double) literal).doubleValue());
    } else if (literal instanceof Boolean) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, literal);
    } else if (literal instanceof byte[]) {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, literal);
    } else {
        return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, literal);
    }
}
Also used : FilterDelegate(ddf.catalog.filter.FilterDelegate) Date(java.util.Date) IncludeFilter(org.opengis.filter.IncludeFilter) ExcludeFilter(org.opengis.filter.ExcludeFilter) Filter(org.opengis.filter.Filter) Literal(org.opengis.filter.expression.Literal)

Aggregations

FilterDelegate (ddf.catalog.filter.FilterDelegate)8 Date (java.util.Date)6 ExcludeFilter (org.opengis.filter.ExcludeFilter)5 Filter (org.opengis.filter.Filter)5 IncludeFilter (org.opengis.filter.IncludeFilter)5 Literal (org.opengis.filter.expression.Literal)4 Period (org.opengis.temporal.Period)2 FuzzyFunction (ddf.catalog.impl.filter.FuzzyFunction)1 ArrayList (java.util.ArrayList)1 DefaultPeriodDuration (org.geotools.temporal.object.DefaultPeriodDuration)1 PropertyName (org.opengis.filter.expression.PropertyName)1