1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.actionlist;
17
18 import org.kuali.rice.core.api.config.property.ConfigContext;
19 import org.kuali.rice.core.api.util.RiceConstants;
20 import org.kuali.rice.kew.actionitem.ActionItemBase;
21 import org.kuali.rice.kew.api.KewApiConstants;
22 import org.kuali.rice.kew.api.preferences.Preferences;
23 import org.kuali.rice.kew.util.WebFriendlyRecipient;
24 import org.kuali.rice.kim.api.identity.Person;
25 import org.kuali.rice.kim.api.identity.principal.Principal;
26 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
27 import org.kuali.rice.krad.util.GlobalVariables;
28 import org.kuali.rice.krad.util.KRADConstants;
29 import org.kuali.rice.krad.util.UrlFactory;
30 import org.kuali.rice.krad.web.form.UifFormBase;
31
32 import javax.servlet.http.HttpServletRequest;
33 import java.text.ParseException;
34 import java.util.ArrayList;
35 import java.util.HashMap;
36 import java.util.List;
37 import java.util.Map;
38 import java.util.Properties;
39
40
41
42
43
44
45
46
47
48
49
50 public class ActionListForm extends UifFormBase {
51
52 private static final long serialVersionUID = -6246391732337228107L;
53
54 private String delegator;
55 private String methodToCall = "";
56 private String helpDeskActionListUserName;
57 private String docType;
58 private String filterLegend;
59 private String actionListType;
60 private Boolean customActionList;
61 private String defaultActionToTake;
62 private List<ActionToTake> actionsToTake = new ArrayList<ActionToTake>();
63 private Map<?, ?> defaultActions = new HashMap<Object, Object>();
64 private String delegationId;
65 private List<?> delegators;
66 private Boolean hasCustomActions;
67 private Boolean routeLogPopup;
68 private Boolean documentPopup;
69 private List<WebFriendlyRecipient> primaryDelegates;
70 private String primaryDelegateId;
71 private Boolean hasDisplayParameters;
72
73 private String cssFile = "kuali.css";
74 private String logoAlign = "left";
75 private String viewOutbox;
76 private String[] outboxItems;
77 private boolean outBoxEmpty;
78 private Boolean showOutbox;
79
80
81 private boolean requeryActionList;
82 private Preferences preferences;
83 private boolean updateActionList;
84 private boolean outBoxMode;
85 private Principal helpDeskActionListPrincipal;
86 private Person helpDeskActionListPerson;
87
88
89 private static String CREATE_DATE_FROM = "createDateFrom";
90 private static String CREATE_DATE_TO = "createDateTo";
91 private static String LAST_ASSIGNED_DATE_FROM = "lastAssignedDateFrom";
92 private static String LAST_ASSIGNED_DATE_TO = "lastAssignedDateTo";
93 private ActionListFilter filter;
94 private ActionListFilter oldFilter;
95 private String createDateFrom;
96 private String createDateTo;
97 private String lastAssignedDateTo;
98 private String lastAssignedDateFrom;
99 private String lookupableImplServiceName;
100 private String lookupType;
101 private String docTypeFullName;
102 private List userWorkgroups;
103
104 private boolean helpDeskActionList;
105 private List<? extends ActionItemBase> actionList;
106 private List<org.kuali.rice.kew.api.action.ActionItem> apiActionItems;
107
108 public String getCreateDateTo() {
109 return createDateTo;
110 }
111 public void setCreateDateTo(String createDateTo) {
112 if(createDateTo == null){
113 createDateTo = "";
114 }
115 else{
116 this.createDateTo = createDateTo.trim();
117 }
118 }
119
120 public String getLastAssignedDateFrom() {
121 return lastAssignedDateFrom;
122 }
123
124 public void setLastAssignedDateFrom(String lastAssignedDateFrom) {
125 if(lastAssignedDateFrom == null){
126 lastAssignedDateFrom = "";
127 }
128 else{
129 this.lastAssignedDateFrom = lastAssignedDateFrom.trim();
130 }
131 }
132
133 public String getCreateDateFrom() {
134 return createDateFrom;
135 }
136
137 public void setCreateDateFrom(String createDate) {
138 if(createDate == null){
139 createDate = "";
140 }
141 else{
142 this.createDateFrom = createDate.trim();
143 }
144 }
145
146 public ActionListFilter getFilter() {
147 return filter;
148 }
149
150 public void setFilter(ActionListFilter filter) {
151 this.filter = filter;
152 if (filter.getCreateDateFrom() != null) {
153 setCreateDateFrom(RiceConstants.getDefaultDateFormat().format(filter.getCreateDateFrom()));
154 }
155 if (filter.getCreateDateTo() != null) {
156 setCreateDateTo(RiceConstants.getDefaultDateFormat().format(filter.getCreateDateTo()));
157 }
158 if (filter.getLastAssignedDateFrom() != null) {
159 setLastAssignedDateFrom(RiceConstants.getDefaultDateFormat().format(filter.getLastAssignedDateFrom()));
160 }
161 if (filter.getLastAssignedDateTo() != null) {
162 setLastAssignedDateTo(RiceConstants.getDefaultDateFormat().format(filter.getLastAssignedDateTo()));
163 }
164 }
165
166 public String getLastAssignedDateTo() {
167 return lastAssignedDateTo;
168 }
169
170 public void setLastAssignedDateTo(String lastAssignedDate) {
171 if(lastAssignedDate == null){
172 lastAssignedDate = "";
173 }
174 else{
175 this.lastAssignedDateTo = lastAssignedDate.trim();
176 }
177 }
178
179 public ActionListFilter getOldFilter() {
180 return oldFilter;
181 }
182
183 public void setOldFilter(ActionListFilter oldFilter) {
184 this.oldFilter = oldFilter;
185 }
186
187 public void validateDates() {
188
189
190 if (getCreateDateFrom() != null && getCreateDateFrom().length() != 0) {
191 try {
192 RiceConstants.getDefaultDateFormat().parse(getCreateDateFrom());
193 } catch (ParseException e) {
194 GlobalVariables.getMessageMap().putError(CREATE_DATE_FROM, "general.error.fieldinvalid", "Create Date From");
195 }
196 }
197 if (getCreateDateTo() != null && getCreateDateTo().length() != 0) {
198 try {
199 RiceConstants.getDefaultDateFormat().parse(getCreateDateTo());
200 } catch (ParseException e) {
201 GlobalVariables.getMessageMap().putError(CREATE_DATE_TO, "general.error.fieldinvalid", "Create Date To");
202 }
203 }
204 if (getLastAssignedDateFrom() != null && getLastAssignedDateFrom().length() != 0) {
205 try {
206 RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateFrom());
207 } catch (ParseException e1) {
208 GlobalVariables.getMessageMap().putError(LAST_ASSIGNED_DATE_FROM, "general.error.fieldinvalid", "Last Assigned Date From");
209 }
210 }
211 if (getLastAssignedDateTo() != null && getLastAssignedDateTo().length() != 0) {
212 try {
213 RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateTo());
214 } catch (ParseException e1) {
215 GlobalVariables.getMessageMap().putError(LAST_ASSIGNED_DATE_TO, "general.error.fieldinvalid", "Last Assigned Date To");
216 }
217 }
218 }
219
220 public ActionListFilter getLoadedFilter() {
221 try {
222 if (getCreateDateFrom() != null && getCreateDateFrom().length() != 0) {
223 filter.setCreateDateFrom(RiceConstants.getDefaultDateFormat().parse(getCreateDateFrom()));
224 }
225 if (getCreateDateTo() != null && getCreateDateTo().length() != 0) {
226 filter.setCreateDateTo(RiceConstants.getDefaultDateFormat().parse(getCreateDateTo()));
227 }
228 if (getLastAssignedDateFrom() != null && getLastAssignedDateFrom().length() != 0) {
229 filter.setLastAssignedDateFrom(RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateFrom()));
230 }
231 if (getLastAssignedDateTo() != null && getLastAssignedDateTo().length() != 0) {
232 filter.setLastAssignedDateTo(RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateTo()));
233 }
234 if (getDocTypeFullName() != null && ! "".equals(getDocTypeFullName())) {
235 filter.setDocumentType(getDocTypeFullName());
236 }
237 } catch (ParseException e) {
238
239 }
240
241 return filter;
242 }
243
244 public String getLookupableImplServiceName() {
245 return lookupableImplServiceName;
246 }
247
248 public void setLookupableImplServiceName(String lookupableImplServiceName) {
249 this.lookupableImplServiceName = lookupableImplServiceName;
250 }
251
252 public String getLookupType() {
253 return lookupType;
254 }
255
256 public void setLookupType(String lookupType) {
257 this.lookupType = lookupType;
258 }
259
260 public String getDocTypeFullName() {
261 return docTypeFullName;
262 }
263
264 public void setDocTypeFullName(String docTypeFullName) {
265 this.docTypeFullName = docTypeFullName;
266 }
267
268 public List getUserWorkgroups() {
269 return userWorkgroups;
270 }
271
272 public void setUserWorkgroups(List userWorkgroups) {
273 this.userWorkgroups = userWorkgroups;
274 }
275
276 public Principal getHelpDeskActionListPrincipal() {
277 return helpDeskActionListPrincipal;
278 }
279
280 public void setHelpDeskActionListPrincipal(Principal helpDeskActionListPrincipal) {
281 this.helpDeskActionListPrincipal = helpDeskActionListPrincipal;
282 }
283
284 public Person getHelpDeskActionListPerson() {
285 return helpDeskActionListPerson;
286 }
287
288 public void setHelpDeskActionListPerson(Person helpDeskActionListPerson) {
289 this.helpDeskActionListPerson = helpDeskActionListPerson;
290 }
291
292 public boolean isOutBoxMode() {
293 return outBoxMode;
294 }
295
296 public void setOutBoxMode(boolean outBoxMode) {
297 this.outBoxMode = outBoxMode;
298 }
299
300 public void setUser(String user) {
301 this.user = user;
302 }
303
304 public String getUser() {
305 return user;
306 }
307
308 private String user;
309
310 public boolean isNoRefresh() {
311 return noRefresh;
312 }
313
314 public void setNoRefresh(boolean noRefresh) {
315 this.noRefresh = noRefresh;
316 }
317
318 private boolean noRefresh;
319
320 public boolean isHelpDeskActionList() {
321 return helpDeskActionList;
322 }
323
324 public void setHelpDeskActionList(boolean helpDeskActionList) {
325 this.helpDeskActionList = helpDeskActionList;
326 }
327
328 public List<? extends ActionItemBase> getActionList() {
329 return actionList;
330 }
331 public void setActionList(List<? extends ActionItemBase> actionList) {
332 this.actionList = actionList;
333 }
334
335 public boolean isRequeryActionList() {
336 return requeryActionList;
337 }
338
339 public void setRequeryActionList(boolean requeryActionList) {
340 this.requeryActionList = requeryActionList;
341 }
342
343 public Preferences getPreferences() {
344 return preferences;
345 }
346
347 public void setPreferences(Preferences preferences) {
348 this.preferences = preferences;
349 }
350
351 public boolean isUpdateActionList() {
352 return updateActionList;
353 }
354
355 public void setUpdateActionList(boolean updateActionList) {
356 this.updateActionList = updateActionList;
357 }
358
359 public String getHelpDeskActionListUserName() {
360 return helpDeskActionListUserName;
361 }
362
363 public void setHelpDeskActionListUserName(String helpDeskActionListUserName) {
364 this.helpDeskActionListUserName = helpDeskActionListUserName;
365 }
366
367 @Override
368 public String getMethodToCall() {
369 return methodToCall;
370 }
371
372 @Override
373 public void setMethodToCall(String methodToCall) {
374 this.methodToCall = methodToCall;
375 }
376
377 public String getDelegator() {
378 return delegator;
379 }
380
381 public void setDelegator(String delegator) {
382 this.delegator = delegator;
383 }
384
385 public String getDocType() {
386 return docType;
387 }
388
389 public void setDocType(String docType) {
390 this.docType = docType;
391 }
392
393 public String getFilterLegend() {
394 return filterLegend;
395 }
396
397 public void setFilterLegend(String filterLegend) {
398 this.filterLegend = filterLegend;
399 }
400
401 public String getActionListType() {
402 if (actionListType == null) {
403 setActionListType("all");
404 }
405 return actionListType;
406 }
407
408 public void setActionListType(String actionListType) {
409 this.actionListType = actionListType;
410 }
411
412 public Boolean getCustomActionList() {
413 return customActionList;
414 }
415
416 public void setCustomActionList(Boolean customActionList) {
417 this.customActionList = customActionList;
418 }
419
420 public String getDefaultActionToTake() {
421 return defaultActionToTake;
422 }
423
424 public void setDefaultActionToTake(String defaultActionToTake) {
425 this.defaultActionToTake = defaultActionToTake;
426 }
427
428 public List<ActionToTake> getActionsToTake() {
429 return actionsToTake;
430 }
431
432 public void setActionsToTake(List<ActionToTake> actionsToTake) {
433 this.actionsToTake = actionsToTake;
434 }
435
436 public ActionToTake getActions(int index) {
437 while (getActionsToTake().size() <= index) {
438 getActionsToTake().add(new ActionToTake());
439 }
440 return getActionsToTake().get(index);
441 }
442
443 public Map<?, ?> getDefaultActions() {
444 return defaultActions;
445 }
446
447 public void setDefaultActions(Map<?, ?> defaultActions) {
448 this.defaultActions = defaultActions;
449 }
450
451 public String getDelegationId() {
452 return delegationId;
453 }
454
455 public void setDelegationId(String delegationId) {
456 this.delegationId = delegationId;
457 }
458
459 public List<?> getDelegators() {
460 return delegators;
461 }
462
463 public void setDelegators(List<?> delegators) {
464 this.delegators = delegators;
465 }
466
467 public Boolean getHasCustomActions() {
468 return hasCustomActions;
469 }
470
471 public void setHasCustomActions(Boolean hasCustomActions) {
472 this.hasCustomActions = hasCustomActions;
473 }
474
475 public String getCssFile() {
476 return cssFile;
477 }
478
479 public void setCssFile(String cssFile) {
480 this.cssFile = cssFile;
481 }
482
483 public String getLogoAlign() {
484 return logoAlign;
485 }
486
487 public void setLogoAlign(String logoAlign) {
488 this.logoAlign = logoAlign;
489 }
490
491 public String getViewOutbox() {
492 return this.viewOutbox;
493 }
494
495 public void setViewOutbox(String viewOutbox) {
496 this.viewOutbox = viewOutbox;
497 }
498
499 public String[] getOutboxItems() {
500 return outboxItems;
501 }
502
503 public void setOutboxItems(String[] outboxItems) {
504 this.outboxItems = outboxItems;
505 }
506
507 public boolean isOutBoxEmpty() {
508 return this.outBoxEmpty;
509 }
510
511 public void setOutBoxEmpty(boolean outBoxEmpty) {
512 this.outBoxEmpty = outBoxEmpty;
513 }
514
515 public Boolean getShowOutbox() {
516 return this.showOutbox;
517 }
518
519 public void setShowOutbox(Boolean showOutbox) {
520 this.showOutbox = showOutbox;
521 }
522
523 public String getMenuBar() {
524 String url = "";
525 Properties parameters = new Properties();
526 url = UrlFactory.parameterizeUrl(KRADConstants.MAINTENANCE_ACTION, parameters);
527 String krBaseUrl = ConfigContext.getCurrentContextConfig().getKRBaseURL();
528 url = "<a href=\""
529 + url
530 + "\"><img src=\""
531 + krBaseUrl
532 + "/images/tinybutton-preferences.gif\" alt=\"create new\" width=\"70\" height=\"15\"/></a>";
533
534 return url;
535 }
536
537 @Override
538 public void postBind(HttpServletRequest request) {
539
540
541 setPreferences((Preferences)(GlobalVariables.getUserSession().retrieveObject(KewApiConstants.PREFERENCES)));
542
543 String principalId = GlobalVariables.getUserSession().getPrincipalId();
544 final Principal hdalPrinc = (Principal) GlobalVariables.getUserSession().retrieveObject(
545 KewApiConstants.HELP_DESK_ACTION_LIST_PRINCIPAL_ATTR_NAME);
546 if (hdalPrinc != null) {
547 setHelpDeskActionListUserName(hdalPrinc.getPrincipalName());
548 }
549 boolean isHelpDeskAuthorized = KimApiServiceLocator.getPermissionService().isAuthorized(principalId,
550 KewApiConstants.KEW_NAMESPACE, KewApiConstants.PermissionNames.VIEW_OTHER_ACTION_LIST,
551 new HashMap<String, String>());
552 if (isHelpDeskAuthorized) {
553 setHelpDeskActionList(true);
554 }
555
556 super.postBind(request);
557 }
558
559 public Boolean getRouteLogPopup() {
560 return this.routeLogPopup;
561 }
562
563 public Boolean getDocumentPopup() {
564 return this.documentPopup;
565 }
566
567 public void setRouteLogPopup(Boolean routeLogPopup) {
568 this.routeLogPopup = routeLogPopup;
569 }
570
571 public void setDocumentPopup(Boolean documentPopup) {
572 this.documentPopup = documentPopup;
573 }
574
575 public Boolean getHasDisplayParameters() {
576 return this.hasDisplayParameters;
577 }
578
579 public void setHasDisplayParameters(Boolean hasDisplayParameters) {
580 this.hasDisplayParameters = hasDisplayParameters;
581 }
582
583 public List<WebFriendlyRecipient> getPrimaryDelegates() {
584 return this.primaryDelegates;
585 }
586
587 public void setPrimaryDelegates(List<WebFriendlyRecipient> primaryDelegates) {
588 this.primaryDelegates = primaryDelegates;
589 }
590
591 public String getPrimaryDelegateId() {
592 return this.primaryDelegateId;
593 }
594
595 public void setPrimaryDelegateId(String primaryDelegateId) {
596 this.primaryDelegateId = primaryDelegateId;
597 }
598
599
600 public List<org.kuali.rice.kew.api.action.ActionItem> getApiActionList() {
601 List<org.kuali.rice.kew.api.action.ActionItem> apiActionItems = new ArrayList<org.kuali.rice.kew.api.action.ActionItem>(actionList.size());
602
603 for (ActionItemBase actionItemObj : actionList) {
604 apiActionItems.add(
605 org.kuali.rice.kew.api.action.ActionItem.Builder.create(actionItemObj).build());
606 }
607
608 return apiActionItems;
609 }
610 }