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