Search in sources :

Example 1 with LogicFilterImpl

use of org.geotools.filter.LogicFilterImpl in project hale by halestudio.

the class CqlToMappingConditionTranslator method createNode.

private FilterNode createNode(FilterNode parent, Filter child) {
    FilterNode childNode = null;
    if (isLogical(child)) {
        LogicFilterImpl logicFilter = (LogicFilterImpl) child;
        childNode = factory.createLogicNode(logicFilter);
        List<?> children = logicFilter.getChildren();
        for (Object c : children) {
            createNode(childNode, (Filter) c);
        }
    } else if (isComparison(child)) {
        AbstractComparisonNode comparisonNode = null;
        if (LikeFilterImpl.class.isAssignableFrom(child.getClass())) {
            LikeFilterImpl like = (LikeFilterImpl) child;
            comparisonNode = factory.createComparisonNode(like);
            comparisonNode.setLeft(getLeftContents((AttributeExpressionImpl) like.getExpression()));
            LeafNode node = new LeafNode();
            node.setLiteralValue(LiteralValue.getNew(like.getLiteral()));
            comparisonNode.setRight(node);
        } else {
            CompareFilterImpl compare = (CompareFilterImpl) child;
            comparisonNode = factory.createComparisonNode(compare);
            comparisonNode.setLeft(getLeftContents((AttributeExpressionImpl) compare.getExpression1()));
            comparisonNode.setRight(getRightContents(compare.getExpression2()));
        }
        childNode = comparisonNode;
    } else if (isGeometric(child)) {
        childNode = factory.createGeometricNode((GeometryFilterImpl) child);
    }
    if (parent != null) {
        parent.addChild(childNode);
    }
    return childNode;
}
Also used : CompareFilterImpl(org.geotools.filter.CompareFilterImpl) LikeFilterImpl(org.geotools.filter.LikeFilterImpl) FilterNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.FilterNode) LeafNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.terminal.LeafNode) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) GeometryFilterImpl(org.geotools.filter.GeometryFilterImpl) AbstractComparisonNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.comparison.AbstractComparisonNode)

Example 2 with LogicFilterImpl

use of org.geotools.filter.LogicFilterImpl 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 3 with LogicFilterImpl

use of org.geotools.filter.LogicFilterImpl 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 4 with LogicFilterImpl

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

the class FilterSubPanel method displayFilter.

/**
 * Display filter.
 *
 * @param node the node
 */
private void displayFilter(FilterNode node) {
    if (node == null) {
        return;
    }
    Filter filter = node.getFilter();
    filterPanel.setFilter(filter, node.getFilterConfig());
    Dimension boxSize = box.getPreferredSize();
    setPreferredSize(boxSize);
    boolean addFilterButtonFlag = filter instanceof LogicFilterImpl;
    btnAddFilter.setVisible(addFilterButtonFlag);
    boolean removeFilterButtonFlag = false;
    FilterNode parentNode = (FilterNode) node.getParent();
    if (parentNode != null) {
        removeFilterButtonFlag = (parentNode.getFilter() instanceof LogicFilterImpl) && (parentNode.getChildCount() > 2);
    }
    btnRemoveFilter.setVisible(removeFilterButtonFlag);
    revalidate();
}
Also used : Filter(org.opengis.filter.Filter) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) Dimension(java.awt.Dimension)

Example 5 with LogicFilterImpl

use of org.geotools.filter.LogicFilterImpl in project hale by halestudio.

the class CqlToMappingConditionTranslator method translate.

/**
 * {@inheritDoc}
 */
@Override
public ModelMappingCondition translate(Filter source) throws TranslationException {
    ModelMappingCondition filter = new ModelMappingCondition();
    FilterNode root = null;
    if (isLogical(source)) {
        LogicFilterImpl logicFilter = (LogicFilterImpl) source;
        root = factory.createLogicNode(logicFilter);
        List<?> children = logicFilter.getChildren();
        for (Object child : children) {
            createNode(root, (Filter) child);
        }
    } else // if it's a comparison filter we assume we are at the start of the tree
    if (isComparison(source)) {
        CompareFilterImpl compare = (CompareFilterImpl) source;
        AbstractComparisonNode cn = factory.createComparisonNode(compare);
        cn.setLeft(getLeftContents((AttributeExpressionImpl) compare.getExpression1()));
        cn.setRight(getRightContents(compare.getExpression2()));
        root = cn;
    } else // likewise if it's a geometric filter
    if (isGeometric(source)) {
        GeometryFilterImpl geometric = (GeometryFilterImpl) source;
        AbstractGeometricNode gn = factory.createGeometricNode(geometric);
        gn.setLeft(getLeftContents((AttributeExpressionImpl) geometric.getExpression1()));
        gn.setRight(getRightContents(geometric.getExpression2()));
        setGeometricOperationSpecifics(gn, geometric);
        root = gn;
    }
    filter.setRoot(root);
    return filter;
}
Also used : AbstractGeometricNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.geometric.AbstractGeometricNode) CompareFilterImpl(org.geotools.filter.CompareFilterImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) FilterNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.FilterNode) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) ModelMappingCondition(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelMappingCondition) GeometryFilterImpl(org.geotools.filter.GeometryFilterImpl) AbstractComparisonNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.comparison.AbstractComparisonNode)

Aggregations

LogicFilterImpl (org.geotools.filter.LogicFilterImpl)8 Filter (org.opengis.filter.Filter)6 ArrayList (java.util.ArrayList)4 PropertyIsBetween (org.opengis.filter.PropertyIsBetween)4 PropertyIsLike (org.opengis.filter.PropertyIsLike)4 PropertyIsNull (org.opengis.filter.PropertyIsNull)4 BinarySpatialOperator (org.opengis.filter.spatial.BinarySpatialOperator)4 BinaryTemporalOperator (org.opengis.filter.temporal.BinaryTemporalOperator)4 BinaryComparisonAbstract (org.geotools.filter.BinaryComparisonAbstract)3 Not (org.opengis.filter.Not)3 FilterNode (com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.FilterNode)2 AbstractComparisonNode (com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.comparison.AbstractComparisonNode)2 FilterConfigInterface (com.sldeditor.filter.v2.function.FilterConfigInterface)2 List (java.util.List)2 CompareFilterImpl (org.geotools.filter.CompareFilterImpl)2 FidFilterImpl (org.geotools.filter.FidFilterImpl)2 GeometryFilterImpl (org.geotools.filter.GeometryFilterImpl)2 PropertyIsGreaterThan (org.opengis.filter.PropertyIsGreaterThan)2 Expression (org.opengis.filter.expression.Expression)2 ModelMappingCondition (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelMappingCondition)1