use of org.obiba.mica.study.event.StudyPublishedEvent in project mica2 by obiba.
the class ContactsRefactorUpgrade method execute.
@Override
public void execute(Version version) {
log.info("Executing contacts upgrade");
studyRepository.findAll().forEach(study -> {
study.getAllPersons().forEach(p -> p.setEmail(Strings.emptyToNull(p.getEmail())));
StudyState studyState = individualStudyService.findStateById(study.getId());
studyRepository.saveWithReferences(study);
eventBus.post(new DraftStudyUpdatedEvent(study));
study.getAllPersons().forEach(c -> eventBus.post(new PersonUpdatedEvent(c)));
if (studyState.isPublished()) {
eventBus.post(new StudyPublishedEvent(study, studyState.getPublishedBy(), PublishCascadingScope.ALL));
}
});
networkRepository.findAll().forEach(network -> {
network.getAllPersons().forEach(p -> p.setEmail(Strings.emptyToNull(p.getEmail())));
networkService.save(network, "System upgrade.");
if (network.isPublished()) {
networkService.publish(network.getId(), true);
}
});
}
use of org.obiba.mica.study.event.StudyPublishedEvent in project mica2 by obiba.
the class AbstractStudyService method removeRoles.
protected void removeRoles(@NotNull T study, Iterable<String> roles) {
saveInternal(study, String.format("Removed roles: %s", Joiner.on(", ").join(roles)), false);
S state = findStateById(study.getId());
if (state.isPublished()) {
publishState(study.getId());
eventBus.post(new StudyPublishedEvent(study, getCurrentUsername(), PublishCascadingScope.NONE));
}
}
use of org.obiba.mica.study.event.StudyPublishedEvent 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