use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CUFinancialSystemDocumentServiceImpl method checkAccountingLinesForChanges.
/**
* new == null, old == null : no change; line deleted previously.
* new == blah, old == blah : no change
* new == blah, old == meh : changed
* new == null, old == blah : deleted
* new == blah, old == null : added
* @throws WorkflowException
*
* @see org.kuali.kfs.sys.document.service.FinancialSystemDocumentService#checkAccountingLinesForChanges(org.kuali.kfs.sys.document.AccountingDocument)
*/
public void checkAccountingLinesForChanges(AccountingDocument accountingDocument) {
DocumentService docService = SpringContext.getBean(DocumentService.class);
AccountingDocument savedDoc = null;
try {
savedDoc = (AccountingDocument) docService.getByDocumentHeaderId(accountingDocument.getDocumentNumber());
} catch (WorkflowException we) {
LOG.error("Unable to retrieve document number " + accountingDocument.getDocumentNumber() + " to evaluate accounting line changes");
}
if (savedDoc == null) {
return;
}
if (!accountingDocument.getSourceAccountingLines().isEmpty()) {
Map<Integer, AccountingLine> newSourceLines = buildAccountingLineMap(accountingDocument.getSourceAccountingLines());
Map<Integer, AccountingLine> savedSourceLines = buildAccountingLineMap(savedDoc.getSourceAccountingLines());
if (newSourceLines.isEmpty())
return;
int maxSourceKey = findMinOrMaxKeyValue(newSourceLines, savedSourceLines, false);
int minSourceKey = findMinOrMaxKeyValue(newSourceLines, savedSourceLines, true);
for (int i = minSourceKey; i < maxSourceKey + 1; i++) {
AccountingLine newLine = newSourceLines.get(i);
AccountingLine oldLine = savedSourceLines.get(i);
if (!compareTo(newLine, oldLine)) {
String diff = buildLineChangedNoteText(newLine, oldLine);
if (StringUtils.isNotBlank(diff)) {
writeNote(accountingDocument, diff);
}
}
}
}
if (!accountingDocument.getTargetAccountingLines().isEmpty()) {
Map<Integer, AccountingLine> newTargetLines = buildAccountingLineMap(accountingDocument.getTargetAccountingLines());
Map<Integer, AccountingLine> savedTargetLines = buildAccountingLineMap(savedDoc.getTargetAccountingLines());
if (newTargetLines.isEmpty())
return;
int maxTargetKey = findMinOrMaxKeyValue(newTargetLines, savedTargetLines, false);
int minTargetKey = findMinOrMaxKeyValue(newTargetLines, savedTargetLines, true);
for (int i = minTargetKey; i < maxTargetKey + 1; i++) {
AccountingLine newLine = newTargetLines.get(i);
AccountingLine oldLine = savedTargetLines.get(i);
if (!compareTo(newLine, oldLine)) {
String diff = buildLineChangedNoteText(newLine, oldLine);
if (StringUtils.isNotBlank(diff)) {
writeNote(accountingDocument, diff);
}
}
}
}
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class PaymentSourceExtractionServiceImpl method getListByDocumentStatusCodeCampus.
/**
* This method retrieves a list of disbursement voucher documents that are in the status provided for the campus code given.
*
* @param statusCode The status of the disbursement vouchers to be retrieved.
* @param campusCode The campus code that the disbursement vouchers will be associated with.
* @param immediatesOnly only retrieve Disbursement Vouchers marked for immediate payment
* @return A collection of disbursement voucher objects that meet the search criteria given.
*/
protected Collection<DisbursementVoucherDocument> getListByDocumentStatusCodeCampus(String statusCode, String campusCode, boolean immediatesOnly) {
LOG.info("getListByDocumentStatusCodeCampus(statusCode=" + statusCode + ", campusCode=" + campusCode + ", immediatesOnly=" + immediatesOnly + ") started");
Collection<DisbursementVoucherDocument> list = new ArrayList<DisbursementVoucherDocument>();
try {
Collection<DisbursementVoucherDocument> docs = SpringContext.getBean(FinancialSystemDocumentService.class).findByDocumentHeaderStatusCode(DisbursementVoucherDocument.class, statusCode);
for (DisbursementVoucherDocument element : docs) {
String dvdCampusCode = element.getCampusCode();
if (dvdCampusCode.equals(campusCode) && KFSConstants.PaymentSourceConstants.PAYMENT_METHOD_CHECK.equals(element.getDisbVchrPaymentMethodCode())) {
if ((immediatesOnly && element.isImmediatePaymentIndicator()) || !immediatesOnly) {
list.add(element);
}
}
}
} catch (WorkflowException we) {
LOG.error("Could not load Disbursement Voucher Documents with status code = " + statusCode + ": " + we);
throw new RuntimeException(we);
}
return list;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class FinancialSystemSearchableAttribute method extractDocumentAttributes.
@Override
public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, DocumentWithContent documentWithContent) {
if (LOG.isDebugEnabled()) {
LOG.debug("extractDocumentAttributes( " + extensionDefinition + ", " + documentWithContent + " )");
}
List<DocumentAttribute> searchAttrValues = super.extractDocumentAttributes(extensionDefinition, documentWithContent);
String docId = documentWithContent.getDocument().getDocumentId();
DocumentService docService = SpringContext.getBean(DocumentService.class);
Document doc = null;
try {
doc = docService.getByDocumentHeaderIdSessionless(docId);
} catch (WorkflowException we) {
}
if (doc != null) {
if (doc instanceof AmountTotaling && ((AmountTotaling) doc).getTotalDollarAmount() != null) {
DocumentAttributeDecimal.Builder searchableAttributeValue = DocumentAttributeDecimal.Builder.create(KFSPropertyConstants.FINANCIAL_DOCUMENT_TOTAL_AMOUNT);
searchableAttributeValue.setValue(((AmountTotaling) doc).getTotalDollarAmount().bigDecimalValue());
searchAttrValues.add(searchableAttributeValue.build());
}
if (doc instanceof AccountingDocument) {
AccountingDocument accountingDoc = (AccountingDocument) doc;
searchAttrValues.addAll(harvestAccountingDocumentSearchableAttributes(accountingDoc));
}
boolean indexedLedgerDoc = false;
if (doc instanceof LaborLedgerPostingDocumentForSearching) {
LaborLedgerPostingDocumentForSearching LLPostingDoc = (LaborLedgerPostingDocumentForSearching) doc;
searchAttrValues.addAll(harvestLLPDocumentSearchableAttributes(LLPostingDoc));
indexedLedgerDoc = true;
}
if (doc instanceof GeneralLedgerPostingDocument && !indexedLedgerDoc) {
GeneralLedgerPostingDocument GLPostingDoc = (GeneralLedgerPostingDocument) doc;
searchAttrValues.addAll(harvestGLPDocumentSearchableAttributes(GLPostingDoc));
}
DocumentHeader docHeader = doc.getDocumentHeader();
if (ObjectUtils.isNotNull(docHeader) && ObjectUtils.isNotNull(docHeader.getWorkflowDocument()) && CUKFSConstants.GACC_DOCUMENT_TYPE.equalsIgnoreCase(docHeader.getWorkflowDocument().getDocumentTypeName())) {
for (AccountGlobalDetail detail : ((AccountGlobal) ((AccountGlobalMaintainableImpl) ((FinancialSystemMaintenanceDocument) doc).getNewMaintainableObject()).getBusinessObject()).getAccountGlobalDetails()) {
if (!StringUtils.isBlank(detail.getAccountNumber())) {
DocumentAttributeString.Builder searchableAttributeValue = DocumentAttributeString.Builder.create(KFSPropertyConstants.ACCOUNT_NUMBER);
searchableAttributeValue.setValue(detail.getAccountNumber());
searchAttrValues.add(searchableAttributeValue.build());
}
}
}
}
return searchAttrValues;
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CheckReconciliationMaintainableImpl method doRouteStatusChange.
/**
* @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#doRouteStatusChange(org.kuali.kfs.kns.bo.DocumentHeader)
*/
public void doRouteStatusChange(DocumentHeader documentHeader) {
WorkflowDocument workflowDocument = documentHeader.getWorkflowDocument();
if (workflowDocument.isProcessed() && !KFSConstants.MAINTENANCE_NEW_ACTION.equalsIgnoreCase(getMaintenanceAction())) {
DocumentService documentService = SpringContext.getBean(DocumentService.class);
MaintenanceDocument document;
try {
document = (MaintenanceDocument) documentService.getByDocumentHeaderId(documentHeader.getDocumentNumber());
CheckReconciliation oldCr = (CheckReconciliation) document.getOldMaintainableObject().getBusinessObject();
CheckReconciliation newCr = (CheckReconciliation) document.getNewMaintainableObject().getBusinessObject();
if (ObjectUtils.isNotNull(oldCr) && !oldCr.getStatus().equalsIgnoreCase(newCr.getStatus())) {
Date currentDate = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
newCr.setStatusChangeDate(currentDate);
// KFSUPGRADE-377
if (CRConstants.CANCELLED.equalsIgnoreCase(newCr.getStatus())) {
newCr.setCancelDocHdrId(documentHeader.getDocumentNumber());
}
}
} catch (WorkflowException e) {
throw new RuntimeCacheException(e);
}
}
}
use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.
the class CuPurapServiceImpl method saveRoutingDataForRelatedDocuments.
// ==== CU Customization (KFSPTS-1656): Save IWantDocument routing data. ====
@Override
public void saveRoutingDataForRelatedDocuments(Integer accountsPayablePurchasingDocumentLinkIdentifier) {
super.saveRoutingDataForRelatedDocuments(accountsPayablePurchasingDocumentLinkIdentifier);
try {
// Save IWNT routing data.
@SuppressWarnings("unchecked") List<IWantView> iWantViews = getRelatedViews(IWantView.class, accountsPayablePurchasingDocumentLinkIdentifier);
for (Iterator<IWantView> iterator = iWantViews.iterator(); iterator.hasNext(); ) {
IWantView view = (IWantView) iterator.next();
Document doc = documentService.getByDocumentHeaderId(view.getDocumentNumber());
doc.getDocumentHeader().getWorkflowDocument().saveDocumentData();
}
} catch (WorkflowException e) {
throw new InfrastructureException("unable to save routing data for related docs", e);
}
}
Aggregations