Search in sources :

Example 56 with QueryObjectModel

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

the class SameNodeTest method testChildNodesDoNotMatchSelector.

public void testChildNodesDoNotMatchSelector() 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.sameNode("s", testRoot + "/" + nodeName1), 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)

Example 57 with QueryObjectModel

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

the class SameNodeTest method testSameNode.

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

Example 58 with QueryObjectModel

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

the class EquiJoinConditionTest method testLeftOuterJoin2.

public void testLeftOuterJoin2() throws RepositoryException {
    JoinCondition c = qf.equiJoinCondition(LEFT, propertyName2, RIGHT, propertyName1);
    QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, c);
    checkQOM(qom, new Node[][] { { n1, null }, { n2, n1 }, { n2, n2 } });
}
Also used : QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) JoinCondition(javax.jcr.query.qom.JoinCondition)

Example 59 with QueryObjectModel

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

the class GetQueryTest method testGetQuery.

public void testGetQuery() throws RepositoryException, NotExecutableException {
    checkNtQuery();
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    superuser.save();
    List<Query> queries = new ArrayList<Query>();
    QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("s", testRoot), null, null);
    queries.add(qom);
    queries.add(qm.createQuery(qom.getStatement(), Query.JCR_SQL2));
    if (isSupportedLanguage(qsXPATH)) {
        String xpath = testPath + "/element(*, " + testNodeType + ")";
        queries.add(qm.createQuery(xpath, qsXPATH));
    }
    if (isSupportedLanguage(qsSQL)) {
        String sql = "select * from " + testNodeType + " where jcr:path like '" + testRoot + "/%'";
        queries.add(qm.createQuery(sql, qsSQL));
    }
    for (Iterator<Query> it = queries.iterator(); it.hasNext(); ) {
        Query q = it.next();
        String lang = q.getLanguage();
        checkResult(q.execute(), new Node[] { n });
        Node stored = q.storeAsNode(testRoot + "/storedQuery");
        q = qm.getQuery(stored);
        assertEquals("language of stored query does not match", lang, q.getLanguage());
        checkResult(q.execute(), new Node[] { n });
        stored.remove();
    }
}
Also used : Query(javax.jcr.query.Query) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Example 60 with QueryObjectModel

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

the class NodeLocalNameTest method testNameLiteral.

public void testNameLiteral() throws RepositoryException {
    Value literal = superuser.getValueFactory().createValue(nodeLocalName, PropertyType.NAME);
    QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);
    checkQOM(qom, new Node[] { node1 });
}
Also used : Value(javax.jcr.Value) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Aggregations

QueryObjectModel (javax.jcr.query.qom.QueryObjectModel)78 Value (javax.jcr.Value)18 Node (javax.jcr.Node)17 JoinCondition (javax.jcr.query.qom.JoinCondition)13 Selector (javax.jcr.query.qom.Selector)10 Query (javax.jcr.query.Query)8 RepositoryException (javax.jcr.RepositoryException)7 Column (javax.jcr.query.qom.Column)7 Ordering (javax.jcr.query.qom.Ordering)7 Source (javax.jcr.query.qom.Source)7 PropertyExistence (javax.jcr.query.qom.PropertyExistence)6 QueryResult (javax.jcr.query.QueryResult)5 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 Constraint (javax.jcr.query.qom.Constraint)4 NodeTypeIterator (javax.jcr.nodetype.NodeTypeIterator)3