Search in sources :

Example 1 with ExcelContingencyWriter

use of org.obiba.mica.dataset.search.rest.harmonization.ExcelContingencyWriter in project mica2 by obiba.

the class PublishedCollectedDatasetVariableResource method getContingencyExcel.

@GET
@Path("/contingency/_export")
@Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
@Timed
public Response getContingencyExcel(@QueryParam("by") String crossVariable) throws IOException {
    Pair<DatasetVariable, DatasetVariable> variables = getContingencyVariables(crossVariable);
    ByteArrayOutputStream res = new ExcelContingencyWriter(variables.getFirst(), variables.getSecond()).write(getContingencyDto(variables.getFirst(), variables.getSecond()));
    return Response.ok(res.toByteArray()).header("Content-Disposition", String.format("attachment; filename=\"contingency-table-%s-%s.xlsx\"", variableName, crossVariable)).build();
}
Also used : DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) ExcelContingencyWriter(org.obiba.mica.dataset.search.rest.harmonization.ExcelContingencyWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)1 ExcelContingencyWriter (org.obiba.mica.dataset.search.rest.harmonization.ExcelContingencyWriter)1