Package org.modeshape.jcr.query.model

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


    protected QueryCommand query( String subquery ) {
        return parser.parseQuery(subquery, typeSystem);
    }

    protected Subquery subquery( String subquery ) {
        return new Subquery(query(subquery));
    }
View Full Code Here


    @Test
    public void shouldParseStaticOperandWithSubquery() {
        QueryCommand expected = parser.parseQuery(tokens("SELECT * FROM tableA"), typeSystem);
        StaticOperand operand = parser.parseStaticOperand(tokens("SELECT * FROM tableA"), typeSystem);
        assertThat(operand, is(instanceOf(Subquery.class)));
        Subquery subquery = (Subquery)operand;
        assertThat(subquery.getQuery(), is(expected));
    }
View Full Code Here

    public void shouldParseStaticOperandWithSubqueryWithoutConsumingExtraTokens() {
        QueryCommand expected = parser.parseQuery(tokens("SELECT * FROM tableA"), typeSystem);
        TokenStream tokens = tokens("SELECT * FROM tableA)");
        StaticOperand operand = parser.parseStaticOperand(tokens, typeSystem);
        assertThat(operand, is(instanceOf(Subquery.class)));
        Subquery subquery = (Subquery)operand;
        assertThat(subquery.getQuery(), is(expected));
        assertThat(tokens.canConsume(')'), is(true));
    }
View Full Code Here

    public static StaticOperand replaceSubqueriesWithBindVariables( QueryContext context,
                                                                    StaticOperand staticOperand,
                                                                    Map<String, Subquery> subqueriesByVariableName ) {
        if (staticOperand instanceof Subquery) {
            Subquery subquery = (Subquery)staticOperand;
            // Create a variable name ...
            int i = 1;
            String variableName = Subquery.VARIABLE_PREFIX;
            while (context.getVariables().containsKey(variableName + i)) {
                ++i;
View Full Code Here

        List<String> varNames = new ArrayList<String>(subqueriesByVariableName.keySet());
        Collections.sort(varNames);
        Collections.reverse(varNames);

        for (String varName : varNames) {
            Subquery subquery = subqueriesByVariableName.get(varName);
            // Plan out the subquery ...
            PlanNode subqueryNode = createPlan(context, subquery.getQuery());
            setSubqueryVariableName(subqueryNode, varName);

            // Create a DEPENDENT_QUERY node, with the subquery on the LHS (so it is executed first) ...
            PlanNode depQuery = new PlanNode(Type.DEPENDENT_QUERY);
            depQuery.addChildren(subqueryNode, plan);
View Full Code Here

         *
         * @param subquery the subquery
         * @return the constraint builder; never null
         */
        public ConstraintBuilder subquery( QueryCommand subquery ) {
            return subquery(new Subquery(subquery));
        }
View Full Code Here

            this.constraintBuilder = constraintBuilder;
        }

        public ConstraintBuilder isInSubquery( QueryCommand subquery ) {
            CheckArg.isNotNull(subquery, "subquery");
            return this.constraintBuilder.setConstraint(new SetCriteria(left, new Subquery(subquery)));
        }
View Full Code Here

        }

        protected StaticOperand adapt( Object literalOrSubquery ) {
            if (literalOrSubquery instanceof QueryCommand) {
                // Wrap the query in a subquery ...
                return new Subquery((QueryCommand)literalOrSubquery);
            }
            if (literalOrSubquery instanceof Subquery) {
                return (Subquery)literalOrSubquery;
            }
            if (literalOrSubquery instanceof Literal) {
View Full Code Here

        }
        return bindVariableName(value);
    }

    protected Subquery subquery( QueryCommand queryCommand ) {
        return new Subquery(queryCommand);
    }
View Full Code Here

         *
         * @param subquery the subquery
         * @return the constraint builder; never null
         */
        public AndBuilder<UpperBoundary> subquery( QueryCommand subquery ) {
            return subquery(new Subquery(subquery));
        }
View Full Code Here

TOP

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

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.