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 return documentActions;
127 }
128
129 public boolean canInitiate(String documentTypeName) {
130 return getDocumentPresentationController().canInitiate(documentTypeName);
131 }
132
133 public boolean canEdit(Document document) {
134 return getDocumentPresentationController().canEdit(document);
135 }
136
137
138
139
140 @Override
141 public boolean canEditView(View view, ViewModel model) {
142 DocumentFormBase documentForm = (DocumentFormBase) model;
143
144 return super.canEditView(view, model) && canEdit(documentForm.getDocument());
145 }
146
147 public boolean canAnnotate(Document document) {
148 return getDocumentPresentationController().canAnnotate(document);
149 }
150
151 public boolean canReload(Document document) {
152 return getDocumentPresentationController().canReload(document);
153 }
154
155 public boolean canClose(Document document) {
156 return getDocumentPresentationController().canClose(document);
157 }
158
159 public boolean canSave(Document document) {
160 return getDocumentPresentationController().canSave(document);
161 }
162
163 public boolean canRoute(Document document) {
164 return getDocumentPresentationController().canRoute(document);
165 }
166
167 public boolean canCancel(Document document) {
168 return getDocumentPresentationController().canEdit(document);
169 }
170
171 public boolean canCopy(Document document) {
172 return getDocumentPresentationController().canCopy(document);
173 }
174
175 public boolean canPerformRouteReport(Document document) {
176 return getDocumentPresentationController().canPerformRouteReport(document);
177 }
178
179 public boolean canAddAdhocRequests(Document document) {
180 return getDocumentPresentationController().canAddAdhocRequests(document);
181 }
182
183 public boolean canBlanketApprove(Document document) {
184 return getDocumentPresentationController().canBlanketApprove(document);
185 }
186
187 public boolean canApprove(Document document) {
188 return getDocumentPresentationController().canApprove(document);
189 }
190
191 public boolean canDisapprove(Document document) {
192 return getDocumentPresentationController().canDisapprove(document);
193 }
194
195 public boolean canSendAdhocRequests(Document document) {
196 return getDocumentPresentationController().canSendAdhocRequests(document);
197 }
198
199 public boolean canSendNoteFyi(Document document) {
200 return getDocumentPresentationController().canSendNoteFyi(document);
201 }
202
203 public boolean canEditDocumentOverview(Document document) {
204 return getDocumentPresentationController().canEditDocumentOverview(document);
205 }
206
207 public boolean canFyi(Document document) {
208 return getDocumentPresentationController().canFyi(document);
209 }
210
211 public boolean canAcknowledge(Document document) {
212 return getDocumentPresentationController().canAcknowledge(document);
213 }
214
215 public DocumentPresentationController getDocumentPresentationController() {
216 return documentPresentationController;
217 }
218
219 public void setDocumentPresentationController(DocumentPresentationController documentPresentationController) {
220 this.documentPresentationController = documentPresentationController;
221 }
222
223 public void setDocumentPresentationControllerClass(
224 Class<? extends DocumentPresentationController> documentPresentationControllerClass) {
225 this.documentPresentationController = ObjectUtils.newInstance(documentPresentationControllerClass);
226 }
227 }