Package javax.jcr.query.qom

Examples of javax.jcr.query.qom.QueryObjectModel


        checkResult(qom.execute(), new Node[][]{{n2, n1}, {null, n2}});
    }

    public void testLeftOuterJoin() throws RepositoryException {
        JoinCondition c = qf.childNodeJoinCondition(LEFT, RIGHT);
        QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, c);
        List result = new ArrayList();
        result.add(new Node[]{n2, n1});
        if (testRootNode.isNodeType(testNodeType)) {
            result.add(new Node[]{n1, testRootNode});
        } else {
            result.add(new Node[]{n1, null});
        }
        checkResult(qom.execute(), (Node[][]) result.toArray(new Node[result.size()][]));
    }
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

        testRootNode.save();
    }

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

        checkResult(qom.execute(), 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);
        checkResult(qom.execute(), new Node[][]{{n2, n1}, {null, n2}});
    }
View Full Code Here

        checkResult(qom.execute(), 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
        Node n = testRootNode;
        for (;;) {
            if (n.isNodeType(testNodeType)) {
                result.add(new Node[]{n1, n});
                result.add(new Node[]{n2, n});
            }
            if (n.getDepth() == 0) {
                break;
            } else {
                n = n.getParent();
            }
        }
        if (result.size() == 1) {
            // n1 not yet covered
            result.add(new Node[]{n1, null});
        }
        checkResult(qom.execute(), (Node[][]) result.toArray(new Node[result.size()][]));
    }
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)});
        QueryResult result = qom.execute();
        List names = new ArrayList(Arrays.asList(result.getColumnNames()));
        NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
        NodeType nt = ntMgr.getNodeType(testNodeType);
        PropertyDefinition[] propDefs = nt.getPropertyDefinitions();
        for (int i = 0; i < propDefs.length; i++) {
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)});
        QueryResult result = qom.execute();
        List names = new ArrayList(Arrays.asList(result.getColumnNames()));
        assertTrue("Missing column: " + propertyName1, names.remove(propertyName1));
        for (Iterator it = names.iterator(); it.hasNext(); ) {
            fail(it.next() + " was not declared as a column");
        }
View Full Code Here

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

        String columnName1 = SELECTOR_1 + "." + propertyName1;
        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)
                ),
                qf.descendantNode(SELECTOR_1, testRoot),
                null,
                new Column[]{
                        qf.column(SELECTOR_1, propertyName1, columnName1),
                        qf.column(SELECTOR_2, propertyName1, columnName2)
                }
        );
        RowIterator rows = qom.execute().getRows();
        assertTrue("empty result", rows.hasNext());
        Row r = rows.nextRow();
        assertEquals("unexpected value", TEST_VALUE, r.getValue(columnName1).getString());
        assertEquals("unexpected value", TEST_VALUE, r.getValue(columnName2).getString());
    }
View Full Code Here

    public void testGetQuery() throws RepositoryException, NotExecutableException {
        checkNtQuery();
        Node n = testRootNode.addNode(nodeName1, testNodeType);
        superuser.save();
        List<Query> queries = new ArrayList<Query>();
        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(qsXPATH)) {
            String xpath = testPath + "/element(*, " + testNodeType + ")";
            queries.add(qm.createQuery(xpath, qsXPATH));
        }
        if (isSupportedLanguage(qsSQL)) {
View Full Code Here

        n2.addMixin(mixReferenceable);
        testRootNode.save();
    }

    public void testInnerJoin() throws RepositoryException {
        QueryObjectModel qom = createQomQuery(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, (String) null);
        QueryResult result = qom.execute();
        checkResult(result, new Node[][]{{n1, n1}, {n2, n2}});
    }
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.