Search in sources :

Example 1 with BinaryComparisonAbstract

use of org.geotools.filter.BinaryComparisonAbstract in project sldeditor by robward-scisys.

the class ExpressionPanelv2 method addFilter.

/**
 * Adds the filter.
 *
 * @param node the node
 * @return the filter
 */
private Filter addFilter(FilterNode node) {
    Filter filter = node.getFilter();
    FilterConfigInterface filterConfig = node.getFilterConfig();
    if (filter instanceof LogicFilterImpl) {
        List<Filter> filterList = new ArrayList<Filter>();
        createFilterList(node, filterList);
        return filterConfig.createLogicFilter(filterList);
    }
    List<Expression> parameterFilter = new ArrayList<Expression>();
    if (filter instanceof FidFilterImpl) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof BinaryTemporalOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof PropertyIsBetween) {
        createExpressionParameterList(node, 3, parameterFilter);
    } else if (filter instanceof PropertyIsNull) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof PropertyIsLike) {
        createExpressionParameterList(node, 6, parameterFilter);
    } else if (filter instanceof BinarySpatialOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof BinaryComparisonAbstract) {
        if (filter instanceof Not) {
            createExpressionParameterList(node, 1, parameterFilter);
        } else if (filter instanceof PropertyIsGreaterThan) {
            createExpressionParameterList(node, 2, parameterFilter);
        } else {
            createExpressionParameterList(node, 3, parameterFilter);
        }
    } else {
        return filter;
    }
    return filterConfig.createFilter(parameterFilter);
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) ArrayList(java.util.ArrayList) FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) Not(org.opengis.filter.Not) PropertyIsNull(org.opengis.filter.PropertyIsNull) Filter(org.opengis.filter.Filter) Expression(org.opengis.filter.expression.Expression) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) FidFilterImpl(org.geotools.filter.FidFilterImpl) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) BinaryComparisonAbstract(org.geotools.filter.BinaryComparisonAbstract) BinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan)

Example 2 with BinaryComparisonAbstract

use of org.geotools.filter.BinaryComparisonAbstract in project sldeditor by robward-scisys.

the class FilterPanelv2 method addFilter.

/**
 * Adds the filter.
 *
 * @param node the node
 * @return the filter
 */
private Filter addFilter(FilterNode node) {
    Filter filter = node.getFilter();
    FilterConfigInterface filterConfig = node.getFilterConfig();
    if (filter instanceof LogicFilterImpl) {
        List<Filter> filterList = new ArrayList<Filter>();
        createFilterList(node, filterList);
        return filterConfig.createLogicFilter(filterList);
    }
    List<Expression> parameterFilter = new ArrayList<Expression>();
    if (filter instanceof FidFilterImpl) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof BinaryTemporalOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof PropertyIsBetween) {
        createExpressionParameterList(node, 3, parameterFilter);
    } else if (filter instanceof PropertyIsNull) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof PropertyIsLike) {
        createExpressionParameterList(node, 6, parameterFilter);
    } else if (filter instanceof BinarySpatialOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof BinaryComparisonAbstract) {
        if (filter instanceof Not) {
            createExpressionParameterList(node, 1, parameterFilter);
        } else if (filter instanceof PropertyIsGreaterThan) {
            createExpressionParameterList(node, 2, parameterFilter);
        } else {
            createExpressionParameterList(node, 3, parameterFilter);
        }
    } else {
        return filter;
    }
    return filterConfig.createFilter(parameterFilter);
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) ArrayList(java.util.ArrayList) FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) Not(org.opengis.filter.Not) PropertyIsNull(org.opengis.filter.PropertyIsNull) Filter(org.opengis.filter.Filter) Expression(org.opengis.filter.expression.Expression) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) FidFilterImpl(org.geotools.filter.FidFilterImpl) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) BinaryComparisonAbstract(org.geotools.filter.BinaryComparisonAbstract) BinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan)

Example 3 with BinaryComparisonAbstract

use of org.geotools.filter.BinaryComparisonAbstract in project sldeditor by robward-scisys.

the class FilterNode method setFilter.

/**
 * Sets the filter.
 *
 * @param filter the new expression
 * @param filterConfig the filter config
 */
public void setFilter(Filter filter, FilterConfigInterface filterConfig) {
    this.filter = filter;
    this.filterConfig = filterConfig;
    setDisplayString();
    this.removeAllChildren();
    TypeManager.getInstance().reset();
    if (filterConfig != null) {
        FilterName filterName = filterConfig.getFilterConfiguration();
        if (filter instanceof Not) {
            List<Filter> childFilterList = ((LogicFilterImpl) filter).getChildren();
            if (childFilterList.isEmpty()) {
                // No child filter so add a minimum 1 to work with.
                setFilterParameter(null, filterName.getParameter(0));
            } else {
                setFilterParameter(childFilterList.get(0), filterName.getParameter(0));
            }
        } else if (filter instanceof LogicFilterImpl) {
            List<Filter> childFilterList = ((LogicFilterImpl) filter).getChildren();
            if (childFilterList.isEmpty()) {
                // No child filter so add a minimum 2 to work with.
                setFilterParameter(null, filterName.getParameter(0));
                setFilterParameter(null, filterName.getParameter(0));
            } else {
                for (Filter childFilter : childFilterList) {
                    setFilterParameter(childFilter, filterName.getParameter(0));
                }
            }
        } else if (filter instanceof BinaryTemporalOperator) {
            setExpressionParameter(((BinaryTemporalOperator) filter).getExpression1(), filterName.getParameter(0));
            setExpressionParameter(((BinaryTemporalOperator) filter).getExpression2(), filterName.getParameter(1));
        } else if (filter instanceof PropertyIsNull) {
            setExpressionParameter(((PropertyIsNull) filter).getExpression(), filterName.getParameter(0));
        } else if (filter instanceof PropertyIsBetween) {
            setExpressionParameter(((PropertyIsBetween) filter).getLowerBoundary(), filterName.getParameter(0));
            setExpressionParameter(((PropertyIsBetween) filter).getExpression(), filterName.getParameter(1));
            setExpressionParameter(((PropertyIsBetween) filter).getUpperBoundary(), filterName.getParameter(2));
        } else if (filter instanceof PropertyIsLike) {
            setExpressionParameter(((PropertyIsLike) filter).getExpression(), filterName.getParameter(0));
            setExpressionParameter(ff.literal(((PropertyIsLike) filter).getLiteral()), filterName.getParameter(1));
            setExpressionParameter(ff.literal(((PropertyIsLike) filter).getWildCard()), filterName.getParameter(2));
            setExpressionParameter(ff.literal(((PropertyIsLike) filter).getSingleChar()), filterName.getParameter(3));
            setExpressionParameter(ff.literal(((PropertyIsLike) filter).getEscape()), filterName.getParameter(4));
            setExpressionParameter(ff.literal(((PropertyIsLike) filter).isMatchingCase()), filterName.getParameter(5));
        } else if (filter instanceof BinarySpatialOperator) {
            setExpressionParameter(((BinaryComparisonAbstract) filter).getExpression1(), filterName.getParameter(0));
            setExpressionParameter(((BinaryComparisonAbstract) filter).getExpression2(), filterName.getParameter(1));
        } else if (filter instanceof BinaryComparisonAbstract) {
            setExpressionParameter(((BinaryComparisonAbstract) filter).getExpression1(), filterName.getParameter(0));
            setExpressionParameter(((BinaryComparisonAbstract) filter).getExpression2(), filterName.getParameter(1));
            // which has no matchCase parameter
            if (filterName.getParameterList().size() > 2) {
                setExpressionParameter(ff.literal(((BinaryComparisonAbstract) filter).isMatchingCase()), filterName.getParameter(2));
            }
        }
    }
}
Also used : Not(org.opengis.filter.Not) BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) PropertyIsLike(org.opengis.filter.PropertyIsLike) PropertyIsNull(org.opengis.filter.PropertyIsNull) Filter(org.opengis.filter.Filter) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) List(java.util.List) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) FilterName(com.sldeditor.filter.v2.function.FilterName) BinaryComparisonAbstract(org.geotools.filter.BinaryComparisonAbstract) BinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator)

Example 4 with BinaryComparisonAbstract

use of org.geotools.filter.BinaryComparisonAbstract in project sldeditor by robward-scisys.

the class PropertyTests method testClass.

/**
 * Test class.
 *
 * @param objUnderTest the obj under test
 */
private void testClass(FilterConfigInterface objUnderTest) {
    assertNotNull(objUnderTest.getFilterConfiguration());
    assertNotNull(objUnderTest.createFilter());
    assertNull(objUnderTest.createLogicFilter(null));
    BinaryComparisonAbstract filter = (BinaryComparisonAbstract) objUnderTest.createFilter(null);
    assertNull(filter.getExpression1());
    assertNull(filter.getExpression2());
    List<Expression> parameterList = new ArrayList<Expression>();
    parameterList.add(ff.literal("expr1"));
    filter = (BinaryComparisonAbstract) objUnderTest.createFilter(parameterList);
    assertNull(filter.getExpression1());
    assertNull(filter.getExpression2());
    parameterList.add(ff.literal("expr2"));
    parameterList.add(ff.literal(false));
    filter = (BinaryComparisonAbstract) objUnderTest.createFilter(parameterList);
    assertNotNull(filter.getExpression1());
    assertNotNull(filter.getExpression2());
    System.out.println(filter.toString());
}
Also used : Expression(org.opengis.filter.expression.Expression) ArrayList(java.util.ArrayList) BinaryComparisonAbstract(org.geotools.filter.BinaryComparisonAbstract)

Example 5 with BinaryComparisonAbstract

use of org.geotools.filter.BinaryComparisonAbstract in project sldeditor by robward-scisys.

the class TemporalTests method testBeyond.

/**
 * Unit test for the following class:
 * {@link com.sldeditor.filter.v2.function.temporal.Beyond}.
 */
@Test
public void testBeyond() {
    Beyond objUnderTest = new Beyond();
    assertNotNull(objUnderTest.getFilterConfiguration());
    assertNotNull(objUnderTest.createFilter());
    assertNull(objUnderTest.createLogicFilter(null));
    BinaryComparisonAbstract filter = (BinaryComparisonAbstract) objUnderTest.createFilter(null);
    assertNull(filter.getExpression1());
    assertNull(filter.getExpression2());
    List<Expression> parameterList = new ArrayList<Expression>();
    parameterList.add(ff.literal("expr1"));
    filter = (BinaryComparisonAbstract) objUnderTest.createFilter(parameterList);
    assertNull(filter.getExpression1());
    assertNull(filter.getExpression2());
    parameterList.add(ff.literal("expr2"));
    filter = (BinaryComparisonAbstract) objUnderTest.createFilter(parameterList);
    assertNotNull(filter.getExpression1());
    assertNotNull(filter.getExpression2());
    System.out.println(filter.toString());
}
Also used : Expression(org.opengis.filter.expression.Expression) Beyond(com.sldeditor.filter.v2.function.temporal.Beyond) ArrayList(java.util.ArrayList) BinaryComparisonAbstract(org.geotools.filter.BinaryComparisonAbstract) Test(org.junit.Test)

Aggregations

BinaryComparisonAbstract (org.geotools.filter.BinaryComparisonAbstract)5 ArrayList (java.util.ArrayList)4 Expression (org.opengis.filter.expression.Expression)4 LogicFilterImpl (org.geotools.filter.LogicFilterImpl)3 Filter (org.opengis.filter.Filter)3 Not (org.opengis.filter.Not)3 PropertyIsBetween (org.opengis.filter.PropertyIsBetween)3 PropertyIsLike (org.opengis.filter.PropertyIsLike)3 PropertyIsNull (org.opengis.filter.PropertyIsNull)3 BinarySpatialOperator (org.opengis.filter.spatial.BinarySpatialOperator)3 BinaryTemporalOperator (org.opengis.filter.temporal.BinaryTemporalOperator)3 FilterConfigInterface (com.sldeditor.filter.v2.function.FilterConfigInterface)2 FidFilterImpl (org.geotools.filter.FidFilterImpl)2 PropertyIsGreaterThan (org.opengis.filter.PropertyIsGreaterThan)2 FilterName (com.sldeditor.filter.v2.function.FilterName)1 Beyond (com.sldeditor.filter.v2.function.temporal.Beyond)1 List (java.util.List)1 Test (org.junit.Test)1