use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class SimpleQueryTest method testLikePatternEnd.
public void testLikePatternEnd() throws Exception {
Node n = testRootNode.addNode("node1");
n.setProperty("value", new String[] { "bli" });
n = testRootNode.addNode("node2");
n.setProperty("value", new String[] { "bla" });
n = testRootNode.addNode("node3");
n.setProperty("value", new String[] { "blub" });
testRootNode.save();
String sql = "SELECT * FROM nt:base WHERE jcr:path LIKE '" + testRoot + "/%' AND value LIKE 'bli'";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
QueryResult result = q.execute();
checkResult(result, 1);
sql = "SELECT * FROM nt:base WHERE jcr:path LIKE '" + testRoot + "/%' AND value LIKE 'bl_'";
q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
result = q.execute();
checkResult(result, 2);
sql = "SELECT * FROM nt:base WHERE jcr:path LIKE '" + testRoot + "/%' AND value LIKE 'bl%'";
q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
result = q.execute();
checkResult(result, 3);
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class ParentNodeTest method testParentInAttribute4.
public void testParentInAttribute4() throws RepositoryException {
String stmt = testPath + "//child[../@foo1 = 'bar1']";
QueryResult result = qm.createQuery(stmt, Query.XPATH).execute();
assertTrue("Wrong size of NodeIterator in result", result.getNodes().getSize() > 0);
assertEquals("child", result.getNodes().nextNode().getName());
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class SearchResourceImpl method search.
/**
* Execute the query defined by the given <code>sInfo</code>.
*
* @see SearchResource#search(org.apache.jackrabbit.webdav.search.SearchInfo)
*/
public MultiStatus search(SearchInfo sInfo) throws DavException {
try {
QueryResult result = getQuery(sInfo).execute();
MultiStatus ms = new MultiStatus();
if (ItemResourceConstants.NAMESPACE.equals(sInfo.getLanguageNameSpace())) {
ms.setResponseDescription("Columns: " + encode(result.getColumnNames()) + "\nSelectors: " + encode(result.getSelectorNames()));
} else {
ms.setResponseDescription(encode(result.getColumnNames()));
}
queryResultToMultiStatus(result, ms);
return ms;
} catch (RepositoryException e) {
throw new JcrDavException(e);
}
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class AbstractQuery method execute.
/**
* {@inheritDoc}
*/
public final boolean execute(Context ctx) throws Exception {
String statement = (String) ctx.get(this.statementKey);
Session session = CommandHelper.getSession(ctx);
Query query = session.getWorkspace().getQueryManager().createQuery(statement, this.getLanguage());
QueryResult result = query.execute();
ctx.put(destKey, result.getNodes());
return false;
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class FulltextSQL2QueryTest method testFulltextSimpleSQL.
public void testFulltextSimpleSQL() throws Exception {
Node foo = testRootNode.addNode("foo");
foo.setProperty("mytext", new String[] { "the quick brown fox jumps over the lazy dog." });
testRootNode.save();
String sql = "SELECT * FROM [nt:unstructured]" + " WHERE ISCHILDNODE([" + testRoot + "])" + " AND CONTAINS(mytext, 'fox')";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
QueryResult result = q.execute();
checkResult(result, 1);
}
Aggregations