chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lu, Wentao" <Wentao...@bchydro.com>
Subject CMIS paging query result sample code
Date Thu, 16 Nov 2017 20:05:57 GMT
Hi,

Is there a sample code for OpenCMIS to paging query result?  We have a query that will return
large result set, we want to use paging query to avoid timeout if return all dataset in one
query from backend FileNet repository, is there a sample code we can reference?  I googled
but get confused sample code especially after the first query call,

     while (results.getHasMoreItems()){
         PAGE_NUM ++;
//Should we do another session.query() call or just use the results.skipTo() from the first
query result?
         ItemIterable<QueryResult>  tmp_results = session.query(queryString, false).skipTo(PAGE_NUM
* PAGE_SIZE).getPage(PAGE_SIZE);   //this line or next line?
         ItemIterable<QueryResult>  tmp_results = results.skipTo(PAGE_NUM * PAGE_SIZE).getPage(PAGE_SIZE);

        for (QueryResult result : tmp_results) {
          System.out.println(result.getPropertyValueByQueryName("cmis:name"));
          resultCount++;
        }
    }

Here is the complete code snip
     String queryString = "SELECT cmis:name FROM InformationSystem";

     int PAGE_NUM = 0;
     int PAGE_SIZE = 500;

     ItemIterable<QueryResult> results = session.query(queryString, false).skipTo(PAGE_NUM
* PAGE_SIZE).getPage(PAGE_SIZE);
     int resultCount = 0;
     for (QueryResult result : results) {
          System.out.println(result.getPropertyValueByQueryName("cmis:name"));
          resultCount ++;
     }
     System.out.println("resultCount="+resultCount);

     while (results.getHasMoreItems()){
         PAGE_NUM ++;
//Should we do another session.query() call or just use the results.skipTo() from the first
query result?
         ItemIterable<QueryResult>  tmp_results = session.query(queryString, false).skipTo(PAGE_NUM
* PAGE_SIZE).getPage(PAGE_SIZE);
         ItemIterable<QueryResult>  tmp_results = results.skipTo(PAGE_NUM * PAGE_SIZE).getPage(PAGE_SIZE);

        for (QueryResult result : tmp_results) {
          System.out.println(result.getPropertyValueByQueryName("cmis:name"));
          resultCount++;
        }
        System.out.println("resultCount="+resultCount);
    }



Thanks
Wentao
________________________________
This email and its attachments are intended solely for the personal use of the individual
or entity named above. Any use of this communication by an unintended recipient is strictly
prohibited. If you have received this email in error, any publication, use, reproduction,
disclosure or dissemination of its contents is strictly prohibited. Please immediately delete
this message and its attachments from your computer and servers. We would also appreciate
if you would contact us by a collect call or return email to notify us of this error. Thank
you for your cooperation.
-BCHydroDisclaimerID5.2.8.1541

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