Search in sources :

Example 1 with NetworkCsvReportGenerator

use of org.obiba.mica.search.reports.generators.NetworkCsvReportGenerator in project mica2 by obiba.

the class PublishedNetworksSearchResource method export.

@POST
@Path("/_export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response export(@FormParam("query") String query, @FormParam("locale") @DefaultValue("en") String locale) {
    if (!micaConfigService.getConfig().isNetworksExportEnabled())
        throw new BadRequestException("Networks export not enabled");
    JoinQuery joinQuery = searcher.makeJoinQuery(query);
    List<String> networkIds = joinQueryExecutor.query(QueryType.NETWORK, joinQuery).getNetworkResultDto().getExtension(MicaSearch.NetworkResultDto.result).getNetworksList().stream().map(Mica.NetworkDto::getId).collect(toList());
    ReportGenerator reporter = new NetworkCsvReportGenerator(publishedNetworkService.findByIds(networkIds, true), Strings.isNullOrEmpty(locale) ? joinQuery.getLocale() : locale, personService);
    StreamingOutput stream = reporter::write;
    return Response.ok(stream).header("Content-Disposition", "attachment; filename=\"Networks.zip\"").build();
}
Also used : ReportGenerator(org.obiba.mica.search.reports.ReportGenerator) JoinQueryReportGenerator(org.obiba.mica.search.reports.JoinQueryReportGenerator) NetworkCsvReportGenerator(org.obiba.mica.search.reports.generators.NetworkCsvReportGenerator) JoinQuery(org.obiba.mica.spi.search.support.JoinQuery) StreamingOutput(javax.ws.rs.core.StreamingOutput) Mica(org.obiba.mica.web.model.Mica) NetworkCsvReportGenerator(org.obiba.mica.search.reports.generators.NetworkCsvReportGenerator)

Example 2 with NetworkCsvReportGenerator

use of org.obiba.mica.search.reports.generators.NetworkCsvReportGenerator in project mica2 by obiba.

the class PublishedNetworksSetResource method reportNetworks.

@GET
@Path("/documents/_report")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response reportNetworks(@PathParam("id") String id, @QueryParam("locale") @DefaultValue("en") String locale) {
    DocumentSet documentSet = getSecuredDocumentSet(id);
    ReportGenerator reporter = new NetworkCsvReportGenerator(networkSetService.getPublishedNetworks(documentSet, true), locale, personService);
    StreamingOutput stream = reporter::write;
    return Response.ok(stream).header("Content-Disposition", "attachment; filename=\"Networks.zip\"").build();
}
Also used : ReportGenerator(org.obiba.mica.search.reports.ReportGenerator) NetworkCsvReportGenerator(org.obiba.mica.search.reports.generators.NetworkCsvReportGenerator) StreamingOutput(javax.ws.rs.core.StreamingOutput) DocumentSet(org.obiba.mica.core.domain.DocumentSet) NetworkCsvReportGenerator(org.obiba.mica.search.reports.generators.NetworkCsvReportGenerator)

Aggregations

StreamingOutput (javax.ws.rs.core.StreamingOutput)2 ReportGenerator (org.obiba.mica.search.reports.ReportGenerator)2 NetworkCsvReportGenerator (org.obiba.mica.search.reports.generators.NetworkCsvReportGenerator)2 DocumentSet (org.obiba.mica.core.domain.DocumentSet)1 JoinQueryReportGenerator (org.obiba.mica.search.reports.JoinQueryReportGenerator)1 JoinQuery (org.obiba.mica.spi.search.support.JoinQuery)1 Mica (org.obiba.mica.web.model.Mica)1