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.kuali.rice.krad.uif.view.View;
19 import org.kuali.rice.krad.uif.view.ViewModel;
20 import org.kuali.rice.krad.uif.view.ViewPresentationControllerBase;
21 import org.kuali.rice.krad.util.KRADConstants;
22 import org.kuali.rice.krad.util.ObjectUtils;
23 import org.kuali.rice.krad.web.form.DocumentFormBase;
24 import org.kuali.rice.krad.web.form.UifFormBase;
25
26 import java.util.HashSet;
27 import java.util.Set;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 public class DocumentViewPresentationControllerBase extends ViewPresentationControllerBase implements DocumentPresentationController {
44 private static final long serialVersionUID = 1461173145806477758L;
45
46 private DocumentPresentationController documentPresentationController;
47
48 @Override
49 public Set<String> getActionFlags(View view, UifFormBase model) {
50 Set<String> documentActions = new HashSet<String>();
51
52 Document document = ((DocumentFormBase) model).getDocument();
53
54 if (canEdit(document)) {
55 documentActions.add(KRADConstants.KUALI_ACTION_CAN_EDIT);
56 }
57
58 if (canAnnotate(document)) {
59 documentActions.add(KRADConstants.KUALI_ACTION_CAN_ANNOTATE);
60 }
61
62 if (canClose(document)) {
63 documentActions.add(KRADConstants.KUALI_ACTION_CAN_CLOSE);
64 }
65
66 if (canSave(document)) {
67 documentActions.add(KRADConstants.KUALI_ACTION_CAN_SAVE);
68 }
69
70 if (canRoute(document)) {
71 documentActions.add(KRADConstants.KUALI_ACTION_CAN_ROUTE);
72 }
73
74 if (canCancel(document)) {
75 documentActions.add(KRADConstants.KUALI_ACTION_CAN_CANCEL);
76 }
77
78 if (canReload(document)) {
79 documentActions.add(KRADConstants.KUALI_ACTION_CAN_RELOAD);
80 }
81
82 if (canCopy(document)) {
83 documentActions.add(KRADConstants.KUALI_ACTION_CAN_COPY);
84 }
85
86 if (canPerformRouteReport(document)) {
87 documentActions.add(KRADConstants.KUALI_ACTION_PERFORM_ROUTE_REPORT);
88 }
89
90 if (canAddAdhocRequests(document)) {
91 documentActions.add(KRADConstants.KUALI_ACTION_CAN_ADD_ADHOC_REQUESTS);
92 }
93
94 if (canBlanketApprove(document)) {
95 documentActions.add(KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE);
96 }
97
98 if (canApprove(document)) {
99 documentActions.add(KRADConstants.KUALI_ACTION_CAN_APPROVE);
100 }
101
102 if (canDisapprove(document)) {
103 documentActions.add(KRADConstants.KUALI_ACTION_CAN_DISAPPROVE);
104 }
105
106 if (canSendAdhocRequests(document)) {
107 documentActions.add(KRADConstants.KUALI_ACTION_CAN_SEND_ADHOC_REQUESTS);
108 }
109
110 if (canSendNoteFyi(document)) {
111 documentActions.add(KRADConstants.KUALI_ACTION_CAN_SEND_NOTE_FYI);
112 }
113
114 if (this.canEditDocumentOverview(document)) {
115 documentActions.add(KRADConstants.KUALI_ACTION_CAN_EDIT_DOCUMENT_OVERVIEW);
116 }
117
118 if (canFyi(document)) {
119 documentActions.add(KRADConstants.KUALI_ACTION_CAN_FYI);
120 }
121
122 if (canAcknowledge(document)) {
123 documentActions.add(KRADConstants.KUALI_ACTION_CAN_ACKNOWLEDGE);
124 }
125
126 if (canComplete(document)) {
127 documentActions.add(KRADConstants.KUALI_ACTION_CAN_COMPLETE);
128 }
129
130 return documentActions;
131 }
132
133 public boolean canInitiate(String documentTypeName) {
134 return getDocumentPresentationController().canInitiate(documentTypeName);
135 }
136
137 public boolean canEdit(Document document) {
138 return getDocumentPresentationController().canEdit(document);
139 }
140
141
142
143
144 @Override
145 public boolean canEditView(View view, ViewModel model) {
146 DocumentFormBase documentForm = (DocumentFormBase) model;
147
148 return super.canEditView(view, model) && canEdit(documentForm.getDocument());
149 }
150
151 public boolean canAnnotate(Document document) {
152 return getDocumentPresentationController().canAnnotate(document);
153 }
154
155 public boolean canReload(Document document) {
156 return getDocumentPresentationController().canReload(document);
157 }
158
159 public boolean canClose(Document document) {
160 return getDocumentPresentationController().canClose(document);
161 }
162
163 public boolean canSave(Document document) {
164 return getDocumentPresentationController().canSave(document);
165 }
166
167 public boolean canRoute(Document document) {
168 return getDocumentPresentationController().canRoute(document);
169 }
170
171 public boolean canCancel(Document document) {
172 return getDocumentPresentationController().canEdit(document);
173 }
174
175 public boolean canRecall(Document document) {
176 return getDocumentPresentationController().canRecall(document);
177 }
178
179 public boolean canCopy(Document document) {
180 return getDocumentPresentationController().canCopy(document);
181 }
182
183 public boolean canPerformRouteReport(Document document) {
184 return getDocumentPresentationController().canPerformRouteReport(document);
185 }
186
187 public boolean canAddAdhocRequests(Document document) {
188 return getDocumentPresentationController().canAddAdhocRequests(document);
189 }
190
191 public boolean canBlanketApprove(Document document) {
192 return getDocumentPresentationController().canBlanketApprove(document);
193 }
194
195 public boolean canApprove(Document document) {
196 return getDocumentPresentationController().canApprove(document);
197 }
198
199 public boolean canDisapprove(Document document) {
200 return getDocumentPresentationController().canDisapprove(document);
201 }
202
203 public boolean canSendAdhocRequests(Document document) {
204 return getDocumentPresentationController().canSendAdhocRequests(document);
205 }
206
207 public boolean canSendNoteFyi(Document document) {
208 return getDocumentPresentationController().canSendNoteFyi(document);
209 }
210
211 public boolean canEditDocumentOverview(Document document) {
212 return getDocumentPresentationController().canEditDocumentOverview(document);
213 }
214
215 public boolean canFyi(Document document) {
216 return getDocumentPresentationController().canFyi(document);
217 }
218
219 public boolean canAcknowledge(Document document) {
220 return getDocumentPresentationController().canAcknowledge(document);
221 }
222
223 public boolean canComplete(Document document) {
224 return getDocumentPresentationController().canComplete(document);
225 }
226
227 public DocumentPresentationController getDocumentPresentationController() {
228 return documentPresentationController;
229 }
230
231 public void setDocumentPresentationController(DocumentPresentationController documentPresentationController) {
232 this.documentPresentationController = documentPresentationController;
233 }
234
235 public void setDocumentPresentationControllerClass(
236 Class<? extends DocumentPresentationController> documentPresentationControllerClass) {
237 this.documentPresentationController = ObjectUtils.newInstance(documentPresentationControllerClass);
238 }
239 }