use of org.obiba.mica.search.reports.ReportGenerator in project mica2 by obiba.
the class PublishedDatasetVariablesSetResource method reportVariables.
@GET
@Path("/documents/_report")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response reportVariables(@PathParam("id") String id, @QueryParam("locale") @DefaultValue("en") String locale) {
DocumentSet documentSet = getSecuredDocumentSet(id);
ReportGenerator reporter = new DatasetVariableCsvReportGenerator(variableSetService.getVariables(documentSet, false), locale);
StreamingOutput stream = reporter::write;
return Response.ok(stream).header("Content-Disposition", "attachment; filename=\"Variables.zip\"").build();
}
use of org.obiba.mica.search.reports.ReportGenerator in project mica2 by obiba.
the class DatasetVariableCsvReportGenerator method write.
@Override
public void write(OutputStream outputStream) {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream)) {
zipOutputStream.putNextEntry(new ZipEntry("variables.csv"));
super.write(zipOutputStream);
zipOutputStream.putNextEntry(new ZipEntry("categories.csv"));
ReportGenerator reporter = new DatasetCategoryCsvReportGenerator(variables, getLocale());
reporter.write(zipOutputStream);
} catch (IOException e) {
log.error("Error when reporting variables", e);
}
}
Aggregations