public ServiceExecutionResult<SorRole> updateSorRole( final SorPerson sorPerson, final SorRole sorRole) { Assert.notNull(sorPerson, "sorPerson cannot be null."); Assert.notNull(sorRole, "sorRole cannot be null."); final Set validationErrors = this.validator.validate(sorRole); if (!validationErrors.isEmpty()) { // since because of existing design we cannot raise exception, we can only rollback the // transaction through code // OR-384 if (TransactionAspectSupport.currentTransactionStatus() != null) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } return new GeneralServiceExecutionResult<SorRole>(validationErrors); } final SorRole savedSorRole = this.personRepository.saveSorRole(sorRole); final Person person = this.personRepository.findByInternalId(sorPerson.getPersonId()); final Role role = person.findRoleBySoRRoleId(savedSorRole.getId()); if (role != null) { // update calculated role only if that role was previously converted to calculated one by // sorRoleElector role.recalculate(savedSorRole); this.personRepository.savePerson(person); } // else //do nothing i.e. don't update the calculated role if SorRoleElector Previously decided // not to convert this sor role to calculated role return new GeneralServiceExecutionResult<SorRole>(savedSorRole); }