Package javax.jcr.query

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


   {
      String jcrType = (String)mappingClass.getField(BaseMapping.JCR_TYPE_NAME_CONSTANT_NAME).get(null);
      String id;
      final Query query = session.getJCRSession().getWorkspace().getQueryManager().createQuery("select jcr:uuid from " + jcrType + " where jcr:path = '/%/" + name + "'", Query.SQL);
      final QueryResult queryResult = query.execute();
      final RowIterator rows = queryResult.getRows();
      final long size = rows.getSize();
      if (size == 0)
      {
         return null;
      }
      else
      {
         if (size != 1)
         {
            throw new IllegalArgumentException("There should be only one " + mappingClass.getSimpleName() + " named " + name);
         }

         id = rows.nextRow().getValue("jcr:uuid").getString();
      }

      return session.findById(mappingClass, id);
   }
View Full Code Here

      try
      {
         ChromatticSession session = persister.getSession();

         // use JCR directly to only retrieve the ProducerInfo identifiers, this is a little bit convoluted, unfortunately, and we should probably check that we indeed perform better than via Chromattic
         final RowIterator rows = getProducerInfoIds(session);

         final long size = rows.getSize();
         if (size == 0)
         {
            return Collections.emptyList();
         }
         else
         {
            List<String> ids = new ArrayList<String>(size != -1 ? (int)size : 7);

            while (rows.hasNext())
            {
               final Row row = rows.nextRow();
               final Value rowValue = row.getValue("producerid");
               ids.add(rowValue.getString());
            }

            return ids;
View Full Code Here

   {
      try
      {
         ChromatticSession session = persister.getSession();

         final RowIterator ids = getProducerInfoIds(session);

         return (int)ids.getSize();
      }
      catch (RepositoryException e)
      {
         throw new RuntimeException(e);
      }
View Full Code Here

     * @throws RepositoryException if an error occurs while iterating over the
     *                             result nodes.
     */
    protected void checkResult(QueryResult result, int hits)
            throws RepositoryException {
        RowIterator itr = result.getRows();
        long count = itr.getSize();
        if (count == 0) {
            log.println(" NONE");
        }
        assertEquals("Wrong hit count.", hits, count);
    }
View Full Code Here

     *                                order-property
     */
    protected void evaluateResultOrder(QueryResult queryResult, String propName,
                                       boolean descending)
            throws RepositoryException, NotExecutableException {
        RowIterator rows = queryResult.getRows();
        if (getSize(rows) < 2) {
            fail("Workspace does not contain sufficient content to test ordering on result nodes.");
        }
        // need to re-aquire rows, {@link #getSize} may consume elements.
        rows = queryResult.getRows();
        int changeCnt = 0;
        String last = descending ? "\uFFFF" : "";
        while (rows.hasNext()) {
            String value = rows.nextRow().getValue(propName).getString();
            int cp = value.compareTo(last);
            // if value changed evaluate if the ordering is correct
            if (cp != 0) {
                changeCnt++;
                if (cp > 0 && descending) {
View Full Code Here

     * For configuration description see {@link #setUpFullTextTest()}.
     */
    public void testScoreColumn() throws Exception {
        setUpFullTextTest();
        QueryResult result = execute(getFullTextStatement());
        RowIterator rows = result.getRows();
        // test mere existence
        rows.nextRow().getValue(jcrScore);
    }
View Full Code Here

        // must be 1
        checkResult(result, 1);

        // evaluate result
        RowIterator itr = result.getRows();
        while (itr.hasNext()) {
            Row row = itr.nextRow();
            Value value = row.getValue(propertyName1);
            if (value != null) {
                String fullText = value.getString();
                if (fullText.indexOf("cat") > 0) {
                    fail("Search Text: full text search not correct, returned prohibited text");
View Full Code Here

     * For configuration description see {@link #setUpFullTextTest()}.
     */
    public void testPathColumn() throws Exception {
        setUpFullTextTest();
        QueryResult result = execute(getFullTextStatement());
        RowIterator rows = result.getRows();
        if (getSize(rows) < 1) {
            fail("Query result did not return any nodes");
        }
        // re-aquire rows
        rows = result.getRows();

        // test mere existence
        rows.nextRow().getValue(jcrPath);
    }
View Full Code Here

     * For configuration description see {@link #setUpFullTextTest()}.
     */
    public void testScoreColumn() throws Exception {
        setUpFullTextTest();
        QueryResult result = execute(getFullTextStatement());
        RowIterator rows = result.getRows();
        // test mere existence
        rows.nextRow().getValue(jcrScore);
    }
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.