Search in sources :

Example 1 with Caching

use of org.springframework.cache.annotation.Caching 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)

Example 2 with Caching

use of org.springframework.cache.annotation.Caching 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);
        Map<String, List<DatasetVariable>> harmonizationVariables = populateHarmonizedVariablesMap(dataset);
        eventBus.post(new DatasetPublishedEvent(dataset, wrappedGetDatasetVariables(dataset), harmonizationVariables, getCurrentUsername(), cascadingScope));
    // helper.asyncBuildDatasetVariablesCache(dataset, harmonizationVariables);
    } else {
        unPublishState(id);
        eventBus.post(new DatasetUnpublishedEvent(dataset));
    }
}
Also used : DatasetUnpublishedEvent(org.obiba.mica.dataset.event.DatasetUnpublishedEvent) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Caching(org.springframework.cache.annotation.Caching)

Example 3 with Caching

use of org.springframework.cache.annotation.Caching in project mica2 by obiba.

the class ProjectService method publish.

/**
 * Set the publication flag on a {@link Project}.
 *
 * @param id
 * @throws NoSuchProjectException
 */
@Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'project'") })
public void publish(@NotNull String id, boolean publish, PublishCascadingScope cascadingScope) throws NoSuchEntityException {
    Project project = projectRepository.findOne(id);
    if (project == null)
        return;
    if (publish) {
        publishState(id);
        eventBus.post(new ProjectPublishedEvent(project, getCurrentUsername(), cascadingScope));
    } else {
        unPublishState(id);
        eventBus.post(new ProjectUnpublishedEvent(project));
    }
}
Also used : Project(org.obiba.mica.project.domain.Project) ProjectPublishedEvent(org.obiba.mica.project.event.ProjectPublishedEvent) ProjectUnpublishedEvent(org.obiba.mica.project.event.ProjectUnpublishedEvent) Caching(org.springframework.cache.annotation.Caching)

Example 4 with Caching

use of org.springframework.cache.annotation.Caching in project mica2 by obiba.

the class NetworkService method publish.

/**
 * Set the publication flag on a {@link Network}.
 *
 * @param id
 * @throws NoSuchNetworkException
 */
@Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'network'") })
public void publish(@NotNull String id, boolean publish, PublishCascadingScope cascadingScope) throws NoSuchEntityException {
    Network network = networkRepository.findOne(id);
    if (network == null)
        return;
    if (publish) {
        processNetworkForPublishedNumberOfStudies(network);
        publishState(id);
        eventBus.post(new NetworkPublishedEvent(network, getCurrentUsername(), cascadingScope));
    } else {
        unPublishState(id);
        eventBus.post(new NetworkUnpublishedEvent(network));
    }
}
Also used : NetworkUnpublishedEvent(org.obiba.mica.network.event.NetworkUnpublishedEvent) NetworkPublishedEvent(org.obiba.mica.network.event.NetworkPublishedEvent) Network(org.obiba.mica.network.domain.Network) Caching(org.springframework.cache.annotation.Caching)

Example 5 with Caching

use of org.springframework.cache.annotation.Caching in project mica2 by obiba.

the class AbstractStudyService method publish.

@Caching(evict = { @CacheEvict(value = "aggregations-metadata", allEntries = true), @CacheEvict(value = { "studies-draft", "studies-published" }, key = "#id") })
public void publish(@NotNull String id, boolean publish, PublishCascadingScope cascadingScope) throws NoSuchEntityException {
    log.info("Publish study: {}", id);
    T study = getRepository().findOne(id);
    if (publish) {
        publishState(id);
        eventBus.post(new StudyPublishedEvent(study, getCurrentUsername(), cascadingScope));
    } else {
        unPublishState(id);
        eventBus.post(new StudyUnpublishedEvent(study));
    }
}
Also used : StudyPublishedEvent(org.obiba.mica.study.event.StudyPublishedEvent) StudyUnpublishedEvent(org.obiba.mica.study.event.StudyUnpublishedEvent) Caching(org.springframework.cache.annotation.Caching)

Aggregations

Caching (org.springframework.cache.annotation.Caching)6 DatasetPublishedEvent (org.obiba.mica.dataset.event.DatasetPublishedEvent)2 DatasetUnpublishedEvent (org.obiba.mica.dataset.event.DatasetUnpublishedEvent)2 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 DBRefAwareRepository (org.obiba.mica.core.repository.DBRefAwareRepository)1 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)1 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)1 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)1 Network (org.obiba.mica.network.domain.Network)1 NetworkPublishedEvent (org.obiba.mica.network.event.NetworkPublishedEvent)1 NetworkUnpublishedEvent (org.obiba.mica.network.event.NetworkUnpublishedEvent)1 Project (org.obiba.mica.project.domain.Project)1 ProjectPublishedEvent (org.obiba.mica.project.event.ProjectPublishedEvent)1 ProjectUnpublishedEvent (org.obiba.mica.project.event.ProjectUnpublishedEvent)1 StudyDeletedEvent (org.obiba.mica.study.event.StudyDeletedEvent)1 StudyPublishedEvent (org.obiba.mica.study.event.StudyPublishedEvent)1 StudyUnpublishedEvent (org.obiba.mica.study.event.StudyUnpublishedEvent)1