1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.authorization;
17
18 import org.kuali.ole.module.purap.PurapAuthorizationConstants.PurchaseOrderEditMode;
19 import org.kuali.ole.module.purap.PurapConstants.PurchaseOrderStatuses;
20 import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
21 import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
22 import org.kuali.ole.module.purap.document.service.PurapService;
23 import org.kuali.ole.sys.context.SpringContext;
24 import org.kuali.rice.kew.api.WorkflowDocument;
25 import org.kuali.rice.krad.document.Document;
26
27 import java.util.Set;
28
29 public class PurchaseOrderAmendmentDocumentPresentationController extends PurchaseOrderDocumentPresentationController {
30
31 @Override
32 public boolean canEdit(Document document) {
33 PurchaseOrderDocument poDocument = (PurchaseOrderDocument) document;
34
35 if (PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(poDocument.getApplicationDocumentStatus())) {
36 WorkflowDocument workflowDocument = poDocument.getFinancialSystemDocumentHeader().getWorkflowDocument();
37
38 if (!workflowDocument.isInitiated() && !workflowDocument.isSaved()) {
39 return false;
40 }
41 }
42 return super.canEdit(document);
43 }
44
45 @Override
46 public Set<String> getEditModes(Document document) {
47 Set<String> editModes = super.getEditModes(document);
48 PurchaseOrderDocument poDocument = (PurchaseOrderDocument) document;
49
50 if (PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(poDocument.getApplicationDocumentStatus())) {
51 WorkflowDocument workflowDocument = poDocument.getFinancialSystemDocumentHeader().getWorkflowDocument();
52
53 if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
54 editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
55 }
56 }
57 if (PurchaseOrderStatuses.APPDOC_AWAIT_NEW_UNORDERED_ITEM_REVIEW.equals(poDocument.getApplicationDocumentStatus())) {
58 editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
59 }
60
61 if (SpringContext.getBean(PurapService.class).isDocumentStoppedInRouteNode((PurchasingAccountsPayableDocument) document, "New Unordered Items")) {
62 editModes.add(PurchaseOrderEditMode.UNORDERED_ITEM_ACCOUNT_ENTRY);
63 }
64
65 return editModes;
66 }
67
68 @Override
69 public boolean canReload(Document document) {
70
71 PurchaseOrderDocument poDocument = (PurchaseOrderDocument) document;
72 WorkflowDocument workflowDocument = poDocument.getFinancialSystemDocumentHeader().getWorkflowDocument();
73 return (workflowDocument.isSaved() || workflowDocument.isEnroute());
74 }
75 }