Package org.modeshape.jcr.query.model

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


        }
        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
View Full Code Here


         */
        public ConstraintBuilder isBetween( Object lowerBoundLiteral,
                                            Object upperBoundLiteral ) {
            assert lowerBoundLiteral != null;
            assert upperBoundLiteral != null;
            return this.constraintBuilder.setConstraint(new Between(left, adapt(lowerBoundLiteral), adapt(upperBoundLiteral)));
        }
View Full Code Here

    @Test
    public void shouldParseConstraintFromStringWithValidBetweenExpressionUsing() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("tableA.id BETWEEN 'lower' AND 'upper'"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(Between.class)));
        Between between = (Between)constraint;
        assertThat(between.isLowerBoundIncluded(), is(true));
        assertThat(between.isUpperBoundIncluded(), is(true));
        assertThat(between.getOperand(), is(instanceOf(PropertyValue.class)));
        PropertyValue operand = (PropertyValue)between.getOperand();
        assertThat(operand.selectorName(), is(selector.name()));
        assertThat(operand.getPropertyName(), is("id"));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat((Literal)between.getLowerBound(), is(literal("lower")));
        assertThat((Literal)between.getUpperBound(), is(literal("upper")));
    }
View Full Code Here

        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("tableA.id BETWEEN 'lower' EXCLUSIVE AND 'upper' EXCLUSIVE"),
                                                       typeSystem,
                                                       selector);
        assertThat(constraint, is(instanceOf(Between.class)));
        Between between = (Between)constraint;
        assertThat(between.isLowerBoundIncluded(), is(false));
        assertThat(between.isUpperBoundIncluded(), is(false));
        assertThat(between.getOperand(), is(instanceOf(PropertyValue.class)));
        PropertyValue operand = (PropertyValue)between.getOperand();
        assertThat(operand.selectorName(), is(selector.name()));
        assertThat(operand.getPropertyName(), is("id"));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat((Literal)between.getLowerBound(), is(literal("lower")));
        assertThat((Literal)between.getUpperBound(), is(literal("upper")));
    }
View Full Code Here

        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("tableA.id BETWEEN 'lower' AND 'upper' EXCLUSIVE"),
                                                       typeSystem,
                                                       selector);
        assertThat(constraint, is(instanceOf(Between.class)));
        Between between = (Between)constraint;
        assertThat(between.isLowerBoundIncluded(), is(true));
        assertThat(between.isUpperBoundIncluded(), is(false));
        assertThat(between.getOperand(), is(instanceOf(PropertyValue.class)));
        PropertyValue operand = (PropertyValue)between.getOperand();
        assertThat(operand.selectorName(), is(selector.name()));
        assertThat(operand.getPropertyName(), is("id"));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat((Literal)between.getLowerBound(), is(literal("lower")));
        assertThat((Literal)between.getUpperBound(), is(literal("upper")));
    }
View Full Code Here

        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("tableA.id BETWEEN 'lower' EXCLUSIVE AND 'upper'"),
                                                       typeSystem,
                                                       selector);
        assertThat(constraint, is(instanceOf(Between.class)));
        Between between = (Between)constraint;
        assertThat(between.isLowerBoundIncluded(), is(false));
        assertThat(between.isUpperBoundIncluded(), is(true));
        assertThat(between.getOperand(), is(instanceOf(PropertyValue.class)));
        PropertyValue operand = (PropertyValue)between.getOperand();
        assertThat(operand.selectorName(), is(selector.name()));
        assertThat(operand.getPropertyName(), is("id"));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat((Literal)between.getLowerBound(), is(literal("lower")));
        assertThat((Literal)between.getUpperBound(), is(literal("upper")));
    }
View Full Code Here

        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("tableA.id NOT BETWEEN 'lower' AND 'upper'"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(Not.class)));
        constraint = ((Not)constraint).getConstraint();
        assertThat(constraint, is(instanceOf(Between.class)));
        Between between = (Between)constraint;
        assertThat(between.isLowerBoundIncluded(), is(true));
        assertThat(between.isUpperBoundIncluded(), is(true));
        assertThat(between.getOperand(), is(instanceOf(PropertyValue.class)));
        PropertyValue operand = (PropertyValue)between.getOperand();
        assertThat(operand.selectorName(), is(selector.name()));
        assertThat(operand.getPropertyName(), is("id"));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat((Literal)between.getLowerBound(), is(literal("lower")));
        assertThat((Literal)between.getUpperBound(), is(literal("upper")));
    }
View Full Code Here

        assertChildren(access, project);
        PlanNode newSelect = project.getFirstChild();
        assertThat(newSelect.getType(), is(Type.SELECT));
        assertThat(newSelect.getSelectors(), is(access.getSelectors()));
        assertThat(newSelect.getParent(), is(sameInstance(project)));
        Between between = newSelect.getProperty(Property.SELECT_CRITERIA, Between.class);
        assertThat(between.getOperand(), is(select2.getProperty(Property.SELECT_CRITERIA, Comparison.class).getOperand1()));
        assertThat(between.getLowerBound(), is(select3.getProperty(Property.SELECT_CRITERIA, Comparison.class).getOperand2()));
        assertThat(between.getUpperBound(), is(select2.getProperty(Property.SELECT_CRITERIA, Comparison.class).getOperand2()));
        assertThat(between.isLowerBoundIncluded(), is(false));
        assertThat(between.isUpperBoundIncluded(), is(false));
        assertChildren(newSelect, select1);
        assertChildren(select1, source);
    }
View Full Code Here

        assertChildren(access, project);
        PlanNode newSelect = project.getFirstChild();
        assertThat(newSelect.getType(), is(Type.SELECT));
        assertThat(newSelect.getSelectors(), is(access.getSelectors()));
        assertThat(newSelect.getParent(), is(sameInstance(project)));
        Between between = newSelect.getProperty(Property.SELECT_CRITERIA, Between.class);
        assertThat(between.getOperand(), is(select2.getProperty(Property.SELECT_CRITERIA, Comparison.class).getOperand1()));
        assertThat(between.getLowerBound(), is(select3.getProperty(Property.SELECT_CRITERIA, Comparison.class).getOperand2()));
        assertThat(between.getUpperBound(), is(select2.getProperty(Property.SELECT_CRITERIA, Comparison.class).getOperand2()));
        assertThat(between.isLowerBoundIncluded(), is(true));
        assertThat(between.isUpperBoundIncluded(), is(true));
        assertChildren(newSelect, select1);
        assertChildren(select1, source);
    }
View Full Code Here

TOP

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

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.