Package org.modeshape.jcr.query.model

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


    public void shouldParseSelectStarFromTwoJoinedSourcesWithWhereContainingJoinCriteria() {
        query = parse("SELECT * FROM [mgnl:content] JOIN [acme:stuff] ON ISSAMENODE([mgnl:content],[acme:stuff])");
        // SELECT * ...
        assertThat(query.columns().isEmpty(), is(true));
        // FROM ...
        Join join = isJoin(query.source());
        assertThat(join.getLeft(), is((Source)namedSelector(selectorName("mgnl:content"))));
        assertThat(join.getRight(), is((Source)namedSelector(selectorName("acme:stuff"))));
        assertThat(join.type(), is(JoinType.INNER));
        SameNodeJoinCondition joinCondition = isSameNodeJoinCondition(join.getJoinCondition());
        assertThat(joinCondition.selector1Name(), is(selectorName("mgnl:content")));
        assertThat(joinCondition.selector2Name(), is(selectorName("acme:stuff")));
        assertThat(joinCondition.getSelector2Path(), is(nullValue()));
        // WHERE ...
        assertThat(query.constraint(), is(nullValue()));
View Full Code Here


    public void shouldParseSelectStarFromThreeJoinedSourcesWithWhereContainingJoinCriteria() {
        query = parse("SELECT * FROM [mgnl:content] JOIN [acme:stuff] ON ISSAMENODE([mgnl:content],[acme:stuff]) JOIN [foo:bar] ON ISSAMENODE([mgnl:content],[foo:bar])");
        // SELECT * ...
        assertThat(query.columns().isEmpty(), is(true));
        // FROM ...
        Join join = isJoin(query.source());
        Join join2 = isJoin(join.getLeft());
        assertThat(join2.getLeft(), is((Source)namedSelector(selectorName("mgnl:content"))));
        assertThat(join2.getRight(), is((Source)namedSelector(selectorName("acme:stuff"))));
        assertThat(join2.type(), is(JoinType.INNER));
        SameNodeJoinCondition joinCondition2 = isSameNodeJoinCondition(join2.getJoinCondition());
        assertThat(joinCondition2.selector1Name(), is(selectorName("mgnl:content")));
        assertThat(joinCondition2.selector2Name(), is(selectorName("acme:stuff")));
        assertThat(joinCondition2.getSelector2Path(), is(nullValue()));

        assertThat(join.getRight(), is((Source)namedSelector(selectorName("foo:bar"))));
View Full Code Here

    public void shouldParseSelectStarFromEquijoinAndAdditionalCriteria() {
        query = parse("SELECT * FROM [modetest:queryable] JOIN [mix:referenceable] ON ISSAMENODE([modetest:queryable],[mix:referenceable]) WHERE PATH([modetest:queryable]) LIKE '/testroot/someQueryableNodeD/%'");
        // SELECT * ...
        assertThat(query.columns().isEmpty(), is(true));
        // FROM ...
        Join join = isJoin(query.source());
        assertThat(join.getLeft(), is((Source)namedSelector(selectorName("modetest:queryable"))));
        assertThat(join.getRight(), is((Source)namedSelector(selectorName("mix:referenceable"))));
        assertThat(join.type(), is(JoinType.INNER));
        SameNodeJoinCondition joinCondition = isSameNodeJoinCondition(join.getJoinCondition());
        assertThat(joinCondition.selector1Name(), is(selectorName("modetest:queryable")));
        assertThat(joinCondition.selector2Name(), is(selectorName("mix:referenceable")));
        assertThat(joinCondition.getSelector2Path(), is(nullValue()));
        // WHERE ...
        Comparison comparison = isComparison(query.constraint());
View Full Code Here

    public void shouldParseDescendantNodeJoinWithNoCriteria() {
        query = parse("select * from [lom:Metadata] as lom join [lom:LangString] as lang on isdescendantnode(lang,lom)");
        // SELECT * ...
        assertThat(query.columns().isEmpty(), is(true));
        // FROM ...
        Join join = isJoin(query.source());
        assertThat(join.getLeft(), is((Source)namedSelector(selectorName("lom:Metadata"), selectorName("lom"))));
        assertThat(join.getRight(), is((Source)namedSelector(selectorName("lom:LangString"), selectorName("lang"))));
        assertThat(join.type(), is(JoinType.INNER));
        DescendantNodeJoinCondition joinCondition = isDescendantNodeJoinCondition(join.getJoinCondition());
        assertThat(joinCondition.ancestorSelectorName(), is(selectorName("lom")));
        assertThat(joinCondition.descendantSelectorName(), is(selectorName("lang")));
    }
View Full Code Here

        assertThat(query.columns().get(1).getPropertyName(), is("text"));
        assertThat(query.columns().get(2).selectorName(), is(selectorName("post")));
        assertThat(query.columns().get(2).getColumnName(), is("user"));
        assertThat(query.columns().get(2).getPropertyName(), is("user"));
        // FROM ...
        Join join = isJoin(query.source());
        assertThat(join.getLeft(), is((Source)namedSelector(selectorName("fincayra.Post"), selectorName("post"))));
        assertThat(join.getRight(), is((Source)namedSelector(selectorName("fincayra.User"), selectorName("u"))));
        assertThat(join.type(), is(JoinType.INNER));
        EquiJoinCondition joinCondition = isEquiJoinCondition(join.getJoinCondition());
        assertThat(joinCondition.getSelector1Name(), is("post"));
        assertThat(joinCondition.getSelector2Name(), is("u"));
        assertThat(joinCondition.getProperty1Name(), is("user"));
        assertThat(joinCondition.getProperty2Name(), is("jcr:uuid"));
View Full Code Here

    public void shouldParseSelectStarFromTwoJoinedSourcesWithWhereContainingJoinCriteria() {
        query = parse("SELECT * FROM mgnl:content, acme:stuff WHERE mgnl:content.jcr:path = acme:stuff.jcr:path");
        // SELECT * ...
        assertThat(query.columns().isEmpty(), is(true));
        // FROM ...
        Join join = isJoin(query.source());
        assertThat(join.getLeft(), is((Source)namedSelector(selectorName("mgnl:content"))));
        assertThat(join.getRight(), is((Source)namedSelector(selectorName("acme:stuff"))));
        assertThat(join.type(), is(JoinType.INNER));
        SameNodeJoinCondition joinCondition = isSameNodeJoinCondition(join.getJoinCondition());
        assertThat(joinCondition.selector1Name(), is(selectorName("mgnl:content")));
        assertThat(joinCondition.selector2Name(), is(selectorName("acme:stuff")));
        assertThat(joinCondition.getSelector2Path(), is(nullValue()));
        // WHERE ...
        assertThat(query.constraint(), is(nullValue()));
View Full Code Here

    public void shouldParseSelectStarFromThreeJoinedSourcesWithWhereContainingJoinCriteria() {
        query = parse("SELECT * FROM mgnl:content, acme:stuff, foo:bar WHERE mgnl:content.jcr:path = acme:stuff.jcr:path AND mgnl:content.jcr:path = foo:bar.jcr:path");
        // SELECT * ...
        assertThat(query.columns().isEmpty(), is(true));
        // FROM ...
        Join join = isJoin(query.source());
        Join join2 = isJoin(join.getLeft());
        assertThat(join2.getLeft(), is((Source)namedSelector(selectorName("mgnl:content"))));
        assertThat(join2.getRight(), is((Source)namedSelector(selectorName("acme:stuff"))));
        assertThat(join2.type(), is(JoinType.INNER));
        SameNodeJoinCondition joinCondition2 = isSameNodeJoinCondition(join2.getJoinCondition());
        assertThat(joinCondition2.selector1Name(), is(selectorName("mgnl:content")));
        assertThat(joinCondition2.selector2Name(), is(selectorName("acme:stuff")));
        assertThat(joinCondition2.getSelector2Path(), is(nullValue()));

        assertThat(join.getRight(), is((Source)namedSelector(selectorName("foo:bar"))));
View Full Code Here

    public void shouldParseSelectStarFromEquijoinAndAdditionalCriteria() {
        query = parse("SELECT * FROM modetest:queryable, mix:referenceable WHERE modetest:queryable.jcr:path = mix:referenceable.jcr:path AND jcr:path LIKE '/testroot/someQueryableNodeD/%'");
        // SELECT * ...
        assertThat(query.columns().isEmpty(), is(true));
        // FROM ...
        Join join = isJoin(query.source());
        assertThat(join.getLeft(), is((Source)namedSelector(selectorName("modetest:queryable"))));
        assertThat(join.getRight(), is((Source)namedSelector(selectorName("mix:referenceable"))));
        assertThat(join.type(), is(JoinType.INNER));
        SameNodeJoinCondition joinCondition = isSameNodeJoinCondition(join.getJoinCondition());
        assertThat(joinCondition.selector1Name(), is(selectorName("modetest:queryable")));
        assertThat(joinCondition.selector2Name(), is(selectorName("mix:referenceable")));
        assertThat(joinCondition.getSelector2Path(), is(nullValue()));
        // WHERE ...
        Comparison comparison = isComparison(query.constraint());
View Full Code Here

        protected QueryBuilder createJoin( JoinCondition condition ) {
            // CROSS joins have a higher precedence, so we may need to adjust the existing left side in this case...
            if (type == JoinType.CROSS && source instanceof Join && ((Join)source).type() != JoinType.CROSS) {
                // A CROSS join follows a non-CROSS join, so the CROSS join becomes precendent ...
                Join left = (Join)source;
                Join cross = new Join(left.getRight(), type, rightSource, condition);
                source = new Join(left.getLeft(), left.type(), cross, left.getJoinCondition());
            } else {
                // Otherwise, just create using usual precedence ...
                source = new Join(source, type, rightSource, condition);
            }
            return QueryBuilder.this;
        }
View Full Code Here

    protected Join join( Source left,
                         JoinType joinType,
                         Source right,
                         JoinCondition joinCondition ) {
        return new Join(left, joinType, right, joinCondition);
    }
View Full Code Here

TOP

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

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.