use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit-oak by apache.
the class QomTest method createQuery.
@Test
public void createQuery() throws RepositoryException {
Selector s = f.selector("nt:file", "x");
BindVariableValue b = f.bindVariable("var");
Constraint c = f.propertyExistence("x", "c");
PropertyValue p = f.propertyValue("x", "propertyName");
c = f.and(f.comparison(p, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, b), c);
Ordering o = f.ascending(p);
Column col = f.column("x", "propertyName", "columnName");
Ordering[] ords = new Ordering[] { o };
Column[] cols = new Column[] { col };
QueryObjectModel q = f.createQuery(s, c, ords, cols);
assertEquals(Query.JCR_JQOM, q.getLanguage());
String[] bv = q.getBindVariableNames();
assertEquals(1, bv.length);
assertEquals("var", bv[0]);
assertEquals(s, q.getSource());
assertEquals(c, q.getConstraint());
assertEquals(o, q.getOrderings()[0]);
assertEquals(col, q.getColumns()[0]);
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class SQL2PathEscapingTest method testGetChildrenApiDirect.
/**
* will build a query directly via the api using a spaced path
*
* @throws Exception
*/
public void testGetChildrenApiDirect() throws Exception {
QueryObjectModelFactory qomf = qm.getQOMFactory();
Source source1 = qomf.selector(NodeType.NT_BASE, "selector");
Column[] columns = new Column[] { qomf.column("selector", null, null) };
Constraint constraint2 = qomf.childNode("selector", n1.getPath());
QueryObjectModel qom = qomf.createQuery(source1, constraint2, null, columns);
checkResult(qom.execute(), 2);
}
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 } });
}
use of javax.jcr.query.qom.QueryObjectModel 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()][]));
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class ChildNodeTest method testChildNode.
public void testChildNode() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("s", testRoot), null, null);
checkQOM(qom, new Node[] { n });
}
Aggregations