Examples of RowIterator


Examples of javax.jcr.query.RowIterator

        for (int limit = 0; limit < 5; limit++) {
            q.setLimit(limit);
            for (int offset = 0; offset < 3; offset++) {
                q.setOffset(offset);
                QueryResult r = q.execute();
                RowIterator it = r.getRows();
                int l = Math.min(Math.max(0, 3 - offset), limit);
                assertEquals(l, r.getRows().getSize());
                assertEquals(l, r.getNodes().getSize());
                Row row;
               
                for (int x = offset + 1, i = 0; i < limit && x < 4; i++, x++) {
                    assertTrue(it.hasNext());
                    row = it.nextRow();
                    assertEquals("" + x, row.getValue("id").getString());
                }
                assertFalse(it.hasNext());
            }
        }
    }
View Full Code Here

Examples of javax.jcr.query.RowIterator

        QueryManager qm = session.getWorkspace().getQueryManager();
        Query q = qm.createQuery("select properties from [nt:base] where id = 1",
                Query.JCR_SQL2);

        QueryResult r = q.execute();
        RowIterator it = r.getRows();
        assertTrue(it.hasNext());
        Row row = it.nextRow();
        assertEquals("p1 p2", row.getValues()[0].getString());
    }
View Full Code Here

Examples of javax.jcr.query.RowIterator

        String sql2 = "select [jcr:path] as [path] from [nt:base] " +
                "where [node2/node3/jcr:primaryType] is not null";
       
        Query q;
        QueryResult result;
        RowIterator it;
       
        q = qm.createQuery("explain " + sql2, Query.JCR_SQL2);
        result = q.execute();
        it = result.getRows();
        assertTrue(it.hasNext());
        String plan = it.nextRow().getValue("plan").getString();
        // should not use the index on "jcr:primaryType"
        assertEquals("[nt:base] as [nt:base] /* traverse \"*\" " +
                "where [nt:base].[node2/node3/jcr:primaryType] is not null */",
                plan);
       
        // verify the result
        q = qm.createQuery(sql2, Query.JCR_SQL2);
        result = q.execute();
        it = result.getRows();
        assertTrue(it.hasNext());
        String path = it.nextRow().getValue("path").getString();
        assertEquals("/testroot/node1", path);
       
    }
View Full Code Here

Examples of javax.jcr.query.RowIterator

        n2.setProperty("text", "Hello World");
        n2.setProperty("desc", "Description");
        session.save();

        Query q;
        RowIterator it;
        Row row;
        String s;
       
        String xpath = "//*[jcr:contains(., 'hello')]/rep:excerpt(.) order by jcr:path descending";
       
        q = qm.createQuery(xpath, "xpath");
        it = q.execute().getRows();
        row = it.nextRow();
        s = row.getValue("rep:excerpt(.)").getString();
        assertTrue(s, s.indexOf("<strong>hello</strong> world") >= 0);
        assertTrue(s, s.indexOf("description") >= 0);
        row = it.nextRow();
        s = row.getValue("rep:excerpt(.)").getString();
        // TODO is this expected?
        assertTrue(s, s.indexOf("Hello World") >= 0);
        assertTrue(s, s.indexOf("Description") >= 0);
       
        xpath = "//*[jcr:contains(., 'hello')]/rep:excerpt(.) order by jcr:path descending";

        q = qm.createQuery(xpath, "xpath");
        it = q.execute().getRows();
        row = it.nextRow();
        s = row.getValue("rep:excerpt(text)").getString();
        assertTrue(s, s.indexOf("<strong>hello</strong> world") >= 0);
        assertTrue(s, s.indexOf("description") < 0);
        row = it.nextRow();
        s = row.getValue("rep:excerpt(text)").getString();
        // TODO is this expected?
        assertTrue(s, s.indexOf("Hello World") >= 0);
        assertTrue(s, s.indexOf("Description") < 0);
    }
View Full Code Here

Examples of javax.jcr.query.RowIterator

    }
   
    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

Examples of javax.jcr.query.RowIterator

        Session anonymousSession = getRepository().login(new GuestCredentials());
        QueryManager qm = anonymousSession.getWorkspace().getQueryManager();
        Query q = qm.createQuery("/jcr:root/home//social/relationships/following//*[id='aaron.mcdonald@mailinator.com']", Query.XPATH);
        QueryResult r = q.execute();
        RowIterator it = r.getRows();
        Assert.assertTrue(it.hasNext());
    }
View Full Code Here

Examples of javax.jcr.query.RowIterator

    private MultiStatus queryResultToMultiStatus(QueryResult qResult)
            throws RepositoryException {
        MultiStatus ms = new MultiStatus();

        String[] columnNames = qResult.getColumnNames();
        RowIterator rowIter = qResult.getRows();
        while (rowIter.hasNext()) {
            Row row = rowIter.nextRow();
            Value[] values = row.getValues();

            // get the jcr:path column indicating the node path and build
            // a webdav compliant resource path of it.
            String itemPath = row.getValue(JcrConstants.JCR_PATH).getString();
View Full Code Here

Examples of javax.jcr.query.RowIterator

        Query q = qm.createQuery("//element(*, nt:version)[@jcr:uuid = '" +
                v.getIdentifier() + "']", Query.XPATH);
        NodeIterator nodes = q.execute().getNodes();
        assertTrue(nodes.hasNext());
        assertTrue(nodes.nextNode() instanceof Version);
        RowIterator rows = q.execute().getRows();
        assertTrue(rows.hasNext());
        assertTrue(rows.nextRow().getNode() instanceof Version);
    }
View Full Code Here

Examples of javax.jcr.query.RowIterator

        }
    }

    public QueryResult merge(RowIterator leftRows, RowIterator rightRows)
            throws RepositoryException {
        RowIterator joinRows;

        Map<String, List<Row>> map = new HashMap<String, List<Row>>();
        for (Row row : new RowIterable(rightRows)) {
            for (String value : getRightValues(row)) {
                List<Row> rows = map.get(value);
View Full Code Here

Examples of org.apache.accumulo.core.client.RowIterator

   */
  public AccumuloResult(DataStore<K,T> dataStore, Query<K,T> query, Scanner scanner) {
    super(dataStore, query);
   
    // TODO set batch size based on limit, and construct iterator later
    iterator = new RowIterator(scanner.iterator());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.