use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method buildDistributionIncomeExpenseDocument.
/**
* @param diDescription
* @param diExplanation
* @param tripNumber
* @param initiatorNetId
* @return
* @throws Exception
*/
private String buildDistributionIncomeExpenseDocument(String diDescription, String diExplanation, String tripNumber, String initiatorNetId) throws Exception {
try {
if (!isValidDocumentInitiator(initiatorNetId, DISTRIBUTION_INCOME_EXPENSE)) {
throw new RuntimeException("Initiator identified does not have permission to create a DI.");
}
} catch (Exception ex) {
throw new RuntimeException("Initiator identified does not have permission to create a DI.", 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
CuDistributionOfIncomeAndExpenseDocument diDoc = null;
try {
diDoc = (CuDistributionOfIncomeAndExpenseDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DistributionOfIncomeAndExpenseDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (diDoc != null) {
diDoc.getDocumentHeader().setDocumentDescription(diDescription);
diDoc.getDocumentHeader().setExplanation(diExplanation);
diDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
diDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
diDoc.setTripId(tripNumber);
// Persist document
SpringContext.getBean(DocumentService.class).saveDocument(diDoc);
return diDoc.getDocumentNumber();
} else {
return "";
}
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method findPdpStatuses.
@Override
public List<RecurringDisbursementVoucherPDPStatus> findPdpStatuses(RecurringDisbursementVoucherDocument recurringDV) {
List<RecurringDisbursementVoucherPDPStatus> pdpStatuses = new ArrayList<RecurringDisbursementVoucherPDPStatus>();
for (RecurringDisbursementVoucherDetail detail : recurringDV.getRecurringDisbursementVoucherDetails()) {
if (StringUtils.isNotEmpty(detail.getDvDocumentNumber())) {
DisbursementVoucherDocument disbursementVoucherDocument;
try {
disbursementVoucherDocument = (DisbursementVoucherDocument) getDocumentService().getByDocumentHeaderId(detail.getDvDocumentNumber());
} catch (WorkflowException e) {
LOG.error("findPdpStatuses: There was a problem getting DV from the recurring DV detail: " + e);
throw new RuntimeException(e);
}
pdpStatuses.add(buildRecurringDisbursementVoucherPDPStatus(disbursementVoucherDocument));
}
}
Collections.sort(pdpStatuses);
return pdpStatuses;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method saveDisbursementVouchers.
private void saveDisbursementVouchers(List<DisbursementVoucherDocument> dvs, RecurringDisbursementVoucherDocument recurringDV) {
for (DisbursementVoucherDocument dv : dvs) {
try {
dv.getDocumentHeader().setDocumentDescription(recurringDV.getDocumentHeader().getDocumentDescription());
dv.getDocumentHeader().setExplanation(buildDVExplanation(recurringDV));
getDocumentService().saveDocument(dv);
getBusinessObjectService().save(recurringDV.getRecurringDisbursementVoucherDetails());
updateGLPEDatesAndAddRecurringDocumentLinks(dv, recurringDV.getDocumentNumber());
} catch (WorkflowException e) {
;
LOG.error("saveDisbursementVouchers: There was an error trying to save our route the created Disbursement Voucher documents: ", e);
throw new RuntimeException(e);
}
}
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method noteChangeOnRecurringDV.
private void noteChangeOnRecurringDV(RecurringDisbursementVoucherDocument recurringDV, String noteText, Set<String> setOfStrings) {
if (!setOfStrings.isEmpty()) {
Note note = buildNoteBase();
note.setNoteText(noteText + StringUtils.join(setOfStrings, ", "));
;
recurringDV.addNote(note);
try {
getDocumentService().saveDocument(recurringDV);
} catch (WorkflowException e) {
throw new RuntimeException("noteChangeOnRecurringDV() Unable to save note.", e);
}
}
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method cancelDisbursementVouchersFinalizedNotExtracted.
@Override
public Set<String> cancelDisbursementVouchersFinalizedNotExtracted(RecurringDisbursementVoucherDocument recurringDisbursementVoucherDocument, String cancelMessage) {
Set<String> canceledDVs = new HashSet<String>();
for (RecurringDisbursementVoucherDetail detail : recurringDisbursementVoucherDocument.getRecurringDisbursementVoucherDetails()) {
String dvDocumentNumber = detail.getDvDocumentNumber();
if (!isDVCancelable(dvDocumentNumber)) {
CuDisbursementVoucherDocument dv;
try {
dv = (CuDisbursementVoucherDocument) getDocumentService().getByDocumentHeaderId(detail.getDvDocumentNumber());
if (isDvCancelableFromApprovedNotExtracted(dv)) {
Date cancelDate = new Date(Calendar.getInstance().getTimeInMillis());
dv.setCancelDate(cancelDate);
CuDisbursementVoucherDocument cancledDV = (CuDisbursementVoucherDocument) getDocumentService().saveDocument(dv);
getCuDisbursementVoucherExtractionHelperService().getPaymentSourceHelperService().handleEntryCancellation(cancledDV, getCuDisbursementVoucherExtractionHelperService());
canceledDVs.add(cancledDV.getDocumentNumber());
}
} catch (WorkflowException e) {
throw new RuntimeException(e);
}
}
}
noteChangeOnRecurringDV(recurringDisbursementVoucherDocument, "The following disbursement vouchers were canceled after it was approved but before payments were created: ", canceledDVs);
return canceledDVs;
}
Aggregations