1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.ole.module.purap.document;
18
19 import org.kuali.ole.module.purap.PurapConstants;
20 import org.kuali.ole.module.purap.PurapConstants.PurchaseOrderStatuses;
21 import org.kuali.ole.module.purap.document.service.PurchaseOrderService;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.rice.kew.api.exception.WorkflowException;
24 import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
25 import org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent;
26 import org.kuali.rice.krad.workflow.service.WorkflowDocumentService;
27
28
29
30
31 public class PurchaseOrderPaymentHoldDocument extends PurchaseOrderDocument {
32 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurchaseOrderPaymentHoldDocument.class);
33
34
35
36
37
38
39 @Override
40 public void customPrepareForSave(KualiDocumentEvent event) {
41
42 }
43
44
45
46
47
48
49 @Override
50 public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
51 super.doRouteStatusChange(statusChangeEvent);
52
53 try {
54
55 if (this.getFinancialSystemDocumentHeader().getWorkflowDocument().isProcessed()) {
56 SpringContext.getBean(PurchaseOrderService.class).setCurrentAndPendingIndicatorsForApprovedPODocuments(this);
57
58
59 updateAndSaveAppDocStatus(PurchaseOrderStatuses.APPDOC_PAYMENT_HOLD);
60 }
61
62 else if (this.getFinancialSystemDocumentHeader().getWorkflowDocument().isDisapproved()) {
63 SpringContext.getBean(PurchaseOrderService.class).setCurrentAndPendingIndicatorsForDisapprovedChangePODocuments(this);
64
65
66 try {
67 String nodeName = SpringContext.getBean(WorkflowDocumentService.class).getCurrentRouteLevelName(this.getFinancialSystemDocumentHeader().getWorkflowDocument());
68 String reqStatus = PurapConstants.PurchaseOrderStatuses.getPurchaseOrderAppDocDisapproveStatuses().get(nodeName);
69 updateAndSaveAppDocStatus(PurapConstants.PurchaseOrderStatuses.getPurchaseOrderAppDocDisapproveStatuses().get(reqStatus));
70 } catch (WorkflowException e) {
71 logAndThrowRuntimeException("Error saving routing data while saving App Doc Status " + getDocumentNumber(), e);
72 }
73
74 }
75
76 else if (this.getFinancialSystemDocumentHeader().getWorkflowDocument().isCanceled()) {
77 SpringContext.getBean(PurchaseOrderService.class).setCurrentAndPendingIndicatorsForCancelledChangePODocuments(this);
78
79 updateAndSaveAppDocStatus(PurapConstants.PurchaseOrderStatuses.APPDOC_CANCELLED);
80 }
81 } catch (WorkflowException e) {
82 logAndThrowRuntimeException("Error saving routing data while saving document with id " + getDocumentNumber(), e);
83 }
84 }
85 }