Search in sources :

Example 1 with QueryRootNode

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());
}
Also used : QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Example 2 with QueryRootNode

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());
}
Also used : QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Example 3 with QueryRootNode

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;
}
Also used : QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Example 4 with QueryRootNode

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;
}
Also used : OrderQueryNode(org.apache.jackrabbit.spi.commons.query.OrderQueryNode) QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Example 5 with QueryRootNode

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));
}
Also used : QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Aggregations

QueryRootNode (org.apache.jackrabbit.spi.commons.query.QueryRootNode)10 Path (org.apache.jackrabbit.spi.Path)2 OrderQueryNode (org.apache.jackrabbit.spi.commons.query.OrderQueryNode)1