use of org.kuali.rice.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method buildDisbursementVoucher.
/**
* @param dvDescription
* @param dvExplanation
* @param tripNumber
* @param travelerNetId
* @param initiatorNetId
* @param totalAmount
* @param checkStubText
* @return
* @throws Exception
*/
private String buildDisbursementVoucher(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
try {
if (!isValidDocumentInitiator(initiatorNetId, DISBURSEMENT_VOUCHER)) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.");
}
} catch (Exception ex) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.", ex);
}
// create and route doc as system user
GlobalVariables.setUserSession(new UserSession(initiatorNetId));
MessageMap documentErrorMap = new MessageMap();
GlobalVariables.setMessageMap(documentErrorMap);
// Create document with description provided
CuDisbursementVoucherDocument dvDoc = null;
try {
dvDoc = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (dvDoc != null) {
dvDoc.getDocumentHeader().setDocumentDescription(dvDescription);
dvDoc.getDocumentHeader().setExplanation(dvExplanation);
dvDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
dvDoc.initiateDocument();
// Set vendor to traveler using netID provided
Person traveler = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(travelerNetId);
for (EntityAffiliationContract entityAffiliation : ((PersonImpl) traveler).getAffiliations()) {
if (entityAffiliation.isDefaultValue()) {
if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
dvDoc.templateStudent(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
dvDoc.templateAlumni(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
dvDoc.templateEmployee(traveler);
}
}
}
dvDoc.setPayeeAssigned(true);
dvDoc.getDvPayeeDetail().setDisbVchrPaymentReasonCode("J");
dvDoc.setDisbVchrCheckTotalAmount(new KualiDecimal(totalAmount));
dvDoc.setDisbVchrPaymentMethodCode("P");
dvDoc.setDisbVchrCheckStubText(checkStubText);
dvDoc.setTripId(tripNumber);
dvDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
// Persist document
SpringContext.getBean(DocumentService.class).saveDocument(dvDoc);
return dvDoc.getDocumentNumber();
} else {
return "";
}
}
use of org.kuali.rice.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.
the class CuBatchInputFileServiceImplTest method testIllegalArguments.
/*
* test several potential IllegalArgumentException
*/
public void testIllegalArguments() {
runTestIllegalArgument();
user = new PersonImpl();
runTestIllegalArgument();
batchInputFileType = new VendorBatchCsvInputFileType();
runTestIllegalArgument();
fileContents = new InputStream() {
@Override
public int read() throws IOException {
return 0;
}
};
// Only allow alphanumeric
fileUserIdentifier = " 123.abc";
runTestIllegalArgument();
}
use of org.kuali.rice.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.
the class MockDocumentUtils method buildMockAdHocRoutePerson.
public static AdHocRoutePerson buildMockAdHocRoutePerson() {
TestAdHocRoutePerson adHocPerson = EasyMock.partialMockBuilder(TestAdHocRoutePerson.class).createNiceMock();
EasyMock.replay(adHocPerson);
adHocPerson.setType(AdHocRouteRecipient.PERSON_TYPE);
adHocPerson.setPerson(new PersonImpl());
return adHocPerson;
}
use of org.kuali.rice.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.
the class CuDisbursementPayeeLookupableHelperServiceImpl method getPersonAsPayees.
@Override
protected List<DisbursementPayee> getPersonAsPayees(Map<String, String> fieldValues) {
List<DisbursementPayee> payeeList = new ArrayList<DisbursementPayee>();
Map<String, String> fieldsForLookup = this.getPersonFieldValues(fieldValues);
List<Person> persons = SpringContext.getBean(PersonService.class).findPeople(fieldsForLookup);
boolean warningExists = false;
for (Person personDetail : persons) {
for (EntityAffiliationContract entityAffiliation : ((PersonImpl) personDetail).getAffiliations()) {
if (entityAffiliation.isDefaultValue()) {
if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
CuDisbursementPayee payee = getPayeeFromPerson(personDetail, fieldValues, CuDisbursementVoucherConstants.DV_PAYEE_TYPE_STUDENT);
payeeList.add(payee);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
CuDisbursementPayee payee = getPayeeFromPerson(personDetail, fieldValues, CuDisbursementVoucherConstants.DV_PAYEE_TYPE_ALUMNI);
payeeList.add(payee);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
if (StringUtils.isNotBlank(personDetail.getEmployeeStatusCode()) && (personDetail.getEmployeeStatusCode().equals(ACTIVE)) || personDetail.getEmployeeStatusCode().equals(RETIRED)) {
CuDisbursementPayee payee = getPayeeFromPerson(personDetail, fieldValues, DisbursementVoucherConstants.DV_PAYEE_TYPE_EMPLOYEE);
payeeList.add(payee);
} else {
if (GlobalVariables.getMessageMap().containsMessageKey(CUKFSKeyConstants.WARNING_DV_PAYEE_MUST_BE_ACTIVE)) {
warningExists = true;
break;
}
}
if (!warningExists) {
GlobalVariables.getMessageMap().putWarningWithoutFullErrorPath(KFSPropertyConstants.PRINCIPAL_ID, CUKFSKeyConstants.WARNING_DV_PAYEE_MUST_BE_ACTIVE);
}
}
break;
}
}
}
return payeeList;
}
use of org.kuali.rice.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.
the class CuBatchInputFileServiceImplTest method testSave.
/*
* This is the core test of CU modification
* If the input file type is not CuBatchInputFileType then we create the
* done file. If it is of type CuBatchInputFileType then we also must call the
* isDoneFileRequired function.
* 1. PCDO is used to test the original save is fine.
* 2. AccountReversion is used to test not to create 'done' file
* This is based on BatchInputFileTypeServiceTest
*/
public final void testSave() throws Exception {
// GlobalVariables.getUserSession().getPerson();
user = new PersonImpl();
String savedFileName = batchInputFileService.save(user, pcdoBatchInputFileType, testFileIdentifier, validPcdoFileContents, new ArrayList());
File expectedFile = new File(savedFileName);
createdTestFiles.add(expectedFile);
// Make sure CU mods does not affect the inputfiletype is not an instance of CuBatchInputFileType
assertTrue("uploaded pcdo file not found", expectedFile.exists());
assertTrue("uploaded pcdo file is empty", expectedFile.length() > 0);
checkForDoneFile(expectedFile, true);
// remove file so we can test collector upload
expectedFile.delete();
// Make sure CU mods is correct; not to create done file
savedFileName = batchInputFileService.save(user, accountReversionInputFileType, testFileIdentifier, validAccountReversionFileContents, null);
expectedFile = new File(savedFileName);
createdTestFiles.add(expectedFile);
assertTrue("uploaded AccountReversion file not found", expectedFile.exists());
assertTrue("uploaded AccountReversion file is empty", expectedFile.length() > 0);
checkForDoneFile(expectedFile, false);
}
Aggregations