use of uk.ac.bbsrc.tgac.miso.core.util.PaginatedDataSource in project miso-lims by miso-lims.
the class PoolPickerResponse method populate.
public <T> void populate(PaginatedDataSource<T> source, boolean sortOrder, String sortColumn, Integer limit, WhineyFunction<T, PoolPickerEntry> transform, PaginationFilter... filters) throws IOException {
Consumer<String> errorHandler = message -> errors.add(message);
Map<Long, List<PoolPickerEntry>> groupedByPool = source.list(errorHandler, 0, limit, sortOrder, sortColumn, filters).stream().map(WhineyFunction.rethrow(transform)).collect(Collectors.groupingBy(entry -> entry.getPool().getId()));
items = groupedByPool.values().stream().map(listOfPicks -> {
List<SequencingOrderCompletionDto> completionsByPool = listOfPicks.stream().flatMap(pick -> pick.getOrders().stream()).collect(Collectors.toList());
PoolDto pool = listOfPicks.get(0).getPool();
return new PoolPickerEntry(pool, completionsByPool);
}).collect(Collectors.toList());
numMatches = source.count(filters);
}
Aggregations