Package org.modeshape.jcr.query.model

Examples of org.modeshape.jcr.query.model.DynamicOperand


            if (replacement == null) return search;
            return new FullTextSearch(replacement, search.getPropertyName(), search.fullTextSearchExpression());
        }
        if (constraint instanceof Between) {
            Between between = (Between)constraint;
            DynamicOperand lhs = between.getOperand();
            StaticOperand lower = between.getLowerBound(); // Current only a literal; therefore, no reference to selector
            StaticOperand upper = between.getUpperBound(); // Current only a literal; therefore, no reference to selector
            DynamicOperand newLhs = replaceReferencesToRemovedSource(context, lhs, rewrittenSelectors);
            if (lhs == newLhs) return between;
            return new Between(newLhs, lower, upper, between.isLowerBoundIncluded(), between.isUpperBoundIncluded());
        }
        if (constraint instanceof Comparison) {
            Comparison comparison = (Comparison)constraint;
            DynamicOperand lhs = comparison.getOperand1();
            StaticOperand rhs = comparison.getOperand2(); // Current only a literal; therefore, no reference to selector
            DynamicOperand newLhs = replaceReferencesToRemovedSource(context, lhs, rewrittenSelectors);
            if (lhs == newLhs) return comparison;
            return new Comparison(newLhs, comparison.operator(), rhs);
        }
        if (constraint instanceof SetCriteria) {
            SetCriteria criteria = (SetCriteria)constraint;
            DynamicOperand lhs = criteria.leftOperand();
            DynamicOperand newLhs = replaceReferencesToRemovedSource(context, lhs, rewrittenSelectors);
            if (lhs == newLhs) return constraint;
            return new SetCriteria(newLhs, criteria.rightOperands());
        }
        return constraint;
    }
View Full Code Here


                    // The selector names and Ordering objects needs to be changed ...
                    List<Ordering> orderings = node.getPropertyAsList(Property.SORT_ORDER_BY, Ordering.class);
                    List<Ordering> newOrderings = new ArrayList<Ordering>(orderings.size());
                    node.getSelectors().clear();
                    for (Ordering ordering : orderings) {
                        DynamicOperand operand = ordering.getOperand();
                        DynamicOperand newOperand = replaceViewReferences(context, operand, mappings, node);
                        if (newOperand != operand) {
                            ordering = new Ordering(newOperand, ordering.order(), ordering.nullOrder());
                        }
                        node.addSelectors(Visitors.getSelectorsReferencedBy(ordering));
                        newOrderings.add(ordering);
View Full Code Here

            return new FullTextSearch(sourceColumn.selectorName(), sourceColumn.getPropertyName(),
                                      search.fullTextSearchExpression(), search.getFullTextSearchExpression());
        }
        if (constraint instanceof SetCriteria) {
            SetCriteria set = (SetCriteria)constraint;
            DynamicOperand oldLeft = set.leftOperand();
            Set<SelectorName> selectorNames = oldLeft.selectorNames();
            if (selectorNames.size() == 1 && !selectorNames.contains(mapping.getOriginalName())) return set;
            DynamicOperand newLeft = replaceViewReferences(context, oldLeft, mapping, node);
            if (newLeft == oldLeft) return set;
            return new SetCriteria(newLeft, set.rightOperands());
        }
        if (constraint instanceof Between) {
            Between between = (Between)constraint;
            DynamicOperand lhs = between.getOperand();
            StaticOperand lower = between.getLowerBound(); // Current only a literal; therefore, no reference to selector
            StaticOperand upper = between.getUpperBound(); // Current only a literal; therefore, no reference to selector
            DynamicOperand newLhs = replaceViewReferences(context, lhs, mapping, node);
            if (lhs == newLhs) return between;
            return new Between(newLhs, lower, upper, between.isLowerBoundIncluded(), between.isUpperBoundIncluded());
        }
        if (constraint instanceof Comparison) {
            Comparison comparison = (Comparison)constraint;
            DynamicOperand lhs = comparison.getOperand1();
            StaticOperand rhs = comparison.getOperand2(); // Current only a literal; therefore, no reference to selector
            DynamicOperand newLhs = replaceViewReferences(context, lhs, mapping, node);
            if (lhs == newLhs) return comparison;
            return new Comparison(newLhs, comparison.operator(), rhs);
        }
        return constraint;
    }
View Full Code Here

                                                        DynamicOperand operand,
                                                        ColumnMapping mapping,
                                                        PlanNode node ) {
        if (operand instanceof ArithmeticOperand) {
            ArithmeticOperand arith = (ArithmeticOperand)operand;
            DynamicOperand newLeft = replaceViewReferences(context, arith.getLeft(), mapping, node);
            DynamicOperand newRight = replaceViewReferences(context, arith.getRight(), mapping, node);
            return new ArithmeticOperand(newLeft, arith.operator(), newRight);
        }
        if (operand instanceof FullTextSearchScore) {
            FullTextSearchScore score = (FullTextSearchScore)operand;
            if (!mapping.getOriginalName().equals(score.selectorName())) return score;
            if (mapping.isMappedToSingleSelector()) {
                return new FullTextSearchScore(mapping.getSingleMappedSelectorName());
            }
            // There are multiple mappings, so we have to create a composite score ...
            DynamicOperand composite = null;
            for (SelectorName name : mapping.getMappedSelectorNames()) {
                FullTextSearchScore mappedScore = new FullTextSearchScore(name);
                if (composite == null) {
                    composite = mappedScore;
                } else {
View Full Code Here

        if (constraint instanceof FullTextSearch) {
            return constraint;
        }
        if (constraint instanceof Between) {
            Between between = (Between)constraint;
            DynamicOperand lhs = replaceAliasesWithProperties(context, between.getOperand(), propertyByAlias);
            StaticOperand lower = between.getLowerBound(); // Current only a literal; therefore, no alias
            StaticOperand upper = between.getUpperBound(); // Current only a literal; therefore, no alias
            if (lower == between.getOperand()) return between;
            return new Between(lhs, lower, upper, between.isLowerBoundIncluded(), between.isUpperBoundIncluded());
        }
        if (constraint instanceof Comparison) {
            Comparison comparison = (Comparison)constraint;
            DynamicOperand lhs = replaceAliasesWithProperties(context, comparison.getOperand1(), propertyByAlias);
            if (lhs == comparison.getOperand1()) return comparison;
            return new Comparison(lhs, comparison.operator(), comparison.getOperand2());
        }
        if (constraint instanceof Relike) {
            Relike relike = (Relike)constraint;
            StaticOperand op1 = relike.getOperand1();
            PropertyValue op2 = relike.getOperand2();
            PropertyValue newOp2 = replaceAliasesWithProperties(context, op2, propertyByAlias);
            if (op2 == newOp2) return relike;
            return new Relike(op1, op2);
        }
        if (constraint instanceof SetCriteria) {
            SetCriteria criteria = (SetCriteria)constraint;
            DynamicOperand lhs = replaceAliasesWithProperties(context, criteria.leftOperand(), propertyByAlias);
            if (lhs == criteria.leftOperand()) return criteria;
            return new SetCriteria(lhs, criteria.rightOperands());
        }
        return constraint;
    }
View Full Code Here

    public static DynamicOperand replaceAliasesWithProperties( QueryContext context,
                                                               DynamicOperand operand,
                                                               Map<String, String> propertyByAlias ) {
        if (operand instanceof ArithmeticOperand) {
            ArithmeticOperand arith = (ArithmeticOperand)operand;
            DynamicOperand newLeft = replaceAliasesWithProperties(context, arith.getLeft(), propertyByAlias);
            DynamicOperand newRight = replaceAliasesWithProperties(context, arith.getRight(), propertyByAlias);
            if (newLeft == arith.getLeft() && newRight == arith.getRight()) return arith;
            return new ArithmeticOperand(newLeft, arith.operator(), newRight);
        }
        if (operand instanceof FullTextSearchScore) {
            return operand;
        }
        if (operand instanceof Length) {
            Length operation = (Length)operand;
            PropertyValue value = operation.getPropertyValue();
            PropertyValue newValue = replaceAliasesWithProperties(context, value, propertyByAlias);
            if (newValue == value) return operation;
            return new Length(newValue);
        }
        if (operand instanceof LowerCase) {
            LowerCase operation = (LowerCase)operand;
            DynamicOperand oldOperand = operation.getOperand();
            DynamicOperand newOperand = replaceAliasesWithProperties(context, oldOperand, propertyByAlias);
            if (oldOperand == newOperand) return operation;
            return new LowerCase(newOperand);
        }
        if (operand instanceof UpperCase) {
            UpperCase operation = (UpperCase)operand;
            DynamicOperand oldOperand = operation.getOperand();
            DynamicOperand newOperand = replaceAliasesWithProperties(context, oldOperand, propertyByAlias);
            if (oldOperand == newOperand) return operation;
            return new UpperCase(newOperand);
        }
        if (operand instanceof NodeName) {
            return operand;
View Full Code Here

        if (constraint instanceof FullTextSearch) {
            return constraint;
        }
        if (constraint instanceof Between) {
            Between between = (Between)constraint;
            DynamicOperand lhs = between.getOperand();
            StaticOperand lower = between.getLowerBound(); // Current only a literal; therefore, no reference to selector
            StaticOperand upper = between.getUpperBound(); // Current only a literal; therefore, no reference to selector
            StaticOperand newLower = replaceSubqueriesWithBindVariables(context, lower, subqueriesByVariableName);
            StaticOperand newUpper = replaceSubqueriesWithBindVariables(context, upper, subqueriesByVariableName);
            if (lower == newLower && upper == newUpper) return between;
            return new Between(lhs, newLower, newUpper, between.isLowerBoundIncluded(), between.isUpperBoundIncluded());
        }
        if (constraint instanceof Comparison) {
            Comparison comparison = (Comparison)constraint;
            DynamicOperand lhs = comparison.getOperand1();
            StaticOperand rhs = comparison.getOperand2(); // Current only a literal; therefore, no reference to selector
            StaticOperand newRhs = replaceSubqueriesWithBindVariables(context, rhs, subqueriesByVariableName);
            if (rhs == newRhs) return comparison;
            return new Comparison(lhs, comparison.operator(), newRhs);
        }
        if (constraint instanceof Relike) {
            Relike relike = (Relike)constraint;
            StaticOperand op1 = relike.getOperand1();
            PropertyValue op2 = relike.getOperand2();
            StaticOperand newOp1 = replaceSubqueriesWithBindVariables(context, op1, subqueriesByVariableName);
            if (op1 == newOp1) return relike;
            return new Relike(op1, op2);
        }
        if (constraint instanceof SetCriteria) {
            SetCriteria criteria = (SetCriteria)constraint;
            DynamicOperand lhs = criteria.leftOperand();
            boolean foundSubquery = false;
            List<StaticOperand> newStaticOperands = new LinkedList<StaticOperand>();
            for (StaticOperand rhs : criteria.rightOperands()) {
                StaticOperand newRhs = replaceSubqueriesWithBindVariables(context, rhs, subqueriesByVariableName);
                newStaticOperands.add(newRhs);
View Full Code Here

        // this.left = left;
        // return this;
        // }

        protected ComparisonBuilder comparisonBuilder( DynamicOperand right ) {
            DynamicOperand leftOperand = null;
            // If the left operand is an arithmetic operand, then we need to check the operator precedence ...
            if (left instanceof ArithmeticOperand) {
                ArithmeticOperand leftArith = (ArithmeticOperand)left;
                ArithmeticOperator operator = leftArith.operator();
                if (this.operator.precedes(operator)) {
                    // Need to do create an operand with leftArith.right and right
                    DynamicOperand inner = new ArithmeticOperand(leftArith.getRight(), this.operator, right);
                    leftOperand = new ArithmeticOperand(leftArith.getLeft(), operator, inner);
                } else {
                    // the left preceds this, so we can add the new operand on top ...
                    leftOperand = new ArithmeticOperand(leftArith, operator, right);
                }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.query.model.DynamicOperand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.