Package javax.jcr.query.qom

Examples of javax.jcr.query.qom.QueryObjectModel


    public void testGetQuery() throws RepositoryException, NotExecutableException {
        checkNtQuery();
        Node n = testRootNode.addNode(nodeName1, testNodeType);
        superuser.save();
        List queries = new ArrayList();
        QueryObjectModel qom = qf.createQuery(
                qf.selector(testNodeType, "s"),
                qf.childNode("s", testRoot),
                null,
                null
        );
        queries.add(qom);
        queries.add(qm.createQuery(qom.getStatement(), Query.JCR_SQL2));
        if (isSupportedLanguage(Query.XPATH)) {
            String xpath = testPath + "/element(*, " + testNodeType + ")";
            queries.add(qm.createQuery(xpath, Query.XPATH));
        }
        if (isSupportedLanguage(Query.SQL)) {
View Full Code Here


    /**
     * Tests if a query object model returns {@link Query#JCR_JQOM} when calling
     * {@link Query#getLanguage()}.
     */
    public void testJCRQOM() throws RepositoryException {
        QueryObjectModel qom = qf.createQuery(
                qf.selector(testNodeType, "s"),
                null, null, null
        );
        assertEquals("Query returns wrong language.", Query.JCR_JQOM, qom.getLanguage());
    }
View Full Code Here

        superuser.save();
    }

    public void testInnerJoin() throws RepositoryException {
        JoinCondition c = qf.descendantNodeJoinCondition(LEFT, RIGHT);
        QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, c);
        checkQOM(qom, new Node[][]{{n2, n1}});
    }
View Full Code Here

        checkQOM(qom, new Node[][]{{n2, n1}});
    }

    public void testRightOuterJoin() throws RepositoryException {
        JoinCondition c = qf.descendantNodeJoinCondition(LEFT, RIGHT);
        QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER, c);
        checkQOM(qom, new Node[][]{{n2, n1}, {null, n2}});
    }
View Full Code Here

        checkQOM(qom, new Node[][]{{n2, n1}, {null, n2}});
    }

    public void testLeftOuterJoin() throws RepositoryException {
        JoinCondition c = qf.descendantNodeJoinCondition(LEFT, RIGHT);
        QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, c);
        List result = new ArrayList();
        result.add(new Node[]{n2, n1});
        // for each ancestor-or-self of testRootNode check
        // whether it is of type testNodeType and add
        // two matches in that case
View Full Code Here

     * [..] If propertyName is not specified,
     * columnName must not be specified, and the included columns will be
     * named "selectorName.propertyName".
     */
    public void testExpandColumnsForNodeType() throws RepositoryException {
        QueryObjectModel qom = qf.createQuery(
                qf.selector(testNodeType, SELECTOR_1),
                null,
                null,
                new Column[]{qf.column(SELECTOR_1, null, null)});
        forQOMandSQL2(qom, new Callable() {
View Full Code Here

     * <p/>
     * If propertyName is specified, columnName is required and used to name
     * the column in the tabular results.
     */
    public void testColumnNames() throws RepositoryException {
        QueryObjectModel qom = qf.createQuery(
                qf.selector(testNodeType, SELECTOR_1),
                null,
                null,
                new Column[]{qf.column(SELECTOR_1, propertyName1, propertyName1)});
        forQOMandSQL2(qom, new Callable() {
View Full Code Here

        n.setProperty(propertyName1, TEST_VALUE);
        superuser.save();

        final String columnName1 = SELECTOR_1 + "." + propertyName1;
        final String columnName2 = SELECTOR_2 + "." + propertyName1;
        QueryObjectModel qom = qf.createQuery(
                qf.join(
                        qf.selector(testNodeType, SELECTOR_1),
                        qf.selector(testNodeType, SELECTOR_2),
                        QueryObjectModelConstants.JCR_JOIN_TYPE_INNER,
                        qf.equiJoinCondition(SELECTOR_1, propertyName1, SELECTOR_2, propertyName1)
View Full Code Here

        }
    }

    public void testCreateQuery() throws RepositoryException {
        Selector selector = qf.selector(testNodeType, SELECTOR_NAME1);
        QueryObjectModel qom = qf.createQuery(selector, null, null, null);
        assertTrue("Not a selector source", qom.getSource() instanceof Selector);
        assertNull("Constraint must be null", qom.getConstraint());
        assertEquals("Wrong size of orderings", 0, qom.getOrderings().length);
        assertEquals("Wrong size of columns", 0, qom.getColumns().length);
    }
View Full Code Here

    }

    public void testCreateQueryWithConstraint() throws RepositoryException {
        Selector selector = qf.selector(testNodeType, SELECTOR_NAME1);
        PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
        QueryObjectModel qom = qf.createQuery(
                selector, propExist, null, null);
        assertTrue("Not a selector source", qom.getSource() instanceof Selector);
        assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
        assertEquals("Wrong size of orderings", 0, qom.getOrderings().length);
        assertEquals("Wrong size of columns", 0, qom.getColumns().length);
    }
View Full Code Here

TOP

Related Classes of javax.jcr.query.qom.QueryObjectModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.