Search in sources :

Example 1 with DatasetUnpublishedEvent

use of org.obiba.mica.dataset.event.DatasetUnpublishedEvent in project mica2 by obiba.

the class HarmonizedDatasetService method publish.

/**
 * Apply dataset publication flag.
 *
 * @param id
 * @param published
 */
@Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'dataset'") })
public void publish(@NotNull String id, boolean published, PublishCascadingScope cascadingScope) {
    HarmonizationDataset dataset = findById(id);
    helper.evictCache(dataset);
    if (published) {
        checkIsPublishable(dataset);
        publishState(id);
        eventBus.post(new DatasetPublishedEvent(dataset, wrappedGetDatasetVariables(dataset), null, getCurrentUsername(), cascadingScope));
        indexHarmonizedVariables(dataset);
    } else {
        unPublishState(id);
        eventBus.post(new DatasetUnpublishedEvent(dataset));
    }
}
Also used : DatasetUnpublishedEvent(org.obiba.mica.dataset.event.DatasetUnpublishedEvent) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Caching(org.springframework.cache.annotation.Caching)

Example 2 with DatasetUnpublishedEvent

use of org.obiba.mica.dataset.event.DatasetUnpublishedEvent in project mica2 by obiba.

the class CollectedDatasetService method publish.

/**
 * Apply dataset publication flag.
 *
 * @param id
 * @param published
 */
@Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'dataset'") })
public void publish(@NotNull String id, boolean published, PublishCascadingScope cascadingScope) {
    StudyDataset dataset = findById(id);
    helper.evictCache(dataset);
    if (published) {
        checkIsPublishable(dataset);
        Iterable<DatasetVariable> variables = wrappedGetDatasetVariables(dataset);
        publishState(id);
        prepareForIndex(dataset);
        eventBus.post(new DatasetPublishedEvent(dataset, variables, getCurrentUsername(), cascadingScope));
    // helper.asyncBuildDatasetVariablesCache(dataset, variables);
    } else {
        unPublishState(id);
        eventBus.post(new DatasetUnpublishedEvent(dataset));
    }
}
Also used : DatasetUnpublishedEvent(org.obiba.mica.dataset.event.DatasetUnpublishedEvent) DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Caching(org.springframework.cache.annotation.Caching)

Aggregations

DatasetPublishedEvent (org.obiba.mica.dataset.event.DatasetPublishedEvent)2 DatasetUnpublishedEvent (org.obiba.mica.dataset.event.DatasetUnpublishedEvent)2 Caching (org.springframework.cache.annotation.Caching)2 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)1 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)1 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)1