Search in sources :

Example 6 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 7 with Dataset

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;
}
Also used : Arrays(java.util.Arrays) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) MetricRegistry(com.codahale.metrics.MetricRegistry) InstrumentedEhcache(com.codahale.metrics.ehcache.InstrumentedEhcache) Cache(org.springframework.cache.Cache) CacheOperationInvocationContext(org.springframework.cache.interceptor.CacheOperationInvocationContext) Collection(java.util.Collection) Dataset(org.obiba.mica.dataset.domain.Dataset) CacheResolver(org.springframework.cache.interceptor.CacheResolver) Inject(javax.inject.Inject) Component(org.springframework.stereotype.Component) Lists(com.google.common.collect.Lists) CacheManager(org.springframework.cache.CacheManager) EhCacheCache(org.springframework.cache.ehcache.EhCacheCache) Optional(java.util.Optional) Dataset(org.obiba.mica.dataset.domain.Dataset) EhCacheCache(org.springframework.cache.ehcache.EhCacheCache) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(org.springframework.cache.Cache) EhCacheCache(org.springframework.cache.ehcache.EhCacheCache)

Example 8 with Dataset

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());
}
Also used : DatasetCountStatsBuilder(org.obiba.mica.search.CountStatsDtoBuilders.DatasetCountStatsBuilder) Dataset(org.obiba.mica.dataset.domain.Dataset) DatasetResultDto(org.obiba.mica.web.model.MicaSearch.DatasetResultDto)

Aggregations

Dataset (org.obiba.mica.dataset.domain.Dataset)8 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)4 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)4 Timed (com.codahale.metrics.annotation.Timed)3 Lists (com.google.common.collect.Lists)2 Collection (java.util.Collection)2 Optional (java.util.Optional)2 Inject (javax.inject.Inject)2 NotNull (javax.validation.constraints.NotNull)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)2 Component (org.springframework.stereotype.Component)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 InstrumentedEhcache (com.codahale.metrics.ehcache.InstrumentedEhcache)1 Strings (com.google.common.base.Strings)1 Maps (com.google.common.collect.Maps)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1