Search in sources :

Example 6 with ReportGenerator

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();
}
Also used : DatasetVariableCsvReportGenerator(org.obiba.mica.search.reports.generators.DatasetVariableCsvReportGenerator) DatasetVariableCsvReportGenerator(org.obiba.mica.search.reports.generators.DatasetVariableCsvReportGenerator) ReportGenerator(org.obiba.mica.search.reports.ReportGenerator) StreamingOutput(javax.ws.rs.core.StreamingOutput) DocumentSet(org.obiba.mica.core.domain.DocumentSet)

Example 7 with ReportGenerator

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);
    }
}
Also used : ReportGenerator(org.obiba.mica.search.reports.ReportGenerator) ZipOutputStream(java.util.zip.ZipOutputStream) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException)

Aggregations

ReportGenerator (org.obiba.mica.search.reports.ReportGenerator)7 StreamingOutput (javax.ws.rs.core.StreamingOutput)5 DocumentSet (org.obiba.mica.core.domain.DocumentSet)3 IOException (java.io.IOException)2 ZipEntry (java.util.zip.ZipEntry)2 ZipOutputStream (java.util.zip.ZipOutputStream)2 JoinQueryReportGenerator (org.obiba.mica.search.reports.JoinQueryReportGenerator)2 NetworkCsvReportGenerator (org.obiba.mica.search.reports.generators.NetworkCsvReportGenerator)2 StudyCsvReportGenerator (org.obiba.mica.search.reports.generators.StudyCsvReportGenerator)2 JoinQuery (org.obiba.mica.spi.search.support.JoinQuery)2 Mica (org.obiba.mica.web.model.Mica)2 List (java.util.List)1 Person (org.obiba.mica.core.domain.Person)1 DatasetVariableCsvReportGenerator (org.obiba.mica.search.reports.generators.DatasetVariableCsvReportGenerator)1 SpecificStudyReportGenerator (org.obiba.mica.search.reports.generators.SpecificStudyReportGenerator)1 BaseStudy (org.obiba.mica.study.domain.BaseStudy)1