public PaginatedList<LookupTableDto> findPaginated(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { try (DBCursor<LookupTableDto> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1))) { return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); } }
public PaginatedList<CacheDto> findPaginated(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { try (DBCursor<CacheDto> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1))) { return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); } }
public PaginatedList<DataAdapterDto> findPaginated(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { try (DBCursor<DataAdapterDto> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1))) { return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); } }
/** * Returns a {@link PaginatedList<DTO>} for the given query and pagination parameters. * <p> * This method is only accessible by subclasses to avoid exposure of the {@link DBQuery} and {@link DBSort} * interfaces to consumers. * * @param query the query to execute * @param sort the sort builder for the query * @param page the page number that should be returned * @param perPage the number of entries per page * @return the paginated list */ protected PaginatedList<DTO> findPaginatedWithQueryAndSort(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { try (final DBCursor<DTO> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1))) { return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); } }
public PaginatedList<CacheDto> findPaginated(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { final DBCursor<CacheDto> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1)); return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); }
public PaginatedList<DataAdapterDto> findPaginated(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { final DBCursor<DataAdapterDto> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1)); return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); }
public PaginatedList<LookupTableDto> findPaginated(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { final DBCursor<LookupTableDto> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1)); return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); }