Search in sources :

Example 1 with IncrementalListResponse

use of org.apache.cayenne.util.IncrementalListResponse in project cayenne by apache.

the class ClientServerChannelQueryAction method interceptIncrementalListConversion.

private boolean interceptIncrementalListConversion() {
    int pageSize = serverMetadata.getPageSize();
    if (pageSize > 0 && serverMetadata.getCacheKey() != null) {
        List list = response.firstList();
        if (list.size() > pageSize && list instanceof IncrementalFaultList) {
            // cache
            channel.getQueryCache().put(serverMetadata, list);
            // extract and convert first page
            // TODO: andrus, 2008/03/05 - we no longer resolve the first page
            // automatically on the server... probably should not do it for the client
            // either... One rare case when this is completely undesirable is
            // subaction execution from 'interceptSinglePageQuery', as it doesn't even
            // care about the first page...
            List sublist = list.subList(0, pageSize);
            List firstPage = (serverMetadata.isFetchingDataRows()) ? new ArrayList(sublist) : toClientObjects(sublist);
            this.response = new IncrementalListResponse(firstPage, list.size());
            return DONE;
        }
    }
    return !DONE;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IncrementalListResponse(org.apache.cayenne.util.IncrementalListResponse)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 IncrementalListResponse (org.apache.cayenne.util.IncrementalListResponse)1