use of org.kuali.rice.kim.api.identity.entity.EntityDefault in project cu-kfs by CU-CommunityApps.
the class CuPayeeACHAccountMaintainableImpl method refresh.
@Override
public void refresh(String refreshCaller, Map fieldValues, MaintenanceDocument document) {
super.refresh(refreshCaller, fieldValues, document);
if (StringUtils.isNotEmpty(refreshCaller) && refreshCaller.equalsIgnoreCase("achPayeeLookupable")) {
PayeeACHAccount payeeAchAccount = (PayeeACHAccount) document.getNewMaintainableObject().getBusinessObject();
String payeeIdNumber = payeeAchAccount.getPayeeIdNumber();
String payeeIdentifierTypeCode = payeeAchAccount.getPayeeIdentifierTypeCode();
if (StringUtils.isNotEmpty(payeeAchAccount.getPayeeIdNumber())) {
// for Employee, retrieve from Person table by employee ID
if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.EMPLOYEE)) {
Person person = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
if (ObjectUtils.isNotNull(person)) {
payeeAchAccount.setPayeeEmailAddress(person.getEmailAddress());
}
} else // for Entity, retrieve from Entity table by entity ID then from Person table
if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.ENTITY)) {
if (ObjectUtils.isNotNull(payeeIdNumber)) {
EntityDefault entity = KimApiServiceLocator.getIdentityService().getEntityDefault(payeeIdNumber);
if (ObjectUtils.isNotNull(entity)) {
List<Principal> principals = entity.getPrincipals();
if (principals.size() > 0 && ObjectUtils.isNotNull(principals.get(0))) {
String principalId = principals.get(0).getPrincipalId();
Person person = SpringContext.getBean(PersonService.class).getPerson(principalId);
if (ObjectUtils.isNotNull(person)) {
payeeAchAccount.setPayeeEmailAddress(person.getEmailAddress());
}
}
}
}
}
}
}
}
Aggregations