Search in sources :

Example 1 with JoinCondition

use of javax.jcr.query.qom.JoinCondition in project jackrabbit by apache.

the class ChildNodeJoinConditionTest method testLeftOuterJoin.

public void testLeftOuterJoin() throws RepositoryException {
    JoinCondition c = qf.childNodeJoinCondition(LEFT, RIGHT);
    QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, c);
    List<Node[]> result = new ArrayList<Node[]>();
    result.add(new Node[] { n2, n1 });
    if (testRootNode.isNodeType(testNodeType)) {
        result.add(new Node[] { n1, testRootNode });
    } else {
        result.add(new Node[] { n1, null });
    }
    checkQOM(qom, result.toArray(new Node[result.size()][]));
}
Also used : Node(javax.jcr.Node) ArrayList(java.util.ArrayList) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) JoinCondition(javax.jcr.query.qom.JoinCondition)

Example 2 with JoinCondition

use of javax.jcr.query.qom.JoinCondition in project jackrabbit by apache.

the class ChildNodeJoinConditionTest method testInnerJoin.

public void testInnerJoin() throws RepositoryException {
    JoinCondition c = qf.childNodeJoinCondition(LEFT, RIGHT);
    QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, c);
    checkQOM(qom, new Node[][] { { n2, n1 } });
}
Also used : QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) JoinCondition(javax.jcr.query.qom.JoinCondition)

Example 3 with JoinCondition

use of javax.jcr.query.qom.JoinCondition in project jackrabbit by apache.

the class DescendantNodeJoinConditionTest method testLeftOuterJoin.

public void testLeftOuterJoin() throws RepositoryException {
    JoinCondition c = qf.descendantNodeJoinCondition(LEFT, RIGHT);
    QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, c);
    List<Node[]> result = new ArrayList<Node[]>();
    result.add(new Node[] { n2, n1 });
    // for each ancestor-or-self of testRootNode check
    // whether it is of type testNodeType and add
    // two matches in that case
    Node n = testRootNode;
    for (; ; ) {
        if (n.isNodeType(testNodeType)) {
            result.add(new Node[] { n1, n });
            result.add(new Node[] { n2, n });
        }
        if (n.getDepth() == 0) {
            break;
        } else {
            n = n.getParent();
        }
    }
    if (result.size() == 1) {
        // n1 not yet covered
        result.add(new Node[] { n1, null });
    }
    checkQOM(qom, result.toArray(new Node[result.size()][]));
}
Also used : Node(javax.jcr.Node) ArrayList(java.util.ArrayList) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) JoinCondition(javax.jcr.query.qom.JoinCondition)

Example 4 with JoinCondition

use of javax.jcr.query.qom.JoinCondition in project jackrabbit by apache.

the class DescendantNodeJoinConditionTest method testInnerJoin.

public void testInnerJoin() throws RepositoryException {
    JoinCondition c = qf.descendantNodeJoinCondition(LEFT, RIGHT);
    QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, c);
    checkQOM(qom, new Node[][] { { n2, n1 } });
}
Also used : QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) JoinCondition(javax.jcr.query.qom.JoinCondition)

Example 5 with JoinCondition

use of javax.jcr.query.qom.JoinCondition in project jackrabbit by apache.

the class OrderingTest method createQuery.

protected QueryObjectModel createQuery(Ordering[] orderings) throws RepositoryException {
    JoinCondition c = qf.equiJoinCondition(LEFT, propertyName1, RIGHT, propertyName2);
    QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, c);
    return qf.createQuery(qom.getSource(), qom.getConstraint(), orderings, qom.getColumns());
}
Also used : QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) JoinCondition(javax.jcr.query.qom.JoinCondition)

Aggregations

JoinCondition (javax.jcr.query.qom.JoinCondition)16 QueryObjectModel (javax.jcr.query.qom.QueryObjectModel)13 ArrayList (java.util.ArrayList)2 Node (javax.jcr.Node)2 Selector (javax.jcr.query.qom.Selector)2 ChildNodeJoinCondition (javax.jcr.query.qom.ChildNodeJoinCondition)1 DescendantNodeJoinCondition (javax.jcr.query.qom.DescendantNodeJoinCondition)1 EquiJoinCondition (javax.jcr.query.qom.EquiJoinCondition)1 Join (javax.jcr.query.qom.Join)1 SameNodeJoinCondition (javax.jcr.query.qom.SameNodeJoinCondition)1 Source (javax.jcr.query.qom.Source)1 JoinType (org.apache.jackrabbit.commons.query.qom.JoinType)1