1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.document.authorization; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.core.framework.parameter.ParameterService; |
20 | |
import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator; |
21 | |
import org.kuali.rice.kns.document.Document; |
22 | |
import org.kuali.rice.kns.util.GlobalVariables; |
23 | |
import org.kuali.rice.kns.util.KNSConstants; |
24 | |
import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument; |
25 | |
|
26 | |
import java.util.HashSet; |
27 | |
import java.util.Set; |
28 | |
|
29 | |
|
30 | 0 | public class DocumentPresentationControllerBase implements DocumentPresentationController { |
31 | |
|
32 | |
|
33 | |
private static transient ParameterService parameterService; |
34 | |
|
35 | |
public boolean canInitiate(String documentTypeName) { |
36 | 0 | return true; |
37 | |
} |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
protected boolean canEdit(Document document){ |
45 | 0 | boolean canEdit = false; |
46 | 0 | KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
47 | 0 | if (workflowDocument.stateIsInitiated() || workflowDocument.stateIsSaved() || workflowDocument.stateIsEnroute() || workflowDocument.stateIsException()) { |
48 | 0 | canEdit = true; |
49 | |
} |
50 | |
|
51 | 0 | return canEdit; |
52 | |
} |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
protected boolean canAnnotate(Document document){ |
61 | 0 | return canEdit(document); |
62 | |
} |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
protected boolean canReload(Document document){ |
71 | 0 | KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
72 | 0 | return (canEdit(document) && !workflowDocument.stateIsInitiated()) ; |
73 | |
|
74 | |
} |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
protected boolean canClose(Document document){ |
83 | 0 | return true; |
84 | |
} |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
protected boolean canSave(Document document){ |
94 | 0 | return canEdit(document); |
95 | |
} |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
protected boolean canRoute(Document document){ |
104 | 0 | boolean canRoute = false; |
105 | 0 | KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
106 | 0 | if (workflowDocument.stateIsInitiated() || workflowDocument.stateIsSaved()){ |
107 | 0 | canRoute = true; |
108 | |
} |
109 | 0 | return canRoute; |
110 | |
} |
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
protected boolean canCancel(Document document){ |
119 | 0 | return canEdit(document); |
120 | |
} |
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
protected boolean canCopy(Document document){ |
129 | 0 | boolean canCopy = false; |
130 | 0 | if(document.getAllowsCopy()){ |
131 | 0 | canCopy = true; |
132 | |
} |
133 | 0 | return canCopy; |
134 | |
} |
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
protected boolean canPerformRouteReport(Document document){ |
144 | 0 | return getParameterService().getParameterValueAsBoolean(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, KNSConstants.SystemGroupParameterNames.DEFAULT_CAN_PERFORM_ROUTE_REPORT_IND); |
145 | |
} |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
protected boolean canAddAdhocRequests(Document document){ |
154 | 0 | return true; |
155 | |
} |
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
protected boolean canBlanketApprove(Document document){ |
165 | |
|
166 | |
|
167 | 0 | Boolean allowBlanketApproveNoRequest = getParameterService().getParameterValueAsBoolean(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, KNSConstants.SystemGroupParameterNames.ALLOW_ENROUTE_BLANKET_APPROVE_WITHOUT_APPROVAL_REQUEST_IND); |
168 | 0 | if ( allowBlanketApproveNoRequest != null && allowBlanketApproveNoRequest.booleanValue() ) { |
169 | 0 | return canEdit(document); |
170 | |
} |
171 | |
|
172 | |
|
173 | 0 | KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
174 | 0 | if ( canRoute(document) && StringUtils.equals( workflowDocument.getInitiatorPrincipalId(), GlobalVariables.getUserSession().getPrincipalId() ) ) { |
175 | 0 | return true; |
176 | |
} |
177 | |
|
178 | 0 | if ( workflowDocument.isApprovalRequested() ) { |
179 | 0 | return true; |
180 | |
} |
181 | |
|
182 | 0 | return false; |
183 | |
} |
184 | |
|
185 | |
protected boolean canApprove(Document document) { |
186 | 0 | return true; |
187 | |
} |
188 | |
|
189 | |
protected boolean canDisapprove(Document document) { |
190 | |
|
191 | 0 | return canApprove(document); |
192 | |
} |
193 | |
|
194 | |
protected boolean canSendAdhocRequests(Document document) { |
195 | 0 | KualiWorkflowDocument kualiWorkflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
196 | 0 | return !(kualiWorkflowDocument.stateIsInitiated() || kualiWorkflowDocument.stateIsSaved()); |
197 | |
} |
198 | |
|
199 | |
protected boolean canSendNoteFyi(Document document) { |
200 | 0 | return true; |
201 | |
} |
202 | |
|
203 | |
protected boolean canEditDocumentOverview(Document document){ |
204 | 0 | KualiWorkflowDocument kualiWorkflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
205 | 0 | return (kualiWorkflowDocument.stateIsInitiated() || kualiWorkflowDocument.stateIsSaved()); |
206 | |
} |
207 | |
|
208 | |
protected boolean canFyi(Document document) { |
209 | 0 | return true; |
210 | |
} |
211 | |
|
212 | |
protected boolean canAcknowledge(Document document) { |
213 | 0 | return true; |
214 | |
} |
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
public Set<String> getDocumentActions(Document document){ |
220 | 0 | Set<String> documentActions = new HashSet<String>(); |
221 | 0 | if (canEdit(document)){ |
222 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_EDIT); |
223 | |
} |
224 | |
|
225 | 0 | if(canAnnotate(document)){ |
226 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_ANNOTATE); |
227 | |
} |
228 | |
|
229 | 0 | if(canClose(document)){ |
230 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_CLOSE); |
231 | |
} |
232 | |
|
233 | 0 | if(canSave(document)){ |
234 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_SAVE); |
235 | |
} |
236 | 0 | if(canRoute(document)){ |
237 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_ROUTE); |
238 | |
} |
239 | |
|
240 | 0 | if(canCancel(document)){ |
241 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_CANCEL); |
242 | |
} |
243 | |
|
244 | 0 | if(canReload(document)){ |
245 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_RELOAD); |
246 | |
} |
247 | 0 | if(canCopy(document)){ |
248 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_COPY); |
249 | |
} |
250 | 0 | if(canPerformRouteReport(document)){ |
251 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_PERFORM_ROUTE_REPORT); |
252 | |
} |
253 | |
|
254 | 0 | if(canAddAdhocRequests(document)){ |
255 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_ADD_ADHOC_REQUESTS); |
256 | |
} |
257 | |
|
258 | 0 | if(canBlanketApprove(document)){ |
259 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_BLANKET_APPROVE); |
260 | |
} |
261 | 0 | if (canApprove(document)) { |
262 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_APPROVE); |
263 | |
} |
264 | 0 | if (canDisapprove(document)) { |
265 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_DISAPPROVE); |
266 | |
} |
267 | 0 | if (canSendAdhocRequests(document)) { |
268 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_SEND_ADHOC_REQUESTS); |
269 | |
} |
270 | 0 | if(canSendNoteFyi(document)){ |
271 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_SEND_NOTE_FYI); |
272 | |
} |
273 | 0 | if(this.canEditDocumentOverview(document)){ |
274 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_EDIT__DOCUMENT_OVERVIEW); |
275 | |
} |
276 | 0 | if (canFyi(document)) { |
277 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_FYI); |
278 | |
} |
279 | 0 | if (canAcknowledge(document)) { |
280 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_ACKNOWLEDGE); |
281 | |
} |
282 | 0 | return documentActions; |
283 | |
} |
284 | |
|
285 | |
protected ParameterService getParameterService() { |
286 | 0 | if ( parameterService == null ) { |
287 | 0 | parameterService = CoreFrameworkServiceLocator.getParameterService(); |
288 | |
} |
289 | 0 | return parameterService; |
290 | |
} |
291 | |
|
292 | |
|
293 | |
} |