Search in sources :

Example 6 with FilterConfigInterface

use of com.sldeditor.filter.v2.function.FilterConfigInterface in project sldeditor by robward-scisys.

the class FilterManagerTest method testGetFunctionType.

/**
 * Test method for
 * {@link com.sldeditor.filter.v2.function.FilterManager#getFunctionType(java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.filter.v2.function.FilterManager#getFilterConfig(java.lang.String)}.
 */
@Test
public void testGetFunctionType() {
    List<FilterConfigInterface> filterConfigList = FilterManager.getInstance().getFilterConfigList();
    Class<?> returnType = FilterManager.getInstance().getFunctionType(null);
    assertNull(returnType);
    // Find a known function
    for (FilterConfigInterface filterConfig : filterConfigList) {
        FilterName filterName = filterConfig.getFilterConfiguration();
        returnType = FilterManager.getInstance().getFunctionType(filterName.getFilterName());
        assertEquals(filterName.getFilterName(), filterName.getReturnType(), returnType);
        FilterConfigInterface actualFilterConfig = FilterManager.getInstance().getFilterConfig(filterName.getFilterName());
        assertEquals(filterConfig.getClass(), actualFilterConfig.getClass());
    }
}
Also used : FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) FilterName(com.sldeditor.filter.v2.function.FilterName) Test(org.junit.Test)

Example 7 with FilterConfigInterface

use of com.sldeditor.filter.v2.function.FilterConfigInterface in project sldeditor by robward-scisys.

the class MiscTests method testIsNullClass.

/**
 * {@link com.sldeditor.filter.v2.function.misc.IsNull}.
 */
@Test
public void testIsNullClass() {
    FilterConfigInterface objUnderTest = new IsNull();
    assertNotNull(objUnderTest.getFilterConfiguration());
    assertNotNull(objUnderTest.createFilter());
    assertNull(objUnderTest.createLogicFilter(null));
    CompareFilterImpl filter = (CompareFilterImpl) objUnderTest.createFilter(null);
    assertNull(filter.getExpression1());
    List<Expression> parameterList = new ArrayList<Expression>();
    filter = (CompareFilterImpl) objUnderTest.createFilter(parameterList);
    assertNull(filter.getExpression1());
    parameterList.add(ff.literal("expr1"));
    filter = (CompareFilterImpl) objUnderTest.createFilter(parameterList);
    assertNotNull(filter.getExpression1());
    System.out.println(filter.toString());
}
Also used : CompareFilterImpl(org.geotools.filter.CompareFilterImpl) Expression(org.opengis.filter.expression.Expression) ArrayList(java.util.ArrayList) FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) IsNull(com.sldeditor.filter.v2.function.misc.IsNull) Test(org.junit.Test)

Example 8 with FilterConfigInterface

use of com.sldeditor.filter.v2.function.FilterConfigInterface in project sldeditor by robward-scisys.

the class MiscTests method testIsLikeClass.

/**
 * {@link com.sldeditor.filter.v2.function.misc.IsLike}.
 */
@Test
public void testIsLikeClass() {
    FilterConfigInterface objUnderTest = new IsLike();
    assertNotNull(objUnderTest.getFilterConfiguration());
    assertNotNull(objUnderTest.createFilter());
    assertNull(objUnderTest.createLogicFilter(null));
    IsLikeExtended filter = (IsLikeExtended) objUnderTest.createFilter(null);
    assertNull(filter.getLiteral());
    assertNull(filter.getExpression());
    List<Expression> parameterList = new ArrayList<Expression>();
    try {
        parameterList.add(ff.literal(CQL.toFilter("expr1 >= 5")));
    } catch (CQLException e) {
        e.printStackTrace();
        fail();
    }
    filter = (IsLikeExtended) objUnderTest.createFilter(parameterList);
    assertNull(filter.getLiteral());
    assertNull(filter.getExpression());
    parameterList.add(ff.literal("expr2"));
    parameterList.add(ff.literal("expr3"));
    parameterList.add(ff.literal("expr4"));
    parameterList.add(ff.literal("expr5"));
    parameterList.add(ff.literal(true));
    filter = (IsLikeExtended) objUnderTest.createFilter(parameterList);
    assertNotNull(filter.getLiteral());
    assertNotNull(filter.getExpression());
    System.out.println(filter.toString());
}
Also used : IsLikeExtended(com.sldeditor.filter.v2.function.misc.IsLike.IsLikeExtended) Expression(org.opengis.filter.expression.Expression) ArrayList(java.util.ArrayList) FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) IsLike(com.sldeditor.filter.v2.function.misc.IsLike) CQLException(org.geotools.filter.text.cql2.CQLException) Test(org.junit.Test)

Example 9 with FilterConfigInterface

use of com.sldeditor.filter.v2.function.FilterConfigInterface in project sldeditor by robward-scisys.

the class FilterNode method setFilterParameter.

/**
 * Sets the filter.
 *
 * @param childFilter the new filter
 * @param parameter the parameter
 */
private void setFilterParameter(Filter childFilter, FilterNameParameter parameter) {
    FilterNode childNode = new FilterNode();
    childNode.setType(parameter.getDataType());
    FilterConfigInterface filterConfig = FilterManager.getInstance().getFilterConfig(childFilter);
    childNode.setFilter(childFilter, filterConfig);
    this.insert(childNode, this.getChildCount());
}
Also used : FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface)

Example 10 with FilterConfigInterface

use of com.sldeditor.filter.v2.function.FilterConfigInterface 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)

Aggregations

FilterConfigInterface (com.sldeditor.filter.v2.function.FilterConfigInterface)9 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 Filter (org.opengis.filter.Filter)5 Expression (org.opengis.filter.expression.Expression)4 IsLike (com.sldeditor.filter.v2.function.misc.IsLike)3 IsNull (com.sldeditor.filter.v2.function.misc.IsNull)3 BinaryComparisonAbstract (org.geotools.filter.BinaryComparisonAbstract)3 LogicFilterImpl (org.geotools.filter.LogicFilterImpl)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 FilterName (com.sldeditor.filter.v2.function.FilterName)2 Overlaps (com.sldeditor.filter.v2.function.geometry.Overlaps)2 And (com.sldeditor.filter.v2.function.logic.And)2 IsBetween (com.sldeditor.filter.v2.function.property.IsBetween)2 IsGreaterThan (com.sldeditor.filter.v2.function.property.IsGreaterThan)2