Search in sources :

Example 16 with DatasetVariable

use of org.obiba.mica.dataset.domain.DatasetVariable in project mica2 by obiba.

the class PublishedHarmonizedDatasetVariableResource 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) 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)

Example 17 with DatasetVariable

use of org.obiba.mica.dataset.domain.DatasetVariable in project mica2 by obiba.

the class VariableQuery method processHits.

@Override
protected void processHits(MicaSearch.QueryResultDto.Builder builder, Searcher.DocumentResults results, QueryScope scope, CountStatsData counts) throws IOException {
    MicaSearch.DatasetVariableResultDto.Builder resBuilder = MicaSearch.DatasetVariableResultDto.newBuilder();
    Map<String, BaseStudy> studyMap = Maps.newHashMap();
    Map<String, Network> networkMap = Maps.newHashMap();
    for (Searcher.DocumentResult result : results.getDocuments()) {
        if (result.hasSource()) {
            DatasetVariable.IdResolver resolver = DatasetVariable.IdResolver.from(result.getId());
            DatasetVariable variable = objectMapper.readValue(result.getSourceInputStream(), DatasetVariable.class);
            resBuilder.addSummaries(processHit(resolver, variable, studyMap, networkMap));
        }
    }
    builder.setExtension(MicaSearch.DatasetVariableResultDto.result, resBuilder.build());
}
Also used : DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) Network(org.obiba.mica.network.domain.Network) BaseStudy(org.obiba.mica.study.domain.BaseStudy)

Aggregations

DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)17 Timed (com.codahale.metrics.annotation.Timed)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 List (java.util.List)4 BadRequestException (javax.ws.rs.BadRequestException)3 NoSuchValueTableException (org.obiba.magma.NoSuchValueTableException)3 NoSuchVariableException (org.obiba.magma.NoSuchVariableException)3 NoSuchEntityException (org.obiba.mica.NoSuchEntityException)3 StudyTable (org.obiba.mica.core.domain.StudyTable)3 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)3 DatasetPublishedEvent (org.obiba.mica.dataset.event.DatasetPublishedEvent)3 Strings (com.google.common.base.Strings)2 Lists (com.google.common.collect.Lists)2 Collectors (java.util.stream.Collectors)2 Collectors.toList (java.util.stream.Collectors.toList)2 Inject (javax.inject.Inject)2 NotNull (javax.validation.constraints.NotNull)2