use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.
the class PathQueryNodeTest method testNeedsSystemTreeForAllNodesByNodeType.
public void testNeedsSystemTreeForAllNodesByNodeType() throws Exception {
QueryRootNode queryRootNode = XPathQueryBuilder.createQuery("//element(*, nt:resource)", JCR_RESOLVER, QUERY_NODE_FACTORY);
assertFalse(queryRootNode.needsSystemTree());
queryRootNode = XPathQueryBuilder.createQuery("//element(*, nt:resource)[@jcr:test = 'foo']", JCR_RESOLVER, QUERY_NODE_FACTORY);
assertFalse(queryRootNode.needsSystemTree());
queryRootNode = XPathQueryBuilder.createQuery("//element(*, nt:nodeType)", JCR_RESOLVER, QUERY_NODE_FACTORY);
assertTrue(queryRootNode.needsSystemTree());
}
use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.
the class PathQueryNodeTest method testNeedsSystemTree.
public void testNeedsSystemTree() throws Exception {
QueryRootNode queryRootNode = XPathQueryBuilder.createQuery("/jcr:root/*", JCR_RESOLVER, QUERY_NODE_FACTORY);
assertTrue(queryRootNode.needsSystemTree());
queryRootNode = XPathQueryBuilder.createQuery("/jcr:root/test/*", JCR_RESOLVER, QUERY_NODE_FACTORY);
assertFalse(queryRootNode.needsSystemTree());
queryRootNode = XPathQueryBuilder.createQuery("*", JCR_RESOLVER, QUERY_NODE_FACTORY);
assertTrue(queryRootNode.needsSystemTree());
queryRootNode = XPathQueryBuilder.createQuery("jcr:system/*", JCR_RESOLVER, QUERY_NODE_FACTORY);
assertTrue(queryRootNode.needsSystemTree());
queryRootNode = XPathQueryBuilder.createQuery("test//*", JCR_RESOLVER, QUERY_NODE_FACTORY);
assertFalse(queryRootNode.needsSystemTree());
queryRootNode = XPathQueryBuilder.createQuery("//test/*", JCR_RESOLVER, QUERY_NODE_FACTORY);
assertTrue(queryRootNode.needsSystemTree());
}
use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.
the class JCRSQLQueryBuilder method visit.
public Object visit(ASTSelectList node, Object data) {
final QueryRootNode root = (QueryRootNode) data;
node.childrenAccept(new DefaultParserVisitor() {
public Object visit(ASTIdentifier node, Object data) {
root.addSelectProperty(node.getName());
return data;
}
public Object visit(ASTExcerptFunction node, Object data) {
root.addSelectProperty(NameFactoryImpl.getInstance().create(Name.NS_REP_URI, "excerpt(.)"));
return data;
}
}, root);
return data;
}
use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.
the class JCRSQLQueryBuilder method visit.
public Object visit(ASTOrderByClause node, Object data) {
QueryRootNode root = (QueryRootNode) data;
OrderQueryNode order = factory.createOrderQueryNode(root);
root.setOrderNode(order);
node.childrenAccept(this, order);
return root;
}
use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.
the class XPathOrderByTest method testRoundTrip.
public void testRoundTrip() throws Exception {
String stmt = "//* order by foo_x0020_bar/@bar";
QueryRootNode root = QueryParser.parse(stmt, Query.XPATH, RESOLVER, FACTORY);
assertEquals(stmt, QueryFormat.toString(root, RESOLVER));
}
Aggregations