Search in sources :

Example 16 with Dataset

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

the class DraftCollectedDatasetResource method update.

@PUT
public Response update(Mica.DatasetDto datasetDto, @Context UriInfo uriInfo, @Nullable @QueryParam("comment") String comment) {
    checkPermission("/draft/collected-dataset", "EDIT");
    if (!datasetDto.hasId() || !datasetDto.getId().equals(id))
        throw new IllegalArgumentException("Not the expected dataset id");
    Dataset dataset = dtos.fromDto(datasetDto);
    if (!(dataset instanceof StudyDataset))
        throw new IllegalArgumentException("A study dataset is expected");
    datasetService.save((StudyDataset) dataset, comment);
    return Response.noContent().build();
}
Also used : StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Dataset(org.obiba.mica.dataset.domain.Dataset) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Example 17 with Dataset

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

the class DatasetController method getDataset.

private Dataset getDataset(String id, String shareKey) {
    Dataset dataset;
    if (Strings.isNullOrEmpty(shareKey)) {
        dataset = publishedDatasetService.findById(id);
        if (dataset == null)
            throw NoSuchDatasetException.withId(id);
        checkAccess((dataset instanceof StudyDataset) ? "/collected-dataset" : "/harmonized-dataset", id);
    } else {
        try {
            dataset = draftCollectedDatasetService.findById(id);
            checkPermission("/draft/collected-dataset", "VIEW", id, shareKey);
        } catch (NoSuchDatasetException ex) {
            dataset = draftHarmonizedDatasetService.findById(id);
            checkPermission("/draft/harmonized-dataset", "VIEW", id, shareKey);
        }
    }
    return dataset;
}
Also used : NoSuchDatasetException(org.obiba.mica.dataset.NoSuchDatasetException) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Dataset(org.obiba.mica.dataset.domain.Dataset) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Example 18 with Dataset

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

the class DatasetAnalysisController method getDataset.

private Dataset getDataset(String id) {
    Dataset dataset = publishedDatasetService.findById(id);
    if (dataset == null)
        throw NoSuchDatasetException.withId(id);
    checkAccess((dataset instanceof StudyDataset) ? "/collected-dataset" : "/harmonized-dataset", id);
    return dataset;
}
Also used : StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Dataset(org.obiba.mica.dataset.domain.Dataset) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Aggregations

Dataset (org.obiba.mica.dataset.domain.Dataset)18 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)13 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)8 Lists (com.google.common.collect.Lists)7 Inject (javax.inject.Inject)7 Component (org.springframework.stereotype.Component)6 Timed (com.codahale.metrics.annotation.Timed)5 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)5 Collectors (java.util.stream.Collectors)4 Collectors.toList (java.util.stream.Collectors.toList)4 Stream (java.util.stream.Stream)4 NotNull (javax.validation.constraints.NotNull)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)4 Async (org.springframework.scheduling.annotation.Async)4 Strings (com.google.common.base.Strings)3 java.util (java.util)3 List (java.util.List)3 Nullable (javax.annotation.Nullable)3 NoSuchDatasetException (org.obiba.mica.dataset.NoSuchDatasetException)3