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;
}
}
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);
}
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;
}
Aggregations