Search in sources :

Example 16 with Document

use of org.kuali.kfs.krad.document.Document in project cu-kfs by CU-CommunityApps.

the class AutoCancelBatchDaoJdbc method cancelDocuments.

/**
 * @see AutoCancelBatchDao#cancelDocuments()
 */
@Override
public void cancelDocuments() throws Exception {
    final String daysToAutoCancel = parameterService.getParameterValueAsString(AutoCancelBatchStep.class, CUKFSParameterKeyConstants.DAYS_TO_AUTO_CANCEL_PARAMETER);
    if (StringUtils.isNotBlank(daysToAutoCancel)) {
        Map<String, String> cancelIds = findSavedDocumentIds(Integer.parseInt(daysToAutoCancel));
        Set<String> cancelDocumentIds = cancelIds.keySet();
        int canceledDocumentCount = 0;
        for (String docId : cancelDocumentIds) {
            String docTypeId = cancelIds.get(docId);
            if (canAutoCancelDocType(docTypeId)) {
                LOG.info("Retrieving document : " + docId.trim());
                Document document = documentService.getByDocumentHeaderId(docId.trim());
                try {
                    if (!ObjectUtils.isNull(document)) {
                        LOG.info("Document Number to cancel : " + document.getDocumentNumber());
                        canceledDocumentCount++;
                        documentService.prepareWorkflowDocument(document);
                        workflowDocumentService.superUserCancel(document.getDocumentHeader().getWorkflowDocument(), "AutoCancelBatchStep: Older Than " + daysToAutoCancel + " Days");
                        sessionDocumentService.addDocumentToUserSession(GlobalVariables.getUserSession(), document.getDocumentHeader().getWorkflowDocument());
                    }
                } catch (WorkflowException e) {
                    LOG.error("AutoCancelBatchStep Encountered WorkflowException " + document.getDocumentNumber(), e);
                }
            }
        }
        LOG.info("Total number of docs canceled : " + canceledDocumentCount);
    } else {
        LOG.info("ERROR: DAYS_TO_CANCEL parameter is empty or missing");
    }
}
Also used : WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) Document(org.kuali.kfs.krad.document.Document)

Example 17 with Document

use of org.kuali.kfs.krad.document.Document in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountExtractServiceImplTest method createMockDocumentService.

@SuppressWarnings("unchecked")
private DocumentService createMockDocumentService() throws Exception {
    DocumentService mockDocumentService = EasyMock.createMock(DocumentServiceImpl.class);
    EasyMock.expect(mockDocumentService.getNewDocument(CUPdpConstants.PAYEE_ACH_ACCOUNT_EXTRACT_MAINT_DOC_TYPE)).andStubAnswer(new IAnswer<Document>() {

        @Override
        public Document answer() throws Throwable {
            return createMockPAATDocument();
        }
    });
    EasyMock.expect(mockDocumentService.routeDocument(EasyMock.isA(MaintenanceDocument.class), EasyMock.or(EasyMock.isA(String.class), EasyMock.isNull(String.class)), EasyMock.or(EasyMock.isA(List.class), EasyMock.isNull(List.class)))).andStubAnswer(new IAnswer<Document>() {

        @Override
        public Document answer() throws Throwable {
            return (Document) EasyMock.getCurrentArguments()[0];
        }
    });
    EasyMock.replay(mockDocumentService);
    return mockDocumentService;
}
Also used : MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) Document(org.kuali.kfs.krad.document.Document) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Aggregations

Document (org.kuali.kfs.krad.document.Document)17 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)5 DocumentService (org.kuali.kfs.krad.service.DocumentService)5 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)5 Note (org.kuali.kfs.krad.bo.Note)4 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)3 VendorCreditMemoDocument (org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)3 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)3 HashMap (java.util.HashMap)2 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)2 Attachment (org.kuali.kfs.krad.bo.Attachment)2 DocumentHeader (org.kuali.kfs.krad.bo.DocumentHeader)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 Person (org.kuali.rice.kim.api.identity.Person)2 AccountExtendedAttribute (edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute)1 AppropriationAccount (edu.cornell.kfs.coa.businessobject.AppropriationAccount)1 SubFundProgram (edu.cornell.kfs.coa.businessobject.SubFundProgram)1 AccountReversionTrickleDownInactivationService (edu.cornell.kfs.coa.service.AccountReversionTrickleDownInactivationService)1 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)1 CuDistributionOfIncomeAndExpenseDocument (edu.cornell.kfs.fp.document.CuDistributionOfIncomeAndExpenseDocument)1