Search in sources :

Example 6 with ListResponse

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

the class DataContextQueryAction method interceptPaginatedQuery.

@Override
protected boolean interceptPaginatedQuery() {
    if (metadata.getPageSize() > 0) {
        Integer maxIdQualifierSize = actingDataContext.getParentDataDomain().getMaxIdQualifierSize();
        List<?> paginatedList;
        List<Object> rsMapping = metadata.getResultSetMapping();
        boolean mixedResults = false;
        if (rsMapping != null) {
            if (rsMapping.size() > 1) {
                mixedResults = true;
            } else if (rsMapping.size() == 1) {
                mixedResults = !(rsMapping.get(0) instanceof EntityResultSegment) || !metadata.isSingleResultSetMapping();
            }
        }
        if (mixedResults) {
            paginatedList = new MixedResultIncrementalFaultList<>(actingDataContext, query, maxIdQualifierSize);
        } else {
            DbEntity dbEntity = metadata.getDbEntity();
            if (dbEntity != null && dbEntity.getPrimaryKeys().size() == 1) {
                paginatedList = new SimpleIdIncrementalFaultList<>(actingDataContext, query, maxIdQualifierSize);
            } else {
                paginatedList = new IncrementalFaultList<>(actingDataContext, query, maxIdQualifierSize);
            }
        }
        response = new ListResponse(paginatedList);
        return DONE;
    }
    return !DONE;
}
Also used : DbEntity(org.apache.cayenne.map.DbEntity) ListResponse(org.apache.cayenne.util.ListResponse) EntityResultSegment(org.apache.cayenne.query.EntityResultSegment)

Aggregations

ListResponse (org.apache.cayenne.util.ListResponse)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Query (org.apache.cayenne.query.Query)2 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)1 DataChannelQueryFilter (org.apache.cayenne.DataChannelQueryFilter)1 DataChannelQueryFilterChain (org.apache.cayenne.DataChannelQueryFilterChain)1 DataChannelSyncFilter (org.apache.cayenne.DataChannelSyncFilter)1 DataChannelSyncFilterChain (org.apache.cayenne.DataChannelSyncFilterChain)1 DataRow (org.apache.cayenne.DataRow)1 ObjectContext (org.apache.cayenne.ObjectContext)1 ObjectId (org.apache.cayenne.ObjectId)1 QueryResponse (org.apache.cayenne.QueryResponse)1 PostPersist (org.apache.cayenne.annotation.PostPersist)1 QueryCache (org.apache.cayenne.cache.QueryCache)1 QueryCacheEntryFactory (org.apache.cayenne.cache.QueryCacheEntryFactory)1 ServerRuntime (org.apache.cayenne.configuration.server.ServerRuntime)1 Inject (org.apache.cayenne.di.Inject)1 GraphDiff (org.apache.cayenne.graph.GraphDiff)1 DbEntity (org.apache.cayenne.map.DbEntity)1