Package javax.jcr.query

Examples of javax.jcr.query.RowIterator


            descr.add(new ScoreValue(JcrConstants.JCR_SCORE, selectorName, vf));
            columnNames.add(JcrConstants.JCR_SCORE);
        }
        String[] selectorNames = createSelectorNames(descr);
        String[] colNames = columnNames.toArray(new String[columnNames.size()]);
        RowIterator rowIter = qResult.getRows();
        while (rowIter.hasNext()) {
            Row row = rowIter.nextRow();
            List<Value> values = new ArrayList<Value>();
            for (RowValue rv : descr) {
                values.add(rv.getValue(row));
            }
View Full Code Here


        List<Row> leftRows = new ArrayList<Row>();
        for (Row row : JcrUtils.getRows(leftResult)) {
            leftRows.add(row);
        }

        RowIterator rightRows;
        Source right = join.getRight();
        List<Constraint> rightConstraints =
            merger.getRightJoinConstraints(leftRows);
        if (rightConstraints.size() < 500) {
            Constraint rightConstraint = Constraints.and(
View Full Code Here

            getColumnMap(columns, selectorMap);
        String[] columnNames =
            columnMap.keySet().toArray(new String[columnMap.size()]);

        try {
            RowIterator rows = new RowIteratorAdapter(lqf.execute(
                    columnMap, selector, constraint));
            QueryResult result =
                new SimpleQueryResult(columnNames, selectorNames, rows);
            return sort(result, orderings, offset, limit);
        } catch (IOException e) {
View Full Code Here

            long offset, long limit) throws RepositoryException {
        if ((orderings != null && orderings.length > 0)
                || offset != 0 || limit >= 0) {
            List<Row> rows = new ArrayList<Row>();

            RowIterator iterator = result.getRows();
            while (iterator.hasNext()) {
                rows.add(iterator.nextRow());
            }

            if (orderings != null && orderings.length > 0) {
                Collections.sort(rows, new RowComparator(orderings));
            }
View Full Code Here

       
    }
   
    static String getResult(QueryResult result, String propertyName) throws RepositoryException {
        StringBuilder buff = new StringBuilder();
        RowIterator it = result.getRows();
        while (it.hasNext()) {
            if (buff.length() > 0) {
                buff.append(", ");
            }
            buff.append(it.nextRow().getValue(propertyName).getString());
        }
        return buff.toString();
    }
View Full Code Here

     */
    private RowIterator execute() {
        try {
            String stmt = translateStatement();
            QueryManager qm = session.getWorkspace().getQueryManager();
            RowIterator nodes = qm.createQuery(stmt, Query.XPATH).execute().getRows();
            if (filter != null) {
                nodes = new FilteredRowIterator(nodes);
            }
            if (offset > 0) {
                try {
                    nodes.skip(offset);
                } catch (NoSuchElementException e) {
                    return RowIteratorAdapter.EMPTY;
                }
            }
            if (numResults == Integer.MAX_VALUE) {
                return new RowIterAdapter(nodes, nodes.getSize());
            }
            List<Row> resultRows = new ArrayList<Row>();
            while (numResults-- > 0 && nodes.hasNext()) {
                resultRows.add(nodes.nextRow());
            }
            return new RowIterAdapter(resultRows, resultRows.size());
        } catch (RepositoryException e) {
            // in case of error return empty result
            return RowIteratorAdapter.EMPTY;
View Full Code Here

    public void testPath() throws RepositoryException {
        Node n1 = testRootNode.addNode("node1");
        Node n2 = testRootNode.addNode("node2");
        Node n3 = testRootNode.addNode("node3");
        superuser.save();
        RowIterator rows = GQL.execute(createStatement(""), superuser);
        checkResult(rows, new Node[]{n1, n2, n3});
    }
View Full Code Here

        Node n3 = testRootNode.addNode("node3");
        n3.setProperty("p", 3);
        superuser.save();
        // default: ascending
        String stmt = createStatement("order:p");
        RowIterator rows = GQL.execute(stmt, superuser);
        checkResultSequence(rows, new Node[]{n1, n2, n3});
        // explicit ascending
        stmt = createStatement("order:+p");
        rows = GQL.execute(stmt, superuser);
        checkResultSequence(rows, new Node[]{n1, n2, n3});
View Full Code Here

        n3.setProperty("prop", "value");
        n3.addNode("sub").setProperty("p", 3);
        superuser.save();
        // default: ascending
        String stmt = createStatement("prop:value order:sub/p");
        RowIterator rows = GQL.execute(stmt, superuser);
        checkResultSequence(rows, new Node[]{n1, n2, n3});
        // explicit ascending
        stmt = createStatement("prop:value order:+sub/p");
        rows = GQL.execute(stmt, superuser);
        checkResultSequence(rows, new Node[]{n1, n2, n3});
View Full Code Here

        Node n3 = testRootNode.addNode("node3");
        n3.setProperty("p", 3);
        superuser.save();
        // only 2 results
        String stmt = createStatement("order:p limit:2");
        RowIterator rows = GQL.execute(stmt, superuser);
        checkResultSequence(rows, new Node[]{n1, n2});
        // range with open start
        stmt = createStatement("order:p limit:..2");
        rows = GQL.execute(stmt, superuser);
        checkResultSequence(rows, new Node[]{n1, n2});
View Full Code Here

TOP

Related Classes of javax.jcr.query.RowIterator

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.