use of javax.jcr.query.RowIterator 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.RowIterator in project jackrabbit-oak by apache.
the class FullTextSearchTest method runTest.
@SuppressWarnings("deprecation")
@Override
protected void runTest(TestContext ec) throws Exception {
QueryManager qm = ec.session.getWorkspace().getQueryManager();
// like > 20% of the perf lost in Collections.sort
for (String word : ec.words) {
Query q = qm.createQuery("//*[jcr:contains(@text, '" + word + "')] ", Query.XPATH);
QueryResult r = q.execute();
RowIterator it = r.getRows();
for (int rows = 0; it.hasNext() && rows < maxRowsToFetch; rows++) {
Node n = it.nextRow().getNode();
ec.hash += n.getProperty("text").getString().hashCode();
ec.hash += n.getProperty("title").getString().hashCode();
}
}
}
use of javax.jcr.query.RowIterator in project jackrabbit-oak by apache.
the class LucenePropertyFullTextTest method performQuery.
private boolean performQuery(@Nonnull final TestContext ec) throws RepositoryException {
QueryManager qm = ec.session.getWorkspace().getQueryManager();
ValueFactory vf = ec.session.getValueFactory();
Query q = qm.createQuery("SELECT * FROM [nt:base] WHERE [title] = $title", Query.JCR_SQL2);
q.bindValue("title", vf.createValue(ec.title));
LOG.trace("statement: {} - title: {}", q.getStatement(), ec.title);
RowIterator rows = q.execute().getRows();
if (rows.hasNext()) {
rows.nextRow().getPath();
return true;
} else {
return false;
}
}
use of javax.jcr.query.RowIterator in project jackrabbit by apache.
the class GQLTest method testFilterLimit.
public void testFilterLimit() throws RepositoryException {
final Node n1 = testRootNode.addNode("node1");
n1.setProperty("jcr:title", "a");
Node n2 = testRootNode.addNode("node2");
n2.setProperty("jcr:title", "b");
Node n3 = testRootNode.addNode("node3");
n3.setProperty("jcr:title", "c");
superuser.save();
String stmt = createStatement("order:jcr:title limit:1");
RowIterator rows = GQL.execute(stmt, superuser, null, new GQL.Filter() {
public boolean include(Row row) throws RepositoryException {
return !n1.getPath().equals(row.getValue("jcr:path").getString());
}
});
checkResultSequence(rows, new Node[] { n2 });
}
use of javax.jcr.query.RowIterator in project jackrabbit by apache.
the class GQLTest method testMixinType.
public void testMixinType() throws RepositoryException {
Node node = testRootNode.addNode("node1");
node.setProperty("text", SAMPLE_CONTENT);
node.addMixin(mixReferenceable);
superuser.save();
String stmt = createStatement("quick type:referenceable");
RowIterator rows = GQL.execute(stmt, superuser);
checkResult(rows, new Node[] { node });
}
Aggregations