Search in sources :

Example 51 with QueryObjectModel

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

the class ColumnTest method testColumnNames.

/**
 * From the spec:
 * <p>
 * If propertyName is specified, columnName is required and used to name
 * the column in the tabular results.
 */
public void testColumnNames() throws RepositoryException {
    QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, SELECTOR_1), null, null, new Column[] { qf.column(SELECTOR_1, propertyName1, propertyName1) });
    forQOMandSQL2(qom, new Callable() {

        public Object call(Query query) throws RepositoryException {
            QueryResult result = query.execute();
            List<String> names = new ArrayList<String>(Arrays.asList(result.getColumnNames()));
            assertTrue("Missing column: " + propertyName1, names.remove(propertyName1));
            for (Iterator<String> it = names.iterator(); it.hasNext(); ) {
                fail(it.next() + " was not declared as a column");
            }
            return null;
        }
    });
}
Also used : QueryResult(javax.jcr.query.QueryResult) Query(javax.jcr.query.Query) Iterator(java.util.Iterator) RowIterator(javax.jcr.query.RowIterator) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) RepositoryException(javax.jcr.RepositoryException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 52 with QueryObjectModel

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

the class DescendantNodeJoinConditionTest method testRightOuterJoin.

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

Example 53 with QueryObjectModel

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

the class DescendantNodeTest method testDescendantNodes.

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

Example 54 with QueryObjectModel

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

the class DescendantNodeTest method testPathDoesNotExist.

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

Example 55 with QueryObjectModel

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

the class SameNodeTest method testPathDoesNotExist.

public void testPathDoesNotExist() throws RepositoryException {
    QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.sameNode("s", testRoot + "/" + nodeName1), null, null);
    checkQOM(qom, new Node[] {});
}
Also used : 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