Search in sources :

Example 21 with QueryObjectModel

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

the class NotConstraintTest method testNot.

public void testNot() throws RepositoryException {
    Node n1 = testRootNode.addNode(nodeName1, testNodeType);
    n1.setProperty(propertyName1, "foo");
    Node n2 = testRootNode.addNode(nodeName2, testNodeType);
    n2.setProperty(propertyName2, "bar");
    superuser.save();
    QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.and(qf.descendantNode("s", testRootNode.getPath()), qf.not(qf.propertyExistence("s", propertyName1))), null, null);
    checkQOM(qom, new Node[] { n2 });
}
Also used : Node(javax.jcr.Node) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Example 22 with QueryObjectModel

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

the class OrConstraintTest method testOr.

public void testOr() throws RepositoryException {
    Node n1 = testRootNode.addNode(nodeName1, testNodeType);
    n1.setProperty(propertyName1, "foo");
    Node n2 = testRootNode.addNode(nodeName2, testNodeType);
    n2.setProperty(propertyName2, "bar");
    superuser.save();
    QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.and(qf.descendantNode("s", testRootNode.getPath()), qf.or(qf.propertyExistence("s", propertyName1), qf.propertyExistence("s", propertyName2))), null, null);
    checkQOM(qom, new Node[] { n1, n2 });
}
Also used : Node(javax.jcr.Node) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Example 23 with QueryObjectModel

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

Example 24 with QueryObjectModel

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

the class PropertyExistenceTest method testPropertyExistence.

public void testPropertyExistence() throws RepositoryException {
    Node n1 = testRootNode.addNode(nodeName1, testNodeType);
    n1.setProperty(propertyName1, "abc");
    Node n2 = testRootNode.addNode(nodeName2, testNodeType);
    n2.setProperty(propertyName2, "abc");
    superuser.save();
    QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.and(qf.childNode("s", testRoot), qf.propertyExistence("s", propertyName1)), null, null);
    checkQOM(qom, new Node[] { n1 });
    qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.and(qf.childNode("s", testRoot), qf.propertyExistence("s", propertyName2)), null, null);
    checkQOM(qom, new Node[] { n2 });
}
Also used : Node(javax.jcr.Node) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Example 25 with QueryObjectModel

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

the class EquiJoinConditionTest method testRightOuterJoin2.

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

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