Search in sources :

Example 1 with LeafNode

use of com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.terminal.LeafNode in project hale by halestudio.

the class CqlToMappingConditionTranslator method getLeftContents.

private LeafNode getLeftContents(AttributeExpressionImpl expression) {
    LeafNode node = new LeafNode();
    node.setPropertyName(expression.getPropertyName());
    return node;
}
Also used : LeafNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.terminal.LeafNode)

Example 2 with LeafNode

use of com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.terminal.LeafNode 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 3 with LeafNode

use of com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.terminal.LeafNode in project hale by halestudio.

the class CqlToMappingConditionTranslator method getRightContents.

private LeafNode getRightContents(Expression expression) {
    LeafNode node = new LeafNode();
    if (LiteralExpressionImpl.class.isAssignableFrom(expression.getClass())) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
        if (literal.getValue() instanceof com.vividsolutions.jts.geom.Geometry) {
            throw new IllegalArgumentException(// $NON-NLS-1$
            "Geometric literals are " + // $NON-NLS-1$
            "not supported! Found " + literal.getValue().getClass().getCanonicalName());
        }
        node.setLiteralValue(LiteralValue.getNew(literal.getValue()));
    } else if (AttributeExpressionImpl.class.isAssignableFrom(expression.getClass())) {
        AttributeExpressionImpl attribute = (AttributeExpressionImpl) expression;
        node.setPropertyName(attribute.getPropertyName());
    } else {
        throw new IllegalArgumentException(// $NON-NLS-1$
        "Unsupported expression type: " + expression.getClass().getCanonicalName());
    }
    return node;
}
Also used : AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) LeafNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.terminal.LeafNode)

Aggregations

LeafNode (com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.terminal.LeafNode)3 FilterNode (com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.FilterNode)1 AbstractComparisonNode (com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.comparison.AbstractComparisonNode)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1 CompareFilterImpl (org.geotools.filter.CompareFilterImpl)1 GeometryFilterImpl (org.geotools.filter.GeometryFilterImpl)1 LikeFilterImpl (org.geotools.filter.LikeFilterImpl)1 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)1 LogicFilterImpl (org.geotools.filter.LogicFilterImpl)1