1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.document;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator;
20 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
21 import org.kuali.rice.kew.api.WorkflowDocument;
22 import org.kuali.rice.krad.util.GlobalVariables;
23 import org.kuali.rice.krad.util.KRADConstants;
24
25 import java.io.Serializable;
26
27
28
29
30 public class DocumentPresentationControllerBase implements DocumentPresentationController, Serializable {
31 private static final long serialVersionUID = -9181864754090276024L;
32
33 private static transient ParameterService parameterService;
34
35 public boolean canInitiate(String documentTypeName) {
36 return true;
37 }
38
39 public boolean canEdit(Document document) {
40 boolean canEdit = false;
41 WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
42 if (workflowDocument.isInitiated()
43 || workflowDocument.isSaved()
44 || workflowDocument.isEnroute()
45 || workflowDocument.isException()) {
46 canEdit = true;
47 }
48
49 return canEdit;
50 }
51
52 public boolean canAnnotate(Document document) {
53 return canEdit(document);
54 }
55
56 public boolean canReload(Document document) {
57 WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
58 return (canEdit(document) && !workflowDocument.isInitiated());
59
60 }
61
62 public boolean canClose(Document document) {
63 return true;
64 }
65
66 public boolean canSave(Document document) {
67 return canEdit(document);
68 }
69
70 public boolean canRoute(Document document) {
71 boolean canRoute = false;
72 WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
73 if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
74 canRoute = true;
75 }
76 return canRoute;
77 }
78
79 public boolean canCancel(Document document) {
80 return canEdit(document);
81 }
82
83 public boolean canCopy(Document document) {
84 boolean canCopy = false;
85 if (document.getAllowsCopy()) {
86 canCopy = true;
87 }
88 return canCopy;
89 }
90
91 public boolean canPerformRouteReport(Document document) {
92 return getParameterService().getParameterValueAsBoolean(KRADConstants.KNS_NAMESPACE,
93 KRADConstants.DetailTypes.DOCUMENT_DETAIL_TYPE,
94 KRADConstants.SystemGroupParameterNames.DEFAULT_CAN_PERFORM_ROUTE_REPORT_IND);
95 }
96
97 public boolean canAddAdhocRequests(Document document) {
98 return true;
99 }
100
101 public boolean canBlanketApprove(Document document) {
102
103
104 Boolean allowBlanketApproveNoRequest = getParameterService().getParameterValueAsBoolean(
105 KRADConstants.KNS_NAMESPACE, KRADConstants.DetailTypes.DOCUMENT_DETAIL_TYPE,
106 KRADConstants.SystemGroupParameterNames.ALLOW_ENROUTE_BLANKET_APPROVE_WITHOUT_APPROVAL_REQUEST_IND);
107 if (allowBlanketApproveNoRequest != null && allowBlanketApproveNoRequest.booleanValue()) {
108 return canEdit(document);
109 }
110
111
112
113 WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
114 if (canRoute(document) && StringUtils.equals(workflowDocument.getInitiatorPrincipalId(),
115 GlobalVariables.getUserSession().getPrincipalId())) {
116 return true;
117 }
118
119
120 if (workflowDocument.isApprovalRequested()) {
121 return true;
122 }
123
124 return false;
125 }
126
127 public boolean canApprove(Document document) {
128 return true;
129 }
130
131 public boolean canDisapprove(Document document) {
132
133 return canApprove(document);
134 }
135
136 public boolean canSendAdhocRequests(Document document) {
137 WorkflowDocument kualiWorkflowDocument = document.getDocumentHeader().getWorkflowDocument();
138 return !(kualiWorkflowDocument.isInitiated() || kualiWorkflowDocument.isSaved());
139 }
140
141 public boolean canSendNoteFyi(Document document) {
142 return true;
143 }
144
145 public boolean canEditDocumentOverview(Document document) {
146 WorkflowDocument kualiWorkflowDocument = document.getDocumentHeader().getWorkflowDocument();
147 return (kualiWorkflowDocument.isInitiated() || kualiWorkflowDocument.isSaved());
148 }
149
150 public boolean canFyi(Document document) {
151 return true;
152 }
153
154 public boolean canAcknowledge(Document document) {
155 return true;
156 }
157
158 protected ParameterService getParameterService() {
159 if (parameterService == null) {
160 parameterService = CoreFrameworkServiceLocator.getParameterService();
161 }
162 return parameterService;
163 }
164 }