chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Streit <mcs...@gmail.com>
Subject How to iterate over an ItemIterable<QueryResult> more than once
Date Mon, 10 Sep 2012 18:20:03 GMT
Hello

I am curious about how to get around something I've encountered using the
ItemIterable<QueryResult>

Using the OpenCMIS 0.8.0 SNAPSHOT, we've been able to successfully add
Documents and use CMIS SQL to retrieve the list of documents using the
IN_FOLDER predicate.  I am able to iterate over the list of QueryResult
objects just as the GettingStarted project shows without an issue.

However, I have a need to potentially "walk over the list" a *second
time*but notice that a 2nd read attempt gets skipped (it won't get
into the for
loop the SECOND time).  I looked to see if there was some method that can
be called to reset or re-position the iterator, finding something called
"skipTo(Long position).

The example below simply shows the same thing (similar to GettiingStarted)
 attempted twice in sequence just to prove to myself the behavior I was
seeing:

*The first for {} loops through and prints OK...*


Whereas the 2nd attempt (below) simply skips over the loop (same behavior
with and without use of skipTo() so I am assuming I am missing the intent
or I am using the wrong approach to reset...but I don't want to have to
make query calls to simply "reload" the result set.


There are only about 12 records returned in this use case but it could be
as high as 20 or 30.



            for (QueryResult qr : queryResult) {
               LOGGER.info("--------------------------------------------\n"
+ i + " , " +
qr.getPropertyByQueryName("cmis:objectTypeId").getFirstValue() + " , "
                     +
qr.getPropertyByQueryName("cmis:name").getFirstValue() + " , " +
qr.getPropertyByQueryName("cmis:createdBy").getFirstValue() + " , "
                     +
qr.getPropertyByQueryName("cmis:objectId").getFirstValue() + " , " +
qr.getPropertyByQueryName("cmis:contentStreamFileName").getFirstValue() + "
, "
                     +
qr.getPropertyByQueryName("acme:attachmentType").getFirstValue() + " , " +
qr.getPropertyByQueryName("cmis:contentStreamFileName").getFirstValue() + "
, "
                     +
qr.getPropertyByQueryName("cmis:contentStreamMimeType").getFirstValue() + "
, " +
qr.getPropertyByQueryName("cmis:contentStreamLength").getFirstValue());

               i++;

            }


            int i = 1;
            queryResult.skipTo(0);
            for (QueryResult qr : queryResult) {
               LOGGER.info("--------------------------------------------\n"
+ i + " , " +
qr.getPropertyByQueryName("cmis:objectTypeId").getFirstValue() + " , "
                     +
qr.getPropertyByQueryName("cmis:name").getFirstValue() + " , " +
qr.getPropertyByQueryName("cmis:createdBy").getFirstValue() + " , "
                     +
qr.getPropertyByQueryName("cmis:objectId").getFirstValue() + " , " +
qr.getPropertyByQueryName("cmis:contentStreamFileName").getFirstValue() + "
, "
                     +
qr.getPropertyByQueryName("acme:attachmentType").getFirstValue() + " , " +
qr.getPropertyByQueryName("cmis:contentStreamFileName").getFirstValue() + "
, "
                     +
qr.getPropertyByQueryName("cmis:contentStreamMimeType").getFirstValue() + "
, " +
qr.getPropertyByQueryName("cmis:contentStreamLength").getFirstValue());

               i++;


            }

Any insight would be appreciated.  I am sure I am doing something wrong.
FWIW, the back-end ECM product we are experimenting with is Alfreso 4
Community but I assume this is NOT product specific.

Thanks

Mark

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message