Package org.modeshape.jcr.query.model

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


            Set<String> languages = queryParsers.getLanguages();
            throw new InvalidQueryException(JcrI18n.invalidQueryLanguage.text(language, languages));
        }
        try {
            // Parsing must be done now ...
            QueryCommand command = parser.parseQuery(expression, typeSystem);
            if (command == null) {
                // The query is not well-formed and cannot be parsed ...
                throw new InvalidQueryException(JcrI18n.queryCannotBeParsedUsingLanguage.text(language, expression));
            }
            // Set up the hints ...
View Full Code Here


     *
     * @return the resulting query command; never null
     * @see #clear()
     */
    public QueryCommand query() {
        QueryCommand result = new Query(source, constraint, orderings, columns, limit, distinct);
        if (this.firstQuery != null) {
            // EXCEPT has a higher precedence than INTERSECT or UNION, so if the first query is
            // an INTERSECT or UNION SetQuery, the result should be applied to the RHS of the previous set ...
            if (firstQuery instanceof SetQuery && firstQuerySetOperation == Operation.EXCEPT) {
                SetQuery setQuery = (SetQuery)firstQuery;
                QueryCommand left = setQuery.getLeft();
                QueryCommand right = setQuery.getRight();
                SetQuery exceptQuery = new SetQuery(right, Operation.EXCEPT, result, firstQueryAll);
                result = new SetQuery(left, setQuery.operation(), exceptQuery, setQuery.isAll());
            } else {
                result = new SetQuery(this.firstQuery, this.firstQuerySetOperation, result, this.firstQueryAll);
            }
View Full Code Here

    public void shouldProducePlanWhenUsingSubquery() {
        // Define the schemata ...
        schemata = schemataBuilder.addTable("someTable", "column1", "column2", "column3")
                                  .addTable("otherTable", "columnA", "columnB").build();
        // Define the subquery command ...
        QueryCommand subquery = builder.select("columnA").from("otherTable").query();
        builder = new QueryBuilder(typeSystem);

        // Define the query command (which uses the subquery) ...
        query = builder.selectStar().from("someTable").where().path("someTable").isLike(subquery).end().query();
        initQueryContext();
View Full Code Here

        // Define the schemata ...
        schemata = schemataBuilder.addTable("someTable", "column1", "column2", "column3")
                                  .addTable("otherTable", "columnA", "columnB").addTable("stillOther", "columnX", "columnY")
                                  .build();
        // Define the innermost subquery command ...
        QueryCommand subquery2 = builder.select("columnY").from("stillOther").where().propertyValue("stillOther", "columnX")
                                        .isLessThan().cast(3).asLong().end().query();
        builder = new QueryBuilder(typeSystem);

        // Define the outer subquery command ...
        QueryCommand subquery1 = builder.select("columnA").from("otherTable").where().propertyValue("otherTable", "columnB")
                                        .isEqualTo(subquery2).end().query();
        builder = new QueryBuilder(typeSystem);

        // Define the query command (which uses the subquery) ...
        query = builder.selectStar().from("someTable").where().path("someTable").isLike(subquery1).end().query();
View Full Code Here

        // Define the schemata ...
        schemata = schemataBuilder.addTable("someTable", "column1", "column2", "column3")
                                  .addTable("otherTable", "columnA", "columnB").addTable("stillOther", "columnX", "columnY")
                                  .build();
        // Define the first subquery command ...
        QueryCommand subquery1 = builder.select("columnA").from("otherTable").where().propertyValue("otherTable", "columnB")
                                        .isEqualTo("winner").end().query();
        builder = new QueryBuilder(typeSystem);

        // Define the second subquery command ...
        QueryCommand subquery2 = builder.select("columnY").from("stillOther").where().propertyValue("stillOther", "columnX")
                                        .isLessThan().cast(3).asLong().end().query();
        builder = new QueryBuilder(typeSystem);

        // Define the query command (which uses the subquery) ...
        query = builder.selectStar().from("someTable").where().path("someTable").isLike(subquery2).and()
View Full Code Here

    // ----------------------------------------------------------------------------------------------------------------
    // Utility methods
    // ----------------------------------------------------------------------------------------------------------------
    protected Query parse( String query ) {
        QueryCommand command = parseCommand(query);
        assertThat(command, is(instanceOf(Query.class)));
        return (Query)command;
    }
View Full Code Here

        assertThat(command, is(instanceOf(Query.class)));
        return (Query)command;
    }

    protected SetQuery parseSetQuery( String query ) {
        QueryCommand command = parser.parseQuery(query, typeSystem);
        assertThat(command, is(instanceOf(SetQuery.class)));
        return (SetQuery)command;
    }
View Full Code Here

    }

    @FixFor( "MODE-869" )
    @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

    }

    @FixFor( "MODE-869" )
    @Test
    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));
View Full Code Here

    // ----------------------------------------------------------------------------------------------------------------
    // Utility methods
    // ----------------------------------------------------------------------------------------------------------------
    protected Query parse( String query ) {
        QueryCommand command = parseCommand(query);
        assertThat(command, is(instanceOf(Query.class)));
        return (Query)command;
    }
View Full Code Here

TOP

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

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.