Search in sources :

Example 1 with NetworkCountStatsBuilder

use of org.obiba.mica.search.CountStatsDtoBuilders.NetworkCountStatsBuilder in project mica2 by obiba.

the class NetworkQuery method processHits.

@Override
public void processHits(QueryResultDto.Builder builder, Searcher.DocumentResults results, QueryScope scope, CountStatsData counts) throws IOException {
    NetworkResultDto.Builder resBuilder = NetworkResultDto.newBuilder();
    NetworkCountStatsBuilder networkCountStatsBuilder = counts == null ? null : NetworkCountStatsBuilder.newBuilder(counts);
    Consumer<Network> addDto = networkConsumer(scope, resBuilder, networkCountStatsBuilder);
    List<Network> networks = Lists.newArrayList();
    for (Searcher.DocumentResult result : results.getDocuments()) {
        if (result.hasSource())
            networks.add(objectMapper.readValue(result.getSourceInputStream(), Network.class));
    }
    networks.forEach(addDto);
    builder.setExtension(NetworkResultDto.result, resBuilder.build());
}
Also used : NetworkCountStatsBuilder(org.obiba.mica.search.CountStatsDtoBuilders.NetworkCountStatsBuilder) Network(org.obiba.mica.network.domain.Network) Searcher(org.obiba.mica.spi.search.Searcher) NetworkResultDto(org.obiba.mica.web.model.MicaSearch.NetworkResultDto)

Aggregations

Network (org.obiba.mica.network.domain.Network)1 NetworkCountStatsBuilder (org.obiba.mica.search.CountStatsDtoBuilders.NetworkCountStatsBuilder)1 Searcher (org.obiba.mica.spi.search.Searcher)1 NetworkResultDto (org.obiba.mica.web.model.MicaSearch.NetworkResultDto)1