use of org.obiba.mica.dataset.domain.DatasetVariable in project mica2 by obiba.
the class PublishedCollectedDatasetVariableResource method getContingencyVariables.
private Pair<DatasetVariable, DatasetVariable> getContingencyVariables(String crossVariable) {
if (Strings.isNullOrEmpty(crossVariable))
throw new BadRequestException("Cross variable name is required for the contingency table");
DatasetVariable var = getDatasetVariable(datasetId, variableName, DatasetVariable.Type.Collected, null);
DatasetVariable crossVar = getDatasetVariable(datasetId, crossVariable, DatasetVariable.Type.Collected, null);
return Pair.create(var, crossVar);
}
use of org.obiba.mica.dataset.domain.DatasetVariable in project mica2 by obiba.
the class PublishedDataschemaDatasetVariableResource 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 value = new CsvContingencyWriter(variables.getFirst(), variables.getSecond()).write(getDatasetVariableContingenciesDto(variables.getFirst(), variables.getSecond()));
return Response.ok(value.toByteArray()).header("Content-Disposition", String.format("attachment; filename=\"contingency-table-%s-%s.csv\"", variableName, crossVariable)).build();
}
use of org.obiba.mica.dataset.domain.DatasetVariable in project mica2 by obiba.
the class PublishedDataschemaDatasetVariableResource method getContingencyVariables.
private Pair<DatasetVariable, DatasetVariable> getContingencyVariables(String crossVariable) {
if (Strings.isNullOrEmpty(crossVariable))
throw new BadRequestException("Cross variable name is required for the contingency table");
DatasetVariable var = getDatasetVariable(datasetId, variableName, DatasetVariable.Type.Dataschema, null);
DatasetVariable crossVar = getDatasetVariable(datasetId, crossVariable, DatasetVariable.Type.Dataschema, null);
return Pair.create(var, crossVar);
}
use of org.obiba.mica.dataset.domain.DatasetVariable in project mica2 by obiba.
the class PublishedHarmonizedDatasetVariableResource 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();
}
use of org.obiba.mica.dataset.domain.DatasetVariable in project mica2 by obiba.
the class PublishedHarmonizedDatasetVariableResource method getContingencyVariables.
private Pair<DatasetVariable, DatasetVariable> getContingencyVariables(String crossVariable) {
if (Strings.isNullOrEmpty(crossVariable))
throw new BadRequestException("Cross variable name is required for the contingency table");
DatasetVariable var = getDatasetVariable(datasetId, variableName, DatasetVariable.Type.Harmonized, studyId, project, table, tableType);
DatasetVariable crossVar = getDatasetVariable(datasetId, crossVariable, DatasetVariable.Type.Harmonized, studyId, project, table, tableType);
return Pair.create(var, crossVar);
}
Aggregations