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());
}
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());
}
}
}
}
}
}
}
}
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);
}
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;
}
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);
}
}
Aggregations