Search in sources :

Example 31 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class CuAutoDisapproveDocumentsServiceImpl method autoDisapprovalYearEndDocument.

protected void autoDisapprovalYearEndDocument(Document document, String annotationForAutoDisapprovalDocument) throws Exception {
    Person systemUser = personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER);
    Note approveNote = getNoteService().createNote(new Note(), document.getDocumentHeader(), systemUser.getPrincipalId());
    approveNote.setNoteText(annotationForAutoDisapprovalDocument);
    approveNote.setAuthorUniversalIdentifier(systemUser.getPrincipalId());
    approveNote.setNotePostedTimestampToCurrent();
    getNoteService().save(approveNote);
    document.addNote(approveNote);
    getDocumentService().prepareWorkflowDocument(document);
    getDocumentService().superUserDisapproveDocumentWithoutSaving(document, "Disapproval of Outstanding Documents - Year End Cancellation Process");
    UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(), document.getDocumentHeader().getWorkflowDocument());
}
Also used : Note(org.kuali.kfs.krad.bo.Note) Person(org.kuali.rice.kim.api.identity.Person)

Example 32 with Person

use of org.kuali.rice.kim.api.identity.Person 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)

Example 33 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherPayeeServiceImplTest method testService.

public void testService() {
    Person alumni = null;
    Person student = null;
    Person employee = null;
    boolean isAlumni = false;
    boolean isStudent = false;
    boolean isEmployee = false;
    List alumniResults = unitTestSqlDao.sqlSelect(alumniSql);
    Object aresult = alumniResults.get(0);
    String[] asplit = aresult.toString().split(",");
    String[] aFdocSplit = asplit[0].split("=");
    String aFdoc = aFdocSplit[1].replaceAll(",", "");
    aFdoc = aFdoc.trim();
    String[] aIdSplit = asplit[1].split("=");
    String aentid = aIdSplit[1].replaceAll("}", "");
    aentid = aentid.trim();
    alumniResults.clear();
    List studentResults = unitTestSqlDao.sqlSelect(studentSql);
    Object sresult = studentResults.get(0);
    String[] stSplit = sresult.toString().split(",");
    String[] sFdocSplit = stSplit[0].split("=");
    String sFdoc = sFdocSplit[1].replaceAll(",", "");
    sFdoc = sFdoc.trim();
    String[] sIdSplit = stSplit[1].split("=");
    String sentid = sIdSplit[1].replaceAll("}", "");
    sentid = sentid.trim();
    studentResults.clear();
    List employeeResults = unitTestSqlDao.sqlSelect(employeeSql);
    Object eresult = employeeResults.get(0);
    String[] esplit = eresult.toString().split(",");
    String[] eFdocSplit = esplit[0].split("=");
    String eFdoc = eFdocSplit[1].replaceAll(",", "");
    eFdoc = eFdoc.trim();
    String[] eIdSplit = esplit[1].split("=");
    String emEmpid = eIdSplit[1].replaceAll("}", "");
    emEmpid = emEmpid.trim();
    employeeResults.clear();
    List<Person> people;
    people = personService.findPeople(Collections.singletonMap(KIMPropertyConstants.Person.ENTITY_ID, aentid));
    alumni = people.get(0);
    people.clear();
    people = personService.findPeople(Collections.singletonMap(KIMPropertyConstants.Person.ENTITY_ID, sentid));
    student = people.get(0);
    people.clear();
    people = personService.findPeople(Collections.singletonMap(KIMPropertyConstants.Person.EMPLOYEE_ID, emEmpid));
    employee = people.get(0);
    DisbursementPayee alumniPayee = cuDisbursementVoucherPayeeService.getPayeeFromPerson(alumni);
    CuDisbursementPayee cuAlumniPayee = (CuDisbursementPayee) cuDisbursementVoucherPayeeService.getPayeeFromPerson(alumni, "A");
    DisbursementPayee studentPayee = cuDisbursementVoucherPayeeService.getPayeeFromPerson(student);
    CuDisbursementPayee cuStudentPayee = (CuDisbursementPayee) cuDisbursementVoucherPayeeService.getPayeeFromPerson(student, "S");
    DisbursementPayee employeePayee = cuDisbursementVoucherPayeeService.getPayeeFromPerson(employee);
    CuDisbursementPayee cuEmployeePayee = (CuDisbursementPayee) cuDisbursementVoucherPayeeService.getPayeeFromPerson(employee, employeePayee.getPayeeTypeCode());
    isAlumni = cuDisbursementVoucherPayeeService.isAlumni(cuAlumniPayee);
    isStudent = cuDisbursementVoucherPayeeService.isStudent(cuStudentPayee);
    isEmployee = cuDisbursementVoucherPayeeService.isEmployee(cuEmployeePayee);
    // test affliation check by payee
    assertTrue(isAlumni);
    assertTrue(isStudent);
    assertTrue(isEmployee);
    isAlumni = false;
    isStudent = false;
    isEmployee = false;
    // Test getpayeefrom person sets principal name
    assertTrue(student.getPrincipalName().equalsIgnoreCase(cuStudentPayee.getPrincipalName()));
    assertTrue(alumni.getPrincipalName().equalsIgnoreCase(cuAlumniPayee.getPrincipalName()));
    CuDisbursementVoucherDocument dvA = businessObjectService.findBySinglePrimaryKey(CuDisbursementVoucherDocument.class, aFdoc);
    System.out.println("FDOC number  " + aFdoc);
    System.out.println("DV Payee detail " + dvA.getDvPayeeDetail());
    isAlumni = cuDisbursementVoucherPayeeService.isAlumni(dvA.getDvPayeeDetail());
    CuDisbursementVoucherDocument dvS = businessObjectService.findBySinglePrimaryKey(CuDisbursementVoucherDocument.class, sFdoc);
    isStudent = cuDisbursementVoucherPayeeService.isStudent(dvS.getDvPayeeDetail());
    CuDisbursementVoucherDocument dvE = businessObjectService.findBySinglePrimaryKey(CuDisbursementVoucherDocument.class, eFdoc);
    isEmployee = cuDisbursementVoucherPayeeService.isEmployee(dvE.getDvPayeeDetail());
    // test affliation check by dvpayeedetail
    assertTrue(isAlumni);
    assertTrue(isStudent);
    assertTrue(isEmployee);
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) CuDisbursementPayee(edu.cornell.kfs.fp.businessobject.CuDisbursementPayee) List(java.util.List) CuDisbursementPayee(edu.cornell.kfs.fp.businessobject.CuDisbursementPayee) DisbursementPayee(org.kuali.kfs.fp.businessobject.DisbursementPayee) Person(org.kuali.rice.kim.api.identity.Person)

Example 34 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class MockPersonUtil method createMockPerson.

public static Person createMockPerson(UserNameFixture userNameFixture) {
    Person person = EasyMock.createMock(PersonImpl.class);
    EasyMock.expect(person.getPrincipalName()).andStubReturn(userNameFixture.toString());
    EasyMock.expect(person.getPrincipalId()).andStubReturn(userNameFixture.toString());
    EasyMock.expect(person.getCampusCode()).andStubReturn(userNameFixture.toString());
    EasyMock.replay(person);
    return person;
}
Also used : Person(org.kuali.rice.kim.api.identity.Person)

Example 35 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class OrganizationGlobalMaintainableImpl method processAfterPost.

/**
 * Overridden to also add special handling for organization manager, city name and state code.
 * This is necessary to properly update the city and state information based on the zip and
 * country codes, and to properly clear out the manager object when the most recently stored
 * or refreshed principal name is an invalid one.
 *
 * Ideally, this would have been placed in a DerivedValuesSetter implementation; however, such
 * utility classes do not get called when performing a "save" action, so we resort to using
 * this method override instead.
 *
 * @see org.kuali.kfs.sys.document.FinancialSystemGlobalMaintainable#processAfterPost(org.kuali.kfs.kns.document.MaintenanceDocument, java.util.Map)
 */
@Override
public void processAfterPost(MaintenanceDocument document, Map<String, String[]> requestParameters) {
    super.processAfterPost(document, requestParameters);
    OrganizationGlobal orgGlobal = (OrganizationGlobal) getBusinessObject();
    // Forcibly set city name and state code if valid zip code is given, otherwise clear them.
    PostalCodeEbo zipCode = orgGlobal.getPostalZip();
    if (ObjectUtils.isNotNull(zipCode)) {
        // Valid zip-and-country combination is given; update city and state with corresponding values.
        orgGlobal.setOrganizationCityName(zipCode.getCityName());
        orgGlobal.setOrganizationStateCode(zipCode.getStateCode());
    } else {
        // Invalid or blank zip-and-country combination is given; clear city and state.
        orgGlobal.setOrganizationCityName(null);
        orgGlobal.setOrganizationStateCode(null);
    }
    // If the user is attempting to clear out an already-invalid principal name on the form, then clear out the manager object.
    Person orgManager = orgGlobal.getOrganizationManagerUniversal();
    String[] principalName = requestParameters.get("document.newMaintainableObject.organizationManagerUniversal.principalName");
    if (ObjectUtils.isNotNull(orgManager) && StringUtils.isBlank(orgManager.getEntityId()) && StringUtils.isNotBlank(orgManager.getPrincipalName()) && (principalName == null || principalName.length == 0 || StringUtils.isBlank(principalName[0]))) {
        // User is trying to clear out an invalid principal name; clear out principal ID and Person object accordingly.
        orgGlobal.setOrganizationManagerUniversalId(null);
        orgGlobal.setOrganizationManagerUniversal(null);
    }
}
Also used : OrganizationGlobal(edu.cornell.kfs.coa.businessobject.OrganizationGlobal) Person(org.kuali.rice.kim.api.identity.Person) PostalCodeEbo(org.kuali.rice.location.framework.postalcode.PostalCodeEbo)

Aggregations

Person (org.kuali.rice.kim.api.identity.Person)64 ArrayList (java.util.ArrayList)12 PersonService (org.kuali.rice.kim.api.identity.PersonService)12 HashMap (java.util.HashMap)10 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)8 List (java.util.List)6 AdHocRoutePerson (org.kuali.kfs.krad.bo.AdHocRoutePerson)6 Map (java.util.Map)5 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)5 Note (org.kuali.kfs.krad.bo.Note)5 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)5 DateTimeService (org.kuali.rice.core.api.datetime.DateTimeService)5 MessageMap (org.kuali.kfs.krad.util.MessageMap)4 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 Date (java.util.Date)3 ChartOrgHolder (org.kuali.kfs.sys.businessobject.ChartOrgHolder)3 AccountingXmlDocumentNote (edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentNote)2