Search in sources :

Example 1 with EntityDefault

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());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) PersonService(org.kuali.rice.kim.api.identity.PersonService) List(java.util.List) Person(org.kuali.rice.kim.api.identity.Person) EntityDefault(org.kuali.rice.kim.api.identity.entity.EntityDefault)

Aggregations

List (java.util.List)1 PayeeACHAccount (org.kuali.kfs.pdp.businessobject.PayeeACHAccount)1 Person (org.kuali.rice.kim.api.identity.Person)1 PersonService (org.kuali.rice.kim.api.identity.PersonService)1 EntityDefault (org.kuali.rice.kim.api.identity.entity.EntityDefault)1