1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.actionlist;
17 import org.apache.struts.action.*;
18 import org.apache.commons.collections.ComparatorUtils;
19 import org.apache.commons.lang.StringUtils;
20 import org.apache.commons.lang.builder.EqualsBuilder;
21 import org.apache.commons.lang.builder.HashCodeBuilder;
22 import org.displaytag.pagination.PaginatedList;
23 import org.displaytag.properties.SortOrderEnum;
24 import org.displaytag.util.LookupUtil;
25 import org.kuali.rice.core.api.config.property.ConfigContext;
26 import org.kuali.rice.core.api.delegation.DelegationType;
27 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
28 import org.kuali.rice.core.api.exception.RiceRuntimeException;
29 import org.kuali.rice.core.api.util.ConcreteKeyValue;
30 import org.kuali.rice.core.api.util.KeyValue;
31 import org.kuali.rice.kew.actionitem.ActionItemActionListExtension;
32 import org.kuali.rice.kew.actionitem.OutboxItemActionListExtension;
33 import org.kuali.rice.kew.actionlist.service.ActionListService;
34 import org.kuali.rice.kew.actionlist.web.ActionListUtil;
35 import org.kuali.rice.kew.actionrequest.Recipient;
36 import org.kuali.rice.kew.api.KewApiConstants;
37 import org.kuali.rice.kew.api.action.ActionInvocation;
38 import org.kuali.rice.kew.api.action.ActionItemCustomization;
39 import org.kuali.rice.kew.api.action.ActionSet;
40 import org.kuali.rice.kew.api.action.ActionType;
41 import org.kuali.rice.kew.api.exception.WorkflowException;
42 import org.kuali.rice.kew.api.extension.ExtensionDefinition;
43 import org.kuali.rice.kew.api.preferences.Preferences;
44 import org.kuali.rice.kew.framework.KewFrameworkServiceLocator;
45 import org.kuali.rice.kew.framework.actionlist.ActionListCustomizationMediator;
46 import org.kuali.rice.kew.service.KEWServiceLocator;
47 import org.kuali.rice.kew.util.PerformanceLogger;
48 import org.kuali.rice.kim.api.group.Group;
49 import org.kuali.rice.kim.api.identity.Person;
50 import org.kuali.rice.kim.api.identity.principal.Principal;
51 import org.kuali.rice.kim.api.identity.principal.PrincipalContract;
52 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
53 import org.kuali.rice.kns.web.ui.ExtraButton;
54 import org.kuali.rice.krad.UserSession;
55 import org.kuali.rice.krad.exception.AuthorizationException;
56 import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
57 import org.kuali.rice.krad.util.GlobalVariables;
58 import org.kuali.rice.krad.web.controller.UifControllerBase;
59 import org.springframework.stereotype.Controller;
60 import org.springframework.validation.BindingResult;
61 import org.springframework.web.bind.annotation.ModelAttribute;
62 import org.springframework.web.bind.annotation.RequestMapping;
63 import org.springframework.web.servlet.ModelAndView;
64 import org.kuali.rice.krad.web.form.UifFormBase;
65
66 import javax.servlet.ServletException;
67 import javax.servlet.http.HttpServletRequest;
68 import javax.servlet.http.HttpServletResponse;
69 import java.text.ParseException;
70 import java.text.SimpleDateFormat;
71 import java.util.ArrayList;
72 import java.util.Arrays;
73 import java.util.Collection;
74 import java.util.Collections;
75 import java.util.Comparator;
76 import java.util.Date;
77 import java.util.HashSet;
78 import java.util.Iterator;
79 import java.util.LinkedHashMap;
80 import java.util.LinkedHashSet;
81 import java.util.List;
82 import java.util.Map;
83 import java.util.Set;
84
85
86
87
88
89
90 @Controller
91 @RequestMapping(value = "/new/actionList")
92 public class ActionListController extends UifControllerBase{
93 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionListController.class);
94 protected static final String MAX_ACTION_ITEM_DATE_FORMAT = "yyyy-MM-dd hh:mm:ss.S";
95
96 private static final ActionType [] actionListActionTypes =
97 { ActionType.APPROVE, ActionType.DISAPPROVE, ActionType.CANCEL, ActionType.ACKNOWLEDGE, ActionType.FYI };
98
99 @Override
100 protected ActionListForm createInitialForm(HttpServletRequest request) {
101 return new ActionListForm();
102 }
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 @RequestMapping(params = "methodToCall=refresh")
119 public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
120 HttpServletRequest request, HttpServletResponse response){
121 ActionListForm actionListForm = (ActionListForm)form;
122 actionListForm.setRequeryActionList(true);
123
124 return start(form,result,request,response);
125 }
126
127
128
129
130
131
132
133
134
135
136 protected void initializeFilter(ActionListForm form) {
137 if (form.getFilter() == null) {
138 ActionListFilter filter = new ActionListFilter();
139 filter.setDelegationType(DelegationType.SECONDARY.getCode());
140 filter.setExcludeDelegationType(true);
141 form.setFilter(filter);
142 }
143 }
144
145
146
147
148
149
150
151
152
153
154
155
156 protected String initializePrinicpalId(ActionListForm actionListForm,ActionListFilter filter) {
157 String principalId = null;
158 Principal principal = actionListForm.getHelpDeskActionListPrincipal();
159 if (principal != null) {
160 principalId = principal.getPrincipalId();
161 } else {
162 if (!StringUtils.isEmpty(actionListForm.getDocType())) {
163 initializeDocType(actionListForm,filter);
164 }
165 final UserSession uSession = getUserSession();
166 principalId = uSession.getPerson().getPrincipalId();
167 }
168
169 return principalId;
170 }
171
172
173
174
175
176
177
178
179
180
181
182
183 protected void initializeDocType(ActionListForm actionListForm,ActionListFilter filter) {
184 filter.setDocumentType(actionListForm.getDocType());
185 filter.setExcludeDocumentType(false);
186 actionListForm.setRequeryActionList(true);
187 }
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202 protected void initializeDelegators(ActionListForm actionListForm,ActionListFilter filter,List<? extends ActionItemActionListExtension> actionList,HttpServletRequest request) {
203 if (!KewApiConstants.DELEGATION_DEFAULT.equals(actionListForm.getDelegationId())) {
204
205
206
207
208
209 if (StringUtils.isNotBlank(actionListForm.getPrimaryDelegateId()) && !KewApiConstants.PRIMARY_DELEGATION_DEFAULT.equals(actionListForm.getPrimaryDelegateId())){
210 setDelegationId(actionListForm,request);
211 } else if (StringUtils.isNotBlank(filter.getPrimaryDelegateId()) &&
212 !KewApiConstants.PRIMARY_DELEGATION_DEFAULT.equals(filter.getPrimaryDelegateId())) {
213
214
215 filter.setPrimaryDelegateId(KewApiConstants.PRIMARY_DELEGATION_DEFAULT);
216 }
217 }
218
219 filter.setDelegatorId(actionListForm.getDelegationId());
220 filter.setExcludeDelegatorId(false);
221 actionList = null;
222 }
223
224
225
226
227
228
229
230
231
232
233
234
235 protected void setDelegationId(ActionListForm actionListForm,HttpServletRequest request) {
236 if (actionListForm.getPrimaryDelegateId().equals(request.getParameter("oldPrimaryDelegateId")) &&
237 !actionListForm.getDelegationId().equals(request.getParameter("oldDelegationId"))) {
238 actionListForm.setPrimaryDelegateId(KewApiConstants.PRIMARY_DELEGATION_DEFAULT);
239 } else {
240 actionListForm.setDelegationId(KewApiConstants.DELEGATION_DEFAULT);
241 }
242 }
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257 protected void initializePrimaryDelegate(ActionListForm actionListForm,ActionListFilter filter,List<? extends ActionItemActionListExtension> actionList,HttpServletRequest request) {
258 if (!StringUtils.isEmpty(actionListForm.getPrimaryDelegateId())) {
259
260
261
262 if (StringUtils.isBlank(actionListForm.getDelegationId()) && !KewApiConstants.PRIMARY_DELEGATION_DEFAULT.equals(actionListForm.getPrimaryDelegateId()) &&
263 StringUtils.isNotBlank(filter.getDelegatorId()) &&
264 !KewApiConstants.DELEGATION_DEFAULT.equals(filter.getDelegatorId())) {
265 filter.setDelegatorId(KewApiConstants.DELEGATION_DEFAULT);
266 }
267
268
269 filter.setPrimaryDelegateId(actionListForm.getPrimaryDelegateId());
270 filter.setExcludeDelegatorId(false);
271 actionList = null;
272 }
273 }
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290 @Override
291 @RequestMapping(params = "methodToCall=start")
292 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
293 HttpServletRequest request, HttpServletResponse response) {
294 ActionListForm actionListForm = (ActionListForm)form;
295 request.setAttribute("preferences", actionListForm.getPreferences());
296
297 PerformanceLogger plog = new PerformanceLogger();
298 plog.log("Starting ActionList fetch");
299 ActionListService actionListSrv = KEWServiceLocator.getActionListService();
300
301
302 actionListForm.setDefaultActionToTake("NONE");
303 boolean freshActionList = true;
304
305
306 List<? extends ActionItemActionListExtension> actionList = (List<? extends ActionItemActionListExtension>)actionListForm.getActionList();
307 plog.log("Time to initialize");
308
309
310 try {
311
312 initializeFilter(actionListForm);
313 final ActionListFilter filter = actionListForm.getFilter();
314
315 String principalId = initializePrinicpalId(actionListForm,filter);
316
317
318
319
320
321
322 boolean forceListRefresh = actionListForm.isRequeryActionList();
323
324 final Preferences preferences = (Preferences)actionListForm.getPreferences();
325
326
327 if (!StringUtils.isEmpty(actionListForm.getDelegationId())) {
328 initializeDelegators(actionListForm,filter,actionList,request);
329 }
330
331
332 if (!StringUtils.isEmpty(actionListForm.getPrimaryDelegateId())) {
333 initializePrimaryDelegate(actionListForm,filter,actionList,request);
334 }
335
336
337 if (!principalId.equals(actionListForm.getUser())) {
338 actionList = null;
339 }
340
341 if (isOutboxMode(actionListForm, request, preferences)) {
342 actionList = new ArrayList<OutboxItemActionListExtension>(actionListSrv.getOutbox(principalId, filter));
343 actionListForm.setOutBoxEmpty(actionList.isEmpty());
344
345 actionListForm.setActionList((ArrayList) actionList);
346 } else {
347
348 if (actionList == null) {
349
350 actionList = new ArrayList<ActionItemActionListExtension>(actionListSrv.getActionList(principalId, filter));
351 actionListForm.setUser(principalId);
352 } else if (forceListRefresh) {
353
354 actionList = new ArrayList<ActionItemActionListExtension>(actionListSrv.getActionList(principalId, filter));
355 actionListForm.setUser(principalId);
356 } else {
357 Boolean update = actionListForm.isUpdateActionList();
358 }
359
360 actionListForm.setActionList((ArrayList) actionList);
361 }
362
363
364 actionListForm.setRequeryActionList(false);
365
366
367 if (KewApiConstants.DELEGATORS_ON_ACTION_LIST_PAGE.equalsIgnoreCase(preferences.getDelegatorFilter())) {
368 Collection<Recipient> delegators = actionListSrv.findUserSecondaryDelegators(principalId);
369 actionListForm.setDelegators(ActionListUtil.getWebFriendlyRecipients(delegators));
370 actionListForm.setDelegationId(filter.getDelegatorId());
371 }
372
373
374 if (KewApiConstants.PRIMARY_DELEGATES_ON_ACTION_LIST_PAGE.equalsIgnoreCase(preferences.getPrimaryDelegateFilter())) {
375 Collection<Recipient> pDelegates = actionListSrv.findUserPrimaryDelegations(principalId);
376 actionListForm.setPrimaryDelegates(ActionListUtil.getWebFriendlyRecipients(pDelegates));
377 actionListForm.setPrimaryDelegateId(filter.getPrimaryDelegateId());
378 }
379
380 actionListForm.setFilterLegend(filter.getFilterLegend());
381 plog.log("Setting attributes");
382
383 int pageSize = getPageSize(preferences);
384
385
386 if (freshActionList) {
387 plog.log("calling initializeActionList");
388 initializeActionList(actionList, preferences);
389 plog.log("done w/ initializeActionList");
390 }
391
392 plog.log("start addActions");
393 addCustomActions(actionList,preferences,actionListForm);
394 plog.log("done w/ addCustomActions");
395 actionListForm.setUpdateActionList(false);
396 plog.log("finished setting attributes, finishing action list fetch");
397 } catch (Exception e) {
398 LOG.error("Error loading action list.", e);
399 }
400
401 LOG.debug("end start ActionListAction");
402
403 String returnPage = "ActionListPage1";
404 String methodToCall = actionListForm.getMethodToCall();
405 if(methodToCall.equals("clear")) {
406 returnPage = "ActionListPage2";
407 }
408
409 return getUIFModelAndView(actionListForm,returnPage);
410 }
411
412 private static final String OUT_BOX_MODE = "_OUT_BOX_MODE";
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427 private boolean isOutboxMode(ActionListForm alForm, HttpServletRequest request, Preferences preferences) {
428
429 boolean outBoxView = false;
430
431 if (! preferences.isUsingOutbox() || ! ConfigContext.getCurrentContextConfig().getOutBoxOn()) {
432 alForm.setOutBoxMode(Boolean.FALSE);
433 alForm.setViewOutbox("false");
434 alForm.setShowOutbox(false);
435
436 return false;
437 }
438
439 alForm.setShowOutbox(true);
440
441 if (StringUtils.isNotEmpty(alForm.getViewOutbox())) {
442 if (!Boolean.valueOf(alForm.getViewOutbox())) {
443
444 alForm.setOutBoxMode(Boolean.FALSE);
445 outBoxView = false;
446 } else {
447
448 alForm.setOutBoxMode(Boolean.FALSE);
449 outBoxView = true;
450 }
451 } else {
452 outBoxView = alForm.isOutBoxMode();
453 }
454
455 if (outBoxView) {
456 alForm.setViewOutbox("true");
457 } else {
458 alForm.setViewOutbox("false");
459 }
460
461 return outBoxView;
462 }
463
464
465
466
467
468
469
470
471
472
473
474
475 private void initializeActionList(List<? extends ActionItemActionListExtension> actionList, Preferences preferences) {
476 List<String> actionItemProblemIds = new ArrayList<String>();
477 int index = 0;
478 generateActionItemErrors(actionList);
479
480 for (Iterator<? extends ActionItemActionListExtension> iterator = actionList.iterator(); iterator.hasNext();) {
481 ActionItemActionListExtension actionItem = iterator.next();
482 if (actionItem.getDocumentId() == null) {
483 LOG.error("Somehow there exists an ActionItem with a null document id! actionItemId=" + actionItem.getId());
484 iterator.remove();
485 continue;
486 }
487
488 try {
489 actionItem.initialize(preferences);
490 actionItem.setActionListIndex(index);
491 index++;
492 } catch (Exception e) {
493
494
495 LOG.error("Error loading action list for action item " + actionItem.getId(), e);
496 iterator.remove();
497 actionItemProblemIds.add(actionItem.getDocumentId());
498 }
499 }
500
501 generateActionItemErrors("actionitem", "actionlist.badActionItems", actionItemProblemIds);
502 }
503
504
505
506
507
508
509
510
511
512
513
514
515 protected int getPageSize(Preferences preferences) {
516 return Integer.parseInt(preferences.getPageSize());
517 }
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532 protected void addCustomActions(List<? extends ActionItemActionListExtension> actionList,
533 Preferences preferences, ActionListForm form) throws WorkflowException {
534
535 boolean haveCustomActions = false;
536 boolean haveDisplayParameters = false;
537
538 final boolean showClearFyi = KewApiConstants.PREFERENCES_YES_VAL.equalsIgnoreCase(preferences.getShowClearFyi());
539
540
541 Set<ActionType> pageActions = new HashSet<ActionType>();
542
543 List<String> customActionListProblemIds = new ArrayList<String>();
544 generateActionItemErrors(actionList);
545
546 LOG.info("Beginning processing of Action List Customizations (total: " + actionList.size() + " Action Items)");
547 long start = System.currentTimeMillis();
548 Map<String, ActionItemCustomization> customizationMap =
549 getActionListCustomizationMediator().getActionListCustomizations(
550 getUserSession().getPrincipalId(), convertToApiActionItems(actionList)
551 );
552 long end = System.currentTimeMillis();
553 LOG.info("Finished processing of Action List Customizations (total time: " + (end - start) + " ms)");
554
555 for(ActionItemActionListExtension actionItem : actionList ){
556
557 try {
558 ActionItemCustomization customization = customizationMap.get(actionItem.getId());
559
560 if (customization != null) {
561 ActionSet actionSet = customization.getActionSet();
562
563
564 Map<String, String> customActions = new LinkedHashMap<String, String>();
565 customActions.put("NONE", "NONE");
566
567 for (ActionType actionType : actionListActionTypes) {
568 if (actionSet.hasAction(actionType.getCode()) &&
569 isActionCompatibleRequest(actionItem, actionType.getCode())) {
570 final boolean isFyi = ActionType.FYI == actionType;
571 if (!isFyi || (isFyi && showClearFyi)) {
572 customActions.put(actionType.getCode(), actionType.getLabel());
573 pageActions.add(actionType);
574 }
575 }
576 }
577
578 if (customActions.size() > 1) {
579 actionItem.setCustomActions(customActions);
580 haveCustomActions = true;
581 }
582
583 actionItem.setDisplayParameters(customization.getDisplayParameters());
584 haveDisplayParameters = haveDisplayParameters || (actionItem.getDisplayParameters() != null);
585 }
586
587 } catch (Exception e) {
588
589 LOG.error("Problem loading custom action list attribute", e);
590 customActionListProblemIds.add(actionItem.getDocumentId());
591 }
592 }
593
594
595 form.setHasCustomActions(haveCustomActions);
596
597 Map<String, String> defaultActions = new LinkedHashMap<String, String>();
598 defaultActions.put("NONE", "NONE");
599
600 for (ActionType actionType : actionListActionTypes) {
601 if (pageActions.contains(actionType)) {
602
603 final boolean isFyi = ActionType.FYI == actionType;
604 if (isFyi) {
605
606 if(showClearFyi) {
607 defaultActions.put(actionType.getCode(), actionType.getLabel());
608 }
609 } else {
610 defaultActions.put(actionType.getCode(), actionType.getLabel());
611 form.setCustomActionList(Boolean.TRUE);
612 }
613 }
614 }
615
616 if (defaultActions.size() > 1) {
617 form.setDefaultActions(defaultActions);
618 }
619
620 form.setHasDisplayParameters(haveDisplayParameters);
621 generateActionItemErrors("customActionList", "actionlist.badCustomActionListItems", customActionListProblemIds);
622
623 }
624
625
626
627
628
629
630
631
632
633
634
635 private List<org.kuali.rice.kew.api.action.ActionItem> convertToApiActionItems(List<? extends ActionItemActionListExtension> actionList) {
636 List<org.kuali.rice.kew.api.action.ActionItem> apiActionItems = new ArrayList<org.kuali.rice.kew.api.action.ActionItem>(actionList.size());
637 for (ActionItemActionListExtension actionItemObj : actionList) {
638 apiActionItems.add(
639 org.kuali.rice.kew.api.action.ActionItem.Builder.create(actionItemObj).build());
640 }
641
642 return apiActionItems;
643 }
644
645
646
647
648
649
650
651
652
653
654
655
656
657 private void generateActionItemErrors(String propertyName, String errorKey, List<String> documentIds) {
658 if (!documentIds.isEmpty()) {
659 String documentIdsString = StringUtils.join(documentIds.iterator(), ", ");
660 GlobalVariables.getMessageMap().putError(propertyName, errorKey, documentIdsString);
661 }
662 }
663
664
665
666
667
668
669
670
671
672
673
674 private void generateActionItemErrors(List<? extends ActionItemActionListExtension> actionList) {
675 for (ActionItemActionListExtension actionItem : actionList) {
676 if(!KewApiConstants.ACTION_REQUEST_CODES.containsKey(actionItem.getActionRequestCd())) {
677 GlobalVariables.getMessageMap().putError("actionRequestCd","actionitem.actionrequestcd.invalid",actionItem.getId()+"");
678 }
679 }
680 }
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696 @RequestMapping(params = "methodToCall=takeMassActions")
697 protected ModelAndView takeMassActions(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
698 HttpServletRequest request, HttpServletResponse response){
699 ActionListForm actionListForm = (ActionListForm) form;
700
701 Object obj = ObjectPropertyUtils.getPropertyValue(form, "extensionData['actionInputField_actionSelect_line2']");
702
703 List<? extends ActionItemActionListExtension> actionList = (List<? extends ActionItemActionListExtension>) actionListForm.getActionList();
704 if (actionList == null) {
705 return getUIFModelAndView(form);
706 }
707
708 ActionMessages messages = new ActionMessages();
709 List<ActionInvocation> invocations = new ArrayList<ActionInvocation>();
710
711 int index = 0;
712 for (Object element : actionListForm.getActionsToTake()) {
713 ActionToTake actionToTake = (ActionToTake) element;
714 if (actionToTake != null && actionToTake.getActionTakenCd() != null &&
715 !"".equals(actionToTake.getActionTakenCd()) &&
716 !"NONE".equalsIgnoreCase(actionToTake.getActionTakenCd()) &&
717 actionToTake.getActionItemId() != null) {
718 ActionItemActionListExtension actionItem = getActionItemFromActionList(actionList, actionToTake.getActionItemId());
719 if (actionItem == null) {
720 LOG.warn("Could not locate the ActionItem to take mass action against in the action list: " + actionToTake.getActionItemId());
721 continue;
722 }
723 invocations.add(ActionInvocation.create(ActionType.fromCode(actionToTake.getActionTakenCd()), actionItem.getId()));
724 }
725 index++;
726 }
727
728 KEWServiceLocator.getWorkflowDocumentService().takeMassActions(getUserSession().getPrincipalId(), invocations);
729 messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.routing.processed"));
730
731 org.kuali.rice.kew.actionlist.web.ActionListForm
732 cleanForm = new org.kuali.rice.kew.actionlist.web.ActionListForm();
733 actionListForm.setRequeryActionList(true);
734
735 return start(actionListForm,result,request,response);
736 }
737
738
739
740
741
742
743
744
745
746
747
748
749 protected ActionItemActionListExtension getActionItemFromActionList(List<? extends ActionItemActionListExtension> actionList, String actionItemId) {
750 for (ActionItemActionListExtension actionItem : actionList) {
751 if (actionItem.getId().equals(actionItemId)) {
752 return actionItem;
753 }
754 }
755
756 return null;
757 }
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772 @RequestMapping(params = "methodToCall=helpDeskActionListLogin")
773 public ModelAndView helpDeskActionListLogin(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
774 HttpServletRequest request, HttpServletResponse response){
775 ActionListForm actionListForm = (ActionListForm) form;
776
777 String name = actionListForm.getHelpDeskActionListUserName();
778 if (!actionListForm.isHelpDeskActionList()) {
779 throw new AuthorizationException(getUserSession().getPrincipalId(), "helpDeskActionListLogin", getClass().getSimpleName());
780 }
781
782 try
783 {
784 final Principal helpDeskActionListPrincipal = KEWServiceLocator.getIdentityHelperService().getPrincipalByPrincipalName(name);
785 final Person helpDeskActionListPerson = KEWServiceLocator.getIdentityHelperService().getPersonByPrincipalName(name);
786 actionListForm.setHelpDeskActionListPrincipal(helpDeskActionListPrincipal);
787 actionListForm.setHelpDeskActionListPerson(helpDeskActionListPerson);
788 }
789 catch (RiceRuntimeException rre)
790 {
791 GlobalVariables.getMessageMap().putError("helpDeskActionListUserName", "helpdesk.login.invalid", name);
792 }
793 catch (RiceIllegalArgumentException e) {
794 GlobalVariables.getMessageMap().putError("helpDeskActionListUserName", "helpdesk.login.invalid", name);
795 }
796 catch (NullPointerException npe)
797 {
798 GlobalVariables.getMessageMap().putError("null", "helpdesk.login.empty", name);
799 }
800
801 actionListForm.setDelegator(null);
802 actionListForm.setRequeryActionList(true);
803
804 return start(actionListForm,result,request,response);
805 }
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820 @RequestMapping(params = "methodToCall=clearFilter")
821 public ModelAndView clearFilter(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
822 HttpServletRequest request, HttpServletResponse response){
823 ActionListForm actionListForm = (ActionListForm) form;
824
825 LOG.debug("clearFilter ActionListController");
826 final org.kuali.rice.krad.UserSession commonUserSession = getUserSession();
827 actionListForm.setFilter(new ActionListFilter());
828 ActionListFilter filter = new ActionListFilter();
829 filter.setDelegationType(DelegationType.SECONDARY.getCode());
830 filter.setExcludeDelegationType(true);
831 actionListForm.setFilter(filter);
832 LOG.debug("end clearFilter ActionListController");
833
834 return start(actionListForm,result,request,response);
835 }
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851 @RequestMapping(params = "methodToCall=clear")
852 public ModelAndView clear(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
853 HttpServletRequest request, HttpServletResponse response){
854 return clearFilter(form,result,request,response);
855 }
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870 @RequestMapping(params = "methodToCall=setFilter")
871 public ModelAndView setFilter(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
872 HttpServletRequest request, HttpServletResponse response){
873 ActionListForm actionListForm = (ActionListForm) form;
874
875
876 final UserSession uSession = getUserSession();
877
878 ActionListFilter alFilter = actionListForm.getLoadedFilter();
879 if (StringUtils.isNotBlank(alFilter.getDelegatorId()) && !KewApiConstants.DELEGATION_DEFAULT.equals(alFilter.getDelegatorId()) &&
880 StringUtils.isNotBlank(alFilter.getPrimaryDelegateId()) && !KewApiConstants.PRIMARY_DELEGATION_DEFAULT.equals(alFilter.getPrimaryDelegateId())){
881
882
883 alFilter.setDelegatorId(KewApiConstants.DELEGATION_DEFAULT);
884 }
885
886 actionListForm.setFilter(alFilter);
887 if (GlobalVariables.getMessageMap().hasNoErrors()) {
888 actionListForm.setRequeryActionList(true);
889 return start(actionListForm,result,request,response);
890 }
891
892 return start(actionListForm,result,request,response);
893 }
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908 @RequestMapping(params = "methodToCall=clearHelpDeskActionListUser")
909 public ModelAndView clearHelpDeskActionListUser(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
910 HttpServletRequest request, HttpServletResponse response){
911 ActionListForm actionListForm = (ActionListForm) form;
912
913 LOG.debug("clearHelpDeskActionListUser ActionListAction");
914 actionListForm.setHelpDeskActionListPrincipal(null);
915 actionListForm.setHelpDeskActionListPerson(null);
916 LOG.debug("end clearHelpDeskActionListUser ActionListAction");
917
918 actionListForm.setRequeryActionList(true);
919
920 return start((UifFormBase)actionListForm,result,request,response);
921 }
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936 @RequestMapping(params = "methodToCall=removeOutboxItems")
937 public ModelAndView removeOutboxItems(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
938 HttpServletRequest request, HttpServletResponse response){
939 ActionListForm actionListForm = (ActionListForm)form;
940 Map selectedCollectionLines = actionListForm.getSelectedCollectionLines();
941 Object selectedItems = selectedCollectionLines.get("ActionList");
942
943 if (selectedItems != null) {
944 List<String> outboxItemsForDeletion = new ArrayList<String>((LinkedHashSet)selectedItems);
945 KEWServiceLocator.getActionListService().removeOutboxItems(getUserSession().getPrincipalId(), outboxItemsForDeletion);
946 selectedCollectionLines.remove("ActionList");
947 actionListForm.setSelectedCollectionLines(selectedCollectionLines);
948 }
949
950 actionListForm.setViewOutbox("true");
951 actionListForm.setRequeryActionList(true);
952
953 return start(actionListForm,result,request,response);
954 }
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969 @RequestMapping(params = "methodToCall=viewFilter")
970 public ModelAndView viewFilter(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
971 HttpServletRequest request, HttpServletResponse response){
972 ActionListForm actionListForm = (ActionListForm)form;
973 actionListForm.setOldFilter(new ActionListFilter(actionListForm.getFilter()));
974
975 return getUIFModelAndView(actionListForm,"ActionListPage2");
976 }
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991 @RequestMapping(params = "methodToCall=cancelFilter")
992 public ModelAndView cancelFilter(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
993 HttpServletRequest request, HttpServletResponse response){
994 ActionListForm actionListForm = (ActionListForm)form;
995 actionListForm.setFilter(new ActionListFilter(actionListForm.getOldFilter()));
996
997 return start(actionListForm,result,request,response);
998 }
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014 @RequestMapping(params = "methodToCall=viewPreferences")
1015 public ModelAndView viewPreferences(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1016 HttpServletRequest request, HttpServletResponse response){
1017 return getUIFModelAndView(form,"ActionListPage3");
1018 }
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031 private boolean isActionCompatibleRequest(ActionItemActionListExtension actionItem, String actionTakenCode) {
1032 boolean actionCompatible = false;
1033 String requestCd = actionItem.getActionRequestCd();
1034
1035
1036 if (KewApiConstants.ACTION_REQUEST_FYI_REQ.equals(requestCd) && KewApiConstants.ACTION_TAKEN_FYI_CD.equals(actionTakenCode)) {
1037 actionCompatible = true || actionCompatible;
1038 }
1039
1040
1041 if (KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ.equals(requestCd) && KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD.equals(actionTakenCode)) {
1042 actionCompatible = true || actionCompatible;
1043 }
1044
1045
1046 if (KewApiConstants.ACTION_REQUEST_APPROVE_REQ.equals(requestCd) && !(KewApiConstants.ACTION_TAKEN_FYI_CD.equals(actionTakenCode) || KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD.equals(actionTakenCode))) {
1047 actionCompatible = true || actionCompatible;
1048 }
1049
1050
1051 if (KewApiConstants.ACTION_REQUEST_COMPLETE_REQ.equals(requestCd) && !(KewApiConstants.ACTION_TAKEN_FYI_CD.equals(actionTakenCode) || KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD.equals(actionTakenCode))) {
1052 actionCompatible = true || actionCompatible;
1053 }
1054
1055 return actionCompatible;
1056 }
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067 private UserSession getUserSession(){
1068 return GlobalVariables.getUserSession();
1069 }
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079 private static class ActionListCustomizationMediatorHolder {
1080 static final ActionListCustomizationMediator actionListCustomizationMediator =
1081 KewFrameworkServiceLocator.getActionListCustomizationMediator();
1082 }
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093 private ActionListCustomizationMediator getActionListCustomizationMediator() {
1094 return ActionListCustomizationMediatorHolder.actionListCustomizationMediator;
1095 }
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105 private static final class PartitionKey {
1106 String applicationId;
1107 Set<String> customActionListAttributeNames;
1108
1109 PartitionKey(String applicationId, Collection<ExtensionDefinition> extensionDefinitions) {
1110 this.applicationId = applicationId;
1111 this.customActionListAttributeNames = new HashSet<String>();
1112 for (ExtensionDefinition extensionDefinition : extensionDefinitions) {
1113 this.customActionListAttributeNames.add(extensionDefinition.getName());
1114 }
1115 }
1116
1117 List<String> getCustomActionListAttributeNameList() {
1118 return new ArrayList<String>(customActionListAttributeNames);
1119 }
1120
1121 @Override
1122 public boolean equals(Object o) {
1123 if (!(o instanceof PartitionKey)) {
1124 return false;
1125 }
1126 PartitionKey key = (PartitionKey) o;
1127 EqualsBuilder builder = new EqualsBuilder();
1128 builder.append(applicationId, key.applicationId);
1129 builder.append(customActionListAttributeNames, key.customActionListAttributeNames);
1130
1131 return builder.isEquals();
1132 }
1133
1134 @Override
1135 public int hashCode() {
1136 HashCodeBuilder builder = new HashCodeBuilder();
1137 builder.append(applicationId);
1138 builder.append(customActionListAttributeNames);
1139
1140 return builder.hashCode();
1141 }
1142 }
1143
1144
1145 }
1146