Search in sources :

Example 11 with QueryObjectModel

use of javax.jcr.query.qom.QueryObjectModel 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 12 with QueryObjectModel

use of javax.jcr.query.qom.QueryObjectModel 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 13 with QueryObjectModel

use of javax.jcr.query.qom.QueryObjectModel 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 14 with QueryObjectModel

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

the class DescendantNodeTest method testDescendantNode.

public void testDescendantNode() throws RepositoryException {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    superuser.save();
    QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("s", testRoot), null, null);
    checkQOM(qom, new Node[] { n });
}
Also used : Node(javax.jcr.Node) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Example 15 with QueryObjectModel

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

the class DescendantNodeTest method testDescendantNodesDoNotMatchSelector.

public void testDescendantNodesDoNotMatchSelector() throws RepositoryException, NotExecutableException {
    testRootNode.addNode(nodeName1, testNodeType);
    superuser.save();
    NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
    NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
    NodeType testNt = ntMgr.getNodeType(testNodeType);
    while (it.hasNext()) {
        NodeType nt = it.nextNodeType();
        if (!testNt.isNodeType(nt.getName())) {
            // perform test
            QueryObjectModel qom = qf.createQuery(qf.selector(nt.getName(), "s"), qf.descendantNode("s", testRoot), null, null);
            checkQOM(qom, new Node[] {});
            return;
        }
    }
    throw new NotExecutableException("No suitable node type found to " + "perform test against '" + testNodeType + "' nodes");
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) NodeType(javax.jcr.nodetype.NodeType) NodeTypeIterator(javax.jcr.nodetype.NodeTypeIterator) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Aggregations

QueryObjectModel (javax.jcr.query.qom.QueryObjectModel)77 Value (javax.jcr.Value)17 Node (javax.jcr.Node)16 JoinCondition (javax.jcr.query.qom.JoinCondition)13 Selector (javax.jcr.query.qom.Selector)9 RepositoryException (javax.jcr.RepositoryException)7 Query (javax.jcr.query.Query)7 Source (javax.jcr.query.qom.Source)7 Column (javax.jcr.query.qom.Column)6 Ordering (javax.jcr.query.qom.Ordering)6 PropertyExistence (javax.jcr.query.qom.PropertyExistence)6 RowIterator (javax.jcr.query.RowIterator)5 PropertyValue (javax.jcr.query.qom.PropertyValue)5 ArrayList (java.util.ArrayList)4 NodeType (javax.jcr.nodetype.NodeType)4 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)4 InvalidQueryException (javax.jcr.query.InvalidQueryException)4 QueryResult (javax.jcr.query.QueryResult)4 Constraint (javax.jcr.query.qom.Constraint)4 NodeTypeIterator (javax.jcr.nodetype.NodeTypeIterator)3