Search in sources :

Example 21 with HarmonizationDataset

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

the class DraftDataschemaDatasetVariableResource method getVariableFacets.

@GET
@Path("/facet")
public List<Search.QueryResultDto> getVariableFacets() {
    ImmutableList.Builder<Search.QueryResultDto> builder = ImmutableList.builder();
    HarmonizationDataset dataset = getDataset();
    dataset.getBaseStudyTables().forEach(table -> {
        try {
            String studyId = table.getStudyId();
            builder.add(datasetService.getVariableFacet(dataset, variableName, studyId, table.getProject(), table.getTable()));
        } catch (NoSuchVariableException | NoSuchValueTableException e) {
        // ignore (case the study has not implemented this dataschema variable)
        }
    });
    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) GET(javax.ws.rs.GET)

Example 22 with HarmonizationDataset

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

the class DraftDataschemaDatasetVariableResource method getVariableSummaries.

@GET
@Path("/summary")
public List<Math.SummaryStatisticsDto> getVariableSummaries() {
    ImmutableList.Builder<Math.SummaryStatisticsDto> builder = ImmutableList.builder();
    HarmonizationDataset dataset = getDataset();
    dataset.getBaseStudyTables().forEach(table -> {
        try {
            String studyId = table.getStudyId();
            builder.add(datasetService.getVariableSummary(dataset, variableName, studyId, table.getProject(), table.getTable()).getWrappedDto());
        } catch (NoSuchVariableException | NoSuchValueTableException e) {
        // ignore (case the study has not implemented this dataschema variable)
        }
    });
    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) GET(javax.ws.rs.GET)

Example 23 with HarmonizationDataset

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

the class DraftDataschemaDatasetVariableResource method getHarmonizedVariables.

@GET
@Path("/harmonizations")
public List<Mica.DatasetVariableDto> getHarmonizedVariables() {
    ImmutableList.Builder<Mica.DatasetVariableDto> builder = ImmutableList.builder();
    HarmonizationDataset dataset = getDataset();
    dataset.getBaseStudyTables().forEach(table -> {
        try {
            builder.add(dtos.asDto(datasetService.getDatasetVariable(dataset, variableName, table)));
        } catch (NoSuchVariableException | NoSuchValueTableException e) {
        // ignore (case the study has not implemented this dataschema variable)
        }
    });
    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) GET(javax.ws.rs.GET)

Example 24 with HarmonizationDataset

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

the class Mica2Upgrade method migrateHarmonizationDataset.

private void migrateHarmonizationDataset() {
    List<HarmonizationDataset> harmonizationDatasetsWithoutModel = harmonizationDatasetRepository.findWithoutModel();
    if (!harmonizationDatasetsWithoutModel.isEmpty()) {
        logger.info("Migrating harmonization datasets 1.x to 2.x: START");
        for (HarmonizationDataset harmonizationDatasetWithoutModel : harmonizationDatasetsWithoutModel) {
            harmonizationDatasetWithoutModel.getModel();
            harmonizationDatasetRepository.save(harmonizationDatasetWithoutModel);
        }
        logger.info("Migrating harmonization datasets: END");
    }
}
Also used : HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Example 25 with HarmonizationDataset

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

the class HarmonizedDatasetService method delete.

public void delete(String id) {
    HarmonizationDataset dataset = harmonizationDatasetRepository.findOne(id);
    if (dataset == null) {
        throw NoSuchDatasetException.withId(id);
    }
    fileSystemService.delete(FileUtils.getEntityPath(dataset));
    helper.evictCache(dataset);
    harmonizationDatasetStateRepository.delete(id);
    harmonizationDatasetRepository.delete(id);
    gitService.deleteGitRepository(dataset);
    eventBus.post(new DatasetDeletedEvent(dataset));
}
Also used : DatasetDeletedEvent(org.obiba.mica.dataset.event.DatasetDeletedEvent) 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