/** * {@inheritDoc} */ @Override public List<IndexSetConfig> findPaginated(Set<String> indexSetIds, int limit, int skip) { final List<DBQuery.Query> idQuery = indexSetIds.stream() .map(id -> DBQuery.is("_id", id)) .collect(Collectors.toList()); final DBQuery.Query query = DBQuery.or(idQuery.toArray(new DBQuery.Query[0])); return ImmutableList.copyOf(collection.find(query) .sort(DBSort.asc("title")) .skip(skip) .limit(limit) .toArray()); }
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); } }
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); } }
@Override public List<Alert> listForStreamIds(List<String> streamIds, AlertState state, int skip, int limit) { if (streamIds == null || streamIds.isEmpty()) { return Collections.emptyList(); } DBQuery.Query query = getFindAnyStreamQuery(streamIds); if (state != null && state != AlertState.ANY) { query = DBQuery.and(query, getFindByStateQuery(state)); } return Collections.unmodifiableList(this.coll.find(query) .sort(DBSort.desc(AlertImpl.FIELD_TRIGGERED_AT)) .skip(skip) .limit(limit) .toArray()); }
/** * 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); } }
/** * {@inheritDoc} */ @Override public List<IndexSetConfig> findPaginated(Set<String> indexSetIds, int limit, int skip) { final List<DBQuery.Query> idQuery = indexSetIds.stream() .map(id -> DBQuery.is("_id", id)) .collect(Collectors.toList()); final DBQuery.Query query = DBQuery.or(idQuery.toArray(new DBQuery.Query[0])); return ImmutableList.copyOf(collection.find(query) .sort(DBSort.asc("title")) .skip(skip) .limit(limit) .toArray()); }
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); }
@Override public List<Alert> listForStreamIds(List<String> streamIds, AlertState state, int skip, int limit) { if (streamIds == null || streamIds.isEmpty()) { return Collections.emptyList(); } DBQuery.Query query = getFindAnyStreamQuery(streamIds); if (state != null && state != AlertState.ANY) { query = DBQuery.and(query, getFindByStateQuery(state)); } return Collections.unmodifiableList(this.coll.find(query) .sort(DBSort.desc(AlertImpl.FIELD_TRIGGERED_AT)) .skip(skip) .limit(limit) .toArray()); }
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); }