Search in sources :

Example 1 with NoSuchDatasetException

use of org.obiba.mica.dataset.NoSuchDatasetException in project mica2 by obiba.

the class DatasetService method getNextId.

@Nullable
protected String getNextId(@Nullable LocalizedString suggested) {
    if (suggested == null)
        return null;
    String prefix = suggested.asUrlSafeString().toLowerCase();
    if (Strings.isNullOrEmpty(prefix))
        return null;
    String next = prefix;
    try {
        findById(next);
        for (int i = 1; i <= 1000; i++) {
            next = prefix + "-" + i;
            findById(next);
        }
        return null;
    } catch (NoSuchDatasetException e) {
        return next;
    }
}
Also used : NoSuchDatasetException(org.obiba.mica.dataset.NoSuchDatasetException) LocalizedString(org.obiba.mica.core.domain.LocalizedString) Nullable(javax.annotation.Nullable)

Example 2 with NoSuchDatasetException

use of org.obiba.mica.dataset.NoSuchDatasetException 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 3 with NoSuchDatasetException

use of org.obiba.mica.dataset.NoSuchDatasetException 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)

Aggregations

NoSuchDatasetException (org.obiba.mica.dataset.NoSuchDatasetException)3 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)2 Nullable (javax.annotation.Nullable)1 LocalizedString (org.obiba.mica.core.domain.LocalizedString)1 Dataset (org.obiba.mica.dataset.domain.Dataset)1 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)1