Search in sources :

Example 6 with DatasetPublishedEvent

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

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

the class DatasetStateUpgrade method migrateDataset.

private <T extends AbstractGitPersistableService, T1 extends EntityStateRepository> void migrateDataset(Dataset dataset, T datasetService, T1 stateRepository, Supplier<EntityState> supplier) {
    EntityState state = datasetService.findEntityState(dataset, supplier);
    state.incrementRevisionsAhead();
    stateRepository.save(state);
    eventBus.post(new DatasetUpdatedEvent(dataset));
    gitService.save(dataset, "System upgrade");
    if (state.isPublished()) {
        datasetService.publishState(dataset.getId());
        eventBus.post(new DatasetPublishedEvent(dataset, null, null));
    }
}
Also used : DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) EntityState(org.obiba.mica.core.domain.EntityState) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent)

Aggregations

DatasetPublishedEvent (org.obiba.mica.dataset.event.DatasetPublishedEvent)7 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)4 DatasetUpdatedEvent (org.obiba.mica.dataset.event.DatasetUpdatedEvent)4 ExecutionException (java.util.concurrent.ExecutionException)3 NoSuchEntityException (org.obiba.mica.NoSuchEntityException)3 NoSuchDatasetException (org.obiba.mica.dataset.NoSuchDatasetException)3 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)3 NoSuchStudyException (org.obiba.mica.study.NoSuchStudyException)3 NoSuchValueTableException (org.obiba.magma.NoSuchValueTableException)2 NoSuchVariableException (org.obiba.magma.NoSuchVariableException)2 MissingCommentException (org.obiba.mica.core.service.MissingCommentException)2 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)2 DatasetUnpublishedEvent (org.obiba.mica.dataset.event.DatasetUnpublishedEvent)2 Caching (org.springframework.cache.annotation.Caching)2 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 MagmaRuntimeException (org.obiba.magma.MagmaRuntimeException)1 EntityState (org.obiba.mica.core.domain.EntityState)1 HarmonizationDatasetIndexedEvent (org.obiba.mica.dataset.event.HarmonizationDatasetIndexedEvent)1