use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class SelectorTest method testSelector.
public void testSelector() throws RepositoryException {
// make sure there's at least one node with this node type
testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), null, null, null);
forQOMandSQL2(qom, new Callable() {
public Object call(Query query) throws RepositoryException {
QueryResult result = query.execute();
String[] names = result.getSelectorNames();
assertNotNull(names);
assertEquals(1, names.length);
assertEquals("s", names[0]);
NodeIterator it = result.getNodes();
while (it.hasNext()) {
assertTrue("Wrong node type", it.nextNode().isNodeType(testNodeType));
}
return null;
}
});
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class RowTest method getRow.
private Row getRow() throws RepositoryException {
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, SELECTOR_NAME), qf.descendantNode(SELECTOR_NAME, testRoot), null, new Column[] { qf.column(SELECTOR_NAME, propertyName1, propertyName1) });
RowIterator rows = qom.execute().getRows();
assertTrue("empty result", rows.hasNext());
Row r = rows.nextRow();
assertFalse("result must not contain more than one row", rows.hasNext());
return r;
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class FullTextSearchScoreTest method testOrdering.
public void testOrdering() throws RepositoryException {
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.and(qf.fullTextSearch("s", null, qf.literal(vf.createValue("fox"))), qf.descendantNode("s", testRootNode.getPath())), new Ordering[] { qf.ascending(qf.fullTextSearchScore("s")) }, null);
forQOMandSQL2(qom, new Callable() {
public Object call(Query query) throws RepositoryException {
RowIterator rows = query.execute().getRows();
double previousScore = Double.NaN;
while (rows.hasNext()) {
double score = rows.nextRow().getScore("s");
if (!Double.isNaN(previousScore)) {
assertTrue("wrong order", previousScore <= score);
}
previousScore = score;
}
return null;
}
});
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class LengthTest method executeQueries.
private QueryResult[] executeQueries(String propertyName, String operator, Value length) throws RepositoryException {
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.and(qf.childNode("s", testRoot), qf.comparison(qf.length(qf.propertyValue("s", propertyName)), operator, qf.literal(length))), null, null);
QueryResult[] results = new QueryResult[2];
results[0] = qom.execute();
results[1] = qm.createQuery(qom.getStatement(), Query.JCR_SQL2).execute();
return results;
}
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()][]));
}
Aggregations