Search in sources :

Example 1 with WhineyFunction

use of uk.ac.bbsrc.tgac.miso.core.util.WhineyFunction 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);
}
Also used : Consumer(java.util.function.Consumer) List(java.util.List) SequencingOrderCompletionDto(uk.ac.bbsrc.tgac.miso.dto.SequencingOrderCompletionDto) PaginationFilter(uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter) PoolDto(uk.ac.bbsrc.tgac.miso.dto.PoolDto) WhineyFunction(uk.ac.bbsrc.tgac.miso.core.util.WhineyFunction) Map(java.util.Map) IOException(java.io.IOException) PaginatedDataSource(uk.ac.bbsrc.tgac.miso.core.util.PaginatedDataSource) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) SequencingOrderCompletionDto(uk.ac.bbsrc.tgac.miso.dto.SequencingOrderCompletionDto) PoolDto(uk.ac.bbsrc.tgac.miso.dto.PoolDto) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 PaginatedDataSource (uk.ac.bbsrc.tgac.miso.core.util.PaginatedDataSource)1 PaginationFilter (uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter)1 WhineyFunction (uk.ac.bbsrc.tgac.miso.core.util.WhineyFunction)1 PoolDto (uk.ac.bbsrc.tgac.miso.dto.PoolDto)1 SequencingOrderCompletionDto (uk.ac.bbsrc.tgac.miso.dto.SequencingOrderCompletionDto)1