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();
}
use of org.obiba.mica.dataset.domain.Dataset in project mica2 by obiba.
the class DatasetCacheResolver method resolveCaches.
@Override
public synchronized Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> cacheOperationInvocationContext) {
Collection<Cache> res = Lists.newArrayList();
Optional<Object> dataset = Arrays.stream(cacheOperationInvocationContext.getArgs()).filter(o -> o instanceof Dataset).findFirst();
if (dataset.isPresent()) {
String cacheName = "dataset-" + ((Dataset) dataset.get()).getId();
Cache datasetCache = springCacheManager.getCache(cacheName);
if (datasetCache == null) {
CacheConfiguration conf = cacheManager.getEhcache("dataset-variables").getCacheConfiguration().clone();
conf.setName(cacheName);
cacheManager.addCache(new net.sf.ehcache.Cache(conf));
net.sf.ehcache.Cache cache = cacheManager.getCache(cacheName);
cacheManager.replaceCacheWithDecoratedCache(cache, InstrumentedEhcache.instrument(metricRegistry, cache));
datasetCache = new EhCacheCache(cacheManager.getEhcache(cacheName));
}
res.add(datasetCache);
}
return res;
}
use of org.obiba.mica.dataset.domain.Dataset in project mica2 by obiba.
the class DatasetQuery method processHits.
@Override
public void processHits(QueryResultDto.Builder builder, Searcher.DocumentResults results, QueryScope scope, CountStatsData counts) {
DatasetResultDto.Builder resBuilder = DatasetResultDto.newBuilder();
DatasetCountStatsBuilder datasetCountStatsBuilder = counts == null ? null : DatasetCountStatsBuilder.newBuilder(counts);
Consumer<Dataset> addDto = getDatasetConsumer(scope, resBuilder, datasetCountStatsBuilder);
List<Dataset> published = getPublishedDocumentsFromHitsByClassName(results, Dataset.class);
published.forEach(addDto::accept);
builder.setExtension(DatasetResultDto.result, resBuilder.build());
}
Aggregations