use of org.obiba.mica.search.reports.generators.StudyCsvReportGenerator in project mica2 by obiba.
the class PublishedStudiesSearchResource 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().isStudiesExportEnabled())
throw new BadRequestException("Studies export not enabled");
JoinQuery joinQuery = searcher.makeJoinQuery(query);
List<String> studyIds = joinQueryExecutor.query(QueryType.STUDY, joinQuery).getStudyResultDto().getExtension(MicaSearch.StudyResultDto.result).getSummariesList().stream().map(Mica.StudySummaryDto::getId).collect(toList());
ReportGenerator reporter = new StudyCsvReportGenerator(publishedStudyService.findByIds(studyIds, true), Strings.isNullOrEmpty(locale) ? joinQuery.getLocale() : locale, personService);
StreamingOutput stream = reporter::write;
return Response.ok(stream).header("Content-Disposition", "attachment; filename=\"Studies.zip\"").build();
}
use of org.obiba.mica.search.reports.generators.StudyCsvReportGenerator in project mica2 by obiba.
the class PublishedStudiesSetResource method reportStudies.
@GET
@Path("/documents/_report")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response reportStudies(@PathParam("id") String id, @QueryParam("locale") @DefaultValue("en") String locale) {
DocumentSet documentSet = getSecuredDocumentSet(id);
ReportGenerator reporter = new StudyCsvReportGenerator(studySetService.getPublishedStudies(documentSet, true), locale, personService);
StreamingOutput stream = reporter::write;
return Response.ok(stream).header("Content-Disposition", "attachment; filename=\"Studies.zip\"").build();
}
Aggregations