use of org.obiba.mica.contact.event.PersonUpdatedEvent 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.contact.event.PersonUpdatedEvent in project mica2 by obiba.
the class PersonService method micaConfigUpdated.
@Async
@Subscribe
public void micaConfigUpdated(MicaConfigUpdatedEvent event) {
event.getRemovedRoles().forEach(r -> {
log.info("Removing role {} from Persons.", r);
Set<Person> persons = Sets.newHashSet(personRepository.findByStudyMembershipsRole(r));
persons.addAll(personRepository.findByNetworkMembershipsRole(r));
persons.forEach(p -> {
p.removeAllMemberships(r);
personRepository.save(p);
eventBus.post(new PersonUpdatedEvent(p));
});
});
}
Aggregations