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