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));
}
}
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));
}
}
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));
}
}
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));
}
}
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));
}
}
Aggregations