Search in sources :

Example 1 with CsvContingencyWriter

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

the class PublishedCollectedDatasetVariableResource method getContingencyCsv.

@GET
@Path("/contingency/_export")
@Produces("text/csv")
@Timed
public Response getContingencyCsv(@QueryParam("by") String crossVariable) throws IOException {
    Pair<DatasetVariable, DatasetVariable> variables = getContingencyVariables(crossVariable);
    ByteArrayOutputStream res = new CsvContingencyWriter(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.csv\"", variableName, crossVariable)).build();
}
Also used : DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) CsvContingencyWriter(org.obiba.mica.dataset.search.rest.harmonization.CsvContingencyWriter) 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 CsvContingencyWriter (org.obiba.mica.dataset.search.rest.harmonization.CsvContingencyWriter)1