Search in sources :

Example 26 with HarmonizationDataset

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

the class StudyPackageImportServiceImpl method importDataset.

private void importDataset(HarmonizationDataset dataset, boolean publish) {
    try {
        HarmonizationDataset existing = harmonizedDatasetService.findById(dataset.getId());
        // TODO merge study tables
        harmonizedDatasetService.save(existing);
    } catch (NoSuchDatasetException e) {
        harmonizedDatasetService.save(dataset);
    }
    if (publish)
        harmonizedDatasetService.publish(dataset.getId(), publish, PublishCascadingScope.ALL);
}
Also used : NoSuchDatasetException(org.obiba.mica.dataset.NoSuchDatasetException) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Example 27 with HarmonizationDataset

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

the class PublishedDataschemaDatasetVariableResource method getVariableFacets.

@GET
@Path("/facet")
@Timed
public List<Search.QueryResultDto> getVariableFacets() {
    ImmutableList.Builder<Search.QueryResultDto> builder = ImmutableList.builder();
    HarmonizationDataset dataset = getDataset(HarmonizationDataset.class, datasetId);
    dataset.getBaseStudyTables().forEach(table -> {
        try {
            String studyId = table.getStudyId();
            builder.add(datasetService.getVariableFacet(dataset, variableName, studyId, table.getProject(), table.getTable()));
        } catch (NoSuchVariableException | NoSuchValueTableException e) {
            // case the study has not implemented this dataschema variable
            builder.add(Search.QueryResultDto.newBuilder().setTotalHits(0).build());
        }
    });
    return builder.build();
}
Also used : NoSuchValueTableException(org.obiba.magma.NoSuchValueTableException) NoSuchVariableException(org.obiba.magma.NoSuchVariableException) ImmutableList(com.google.common.collect.ImmutableList) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 28 with HarmonizationDataset

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

the class PublishedHarmonizedDatasetResource method getVariableHarmonizationsInternal.

private Mica.DatasetVariablesHarmonizationsDto getVariableHarmonizationsInternal(String id, int from, int limit, String sort, String order, boolean includeSummaries) {
    checkAccess(id);
    Mica.DatasetVariablesHarmonizationsDto.Builder builder = Mica.DatasetVariablesHarmonizationsDto.newBuilder();
    HarmonizationDataset dataset = getDataset(HarmonizationDataset.class, id);
    Mica.DatasetVariablesDto variablesDto = getDatasetVariableDtos(id, DatasetVariable.Type.Dataschema, from, limit, sort, order);
    builder.setTotal(variablesDto.getTotal()).setLimit(variablesDto.getLimit()).setFrom(variablesDto.getFrom());
    variablesDto.getVariablesList().forEach(variable -> builder.addVariableHarmonizations(getVariableHarmonizationDto(dataset, variable.getName(), includeSummaries)));
    return builder.build();
}
Also used : Mica(org.obiba.mica.web.model.Mica) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Aggregations

HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)28 Path (javax.ws.rs.Path)10 NoSuchVariableException (org.obiba.magma.NoSuchVariableException)9 GET (javax.ws.rs.GET)8 NoSuchValueTableException (org.obiba.magma.NoSuchValueTableException)8 Timed (com.codahale.metrics.annotation.Timed)7 ImmutableList (com.google.common.collect.ImmutableList)7 IOException (java.io.IOException)4 List (java.util.List)4 BaseStudyTable (org.obiba.mica.core.domain.BaseStudyTable)4 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)4 Mica (org.obiba.mica.web.model.Mica)4 Lists (com.google.common.collect.Lists)3 Inject (javax.inject.Inject)3 HarmonizationStudyTable (org.obiba.mica.core.domain.HarmonizationStudyTable)3 StudyTable (org.obiba.mica.core.domain.StudyTable)3 Dataset (org.obiba.mica.dataset.domain.Dataset)3 Strings (com.google.common.base.Strings)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Collection (java.util.Collection)2