1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.actionlist.web; |
18 | |
|
19 | |
import java.util.ArrayList; |
20 | |
import java.util.Arrays; |
21 | |
import java.util.Collection; |
22 | |
import java.util.Collections; |
23 | |
import java.util.Comparator; |
24 | |
import java.util.Iterator; |
25 | |
import java.util.LinkedHashMap; |
26 | |
import java.util.List; |
27 | |
import java.util.Map; |
28 | |
|
29 | |
import javax.servlet.http.HttpServletRequest; |
30 | |
import javax.servlet.http.HttpServletResponse; |
31 | |
|
32 | |
import org.apache.commons.collections.ComparatorUtils; |
33 | |
import org.apache.commons.lang.StringUtils; |
34 | |
import org.apache.struts.action.ActionForm; |
35 | |
import org.apache.struts.action.ActionForward; |
36 | |
import org.apache.struts.action.ActionMapping; |
37 | |
import org.apache.struts.action.ActionMessage; |
38 | |
import org.apache.struts.action.ActionMessages; |
39 | |
import org.displaytag.pagination.PaginatedList; |
40 | |
import org.displaytag.properties.SortOrderEnum; |
41 | |
import org.displaytag.util.LookupUtil; |
42 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
43 | |
import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; |
44 | |
import org.kuali.rice.core.api.exception.RiceRuntimeException; |
45 | |
import org.kuali.rice.kew.actionitem.ActionItem; |
46 | |
import org.kuali.rice.kew.actionitem.ActionItemActionListExtension; |
47 | |
import org.kuali.rice.kew.actionlist.ActionListFilter; |
48 | |
import org.kuali.rice.kew.actionlist.ActionToTake; |
49 | |
import org.kuali.rice.kew.actionlist.CustomActionListAttribute; |
50 | |
import org.kuali.rice.kew.actionlist.PaginatedActionList; |
51 | |
import org.kuali.rice.kew.actionlist.service.ActionListService; |
52 | |
import org.kuali.rice.kew.actionrequest.Recipient; |
53 | |
import org.kuali.rice.kew.actions.ActionSet; |
54 | |
import org.kuali.rice.kew.actions.asyncservices.ActionInvocation; |
55 | |
import org.kuali.rice.kew.api.action.DelegationType; |
56 | |
import org.kuali.rice.kew.exception.WorkflowException; |
57 | |
import org.kuali.rice.kew.preferences.Preferences; |
58 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
59 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValueActionListExtension; |
60 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
61 | |
import org.kuali.rice.kew.util.KEWConstants; |
62 | |
import org.kuali.rice.kew.util.PerformanceLogger; |
63 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
64 | |
import org.kuali.rice.kim.api.identity.principal.PrincipalContract; |
65 | |
import org.kuali.rice.kim.bo.Person; |
66 | |
import org.kuali.rice.kns.web.struts.action.KualiAction; |
67 | |
import org.kuali.rice.kns.web.ui.ExtraButton; |
68 | |
import org.kuali.rice.krad.UserSession; |
69 | |
import org.kuali.rice.krad.exception.AuthorizationException; |
70 | |
import org.kuali.rice.krad.util.GlobalVariables; |
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | 0 | public class ActionListAction extends KualiAction { |
80 | |
|
81 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionListAction.class); |
82 | |
|
83 | |
private static final String ACTION_LIST_KEY = "actionList"; |
84 | |
private static final String ACTION_LIST_PAGE_KEY = "actionListPage"; |
85 | |
private static final String ACTION_LIST_USER_KEY = "actionList.user"; |
86 | |
private static final String REQUERY_ACTION_LIST_KEY = "requeryActionList"; |
87 | |
|
88 | |
private static final String ACTIONREQUESTCD_PROP = "actionRequestCd"; |
89 | |
private static final String CUSTOMACTIONLIST_PROP = "customActionList"; |
90 | |
private static final String ACTIONITEM_PROP = "actionitem"; |
91 | |
private static final String HELPDESK_ACTIONLIST_USERNAME = "helpDeskActionListUserName"; |
92 | |
|
93 | |
private static final String ACTIONITEM_ACTIONREQUESTCD_INVALID_ERRKEY = "actionitem.actionrequestcd.invalid"; |
94 | |
private static final String ACTIONLIST_BAD_CUSTOM_ACTION_LIST_ITEMS_ERRKEY = "actionlist.badCustomActionListItems"; |
95 | |
private static final String ACTIONLIST_BAD_ACTION_ITEMS_ERRKEY = "actionlist.badActionItems"; |
96 | |
private static final String HELPDESK_LOGIN_EMPTY_ERRKEY = "helpdesk.login.empty"; |
97 | |
private static final String HELPDESK_LOGIN_INVALID_ERRKEY = "helpdesk.login.invalid"; |
98 | |
|
99 | |
|
100 | |
@Override |
101 | |
public ActionForward execute(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { |
102 | 0 | ActionListForm frm = (ActionListForm)actionForm; |
103 | 0 | request.setAttribute("Constants", getServlet().getServletContext().getAttribute("KEWConstants")); |
104 | 0 | request.setAttribute("preferences", getUserSession().retrieveObject(KEWConstants.PREFERENCES)); |
105 | 0 | frm.setHeaderButtons(getHeaderButtons()); |
106 | 0 | return super.execute(mapping, actionForm, request, response); |
107 | |
} |
108 | |
|
109 | |
private List<ExtraButton> getHeaderButtons(){ |
110 | 0 | List<ExtraButton> headerButtons = new ArrayList<ExtraButton>(); |
111 | 0 | ExtraButton eb = new ExtraButton(); |
112 | 0 | String krBaseUrl = ConfigContext.getCurrentContextConfig().getKRBaseURL(); |
113 | 0 | eb.setExtraButtonSource( krBaseUrl + "/images/tinybutton-preferences.gif"); |
114 | 0 | eb.setExtraButtonOnclick("Preferences.do?returnMapping=viewActionList"); |
115 | |
|
116 | 0 | headerButtons.add(eb); |
117 | 0 | eb = new ExtraButton(); |
118 | 0 | eb.setExtraButtonSource(krBaseUrl + "/images/tinybutton-refresh.gif"); |
119 | 0 | eb.setExtraButtonProperty("methodToCall.start"); |
120 | |
|
121 | 0 | headerButtons.add(eb); |
122 | 0 | eb = new ExtraButton(); |
123 | 0 | eb.setExtraButtonSource(krBaseUrl + "/images/tinybutton-filter.gif"); |
124 | 0 | eb.setExtraButtonOnclick("javascript: window.open('ActionListFilter.do?methodToCall=start');"); |
125 | 0 | headerButtons.add(eb); |
126 | |
|
127 | |
|
128 | 0 | return headerButtons; |
129 | |
} |
130 | |
|
131 | |
|
132 | |
|
133 | |
@Override |
134 | |
protected ActionForward defaultDispatch(ActionMapping mapping, |
135 | |
ActionForm form, HttpServletRequest request, |
136 | |
HttpServletResponse response) throws Exception { |
137 | 0 | return start(mapping, form, request, response); |
138 | |
} |
139 | |
|
140 | |
public ActionForward start(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { |
141 | 0 | PerformanceLogger plog = new PerformanceLogger(); |
142 | 0 | plog.log("Starting ActionList fetch"); |
143 | 0 | ActionListForm form = (ActionListForm) actionForm; |
144 | 0 | ActionListService actionListSrv = KEWServiceLocator.getActionListService(); |
145 | |
|
146 | |
|
147 | |
|
148 | 0 | Integer page = form.getPage(); |
149 | 0 | String sortCriterion = form.getSort(); |
150 | 0 | SortOrderEnum sortOrder = SortOrderEnum.ASCENDING; |
151 | 0 | final UserSession uSession = getUserSession(); |
152 | |
|
153 | 0 | if (form.getDir() != null) { |
154 | 0 | sortOrder = parseSortOrder(form.getDir()); |
155 | |
} |
156 | 0 | else if ( !StringUtils.isEmpty((String) uSession.retrieveObject(KEWConstants.SORT_ORDER_ATTR_NAME))) { |
157 | 0 | sortOrder = parseSortOrder((String) uSession.retrieveObject(KEWConstants.SORT_ORDER_ATTR_NAME)); |
158 | |
} |
159 | |
|
160 | 0 | if (page == null && sortCriterion == null) { |
161 | 0 | page = Integer.valueOf(1); |
162 | 0 | sortCriterion = ActionItemComparator.DOCUMENT_ID; |
163 | |
} |
164 | 0 | else if ( !StringUtils.isEmpty((String) uSession.retrieveObject(KEWConstants.SORT_CRITERIA_ATTR_NAME))) { |
165 | 0 | sortCriterion = (String) uSession.retrieveObject(KEWConstants.SORT_CRITERIA_ATTR_NAME); |
166 | |
} |
167 | |
|
168 | 0 | if (page == null) { |
169 | 0 | page = form.getCurrentPage(); |
170 | |
} |
171 | |
|
172 | |
|
173 | 0 | form.setCurrentPage(page); |
174 | 0 | if (!StringUtils.isEmpty(sortCriterion)) { |
175 | 0 | form.setCurrentSort(sortCriterion); |
176 | 0 | form.setCurrentDir(getSortOrderValue(sortOrder)); |
177 | |
} |
178 | |
|
179 | |
|
180 | 0 | form.setDefaultActionToTake("NONE"); |
181 | |
|
182 | 0 | boolean freshActionList = true; |
183 | |
|
184 | 0 | List actionList = (List)request.getSession().getAttribute(ACTION_LIST_KEY); |
185 | 0 | plog.log("Time to initialize"); |
186 | |
try { |
187 | |
|
188 | 0 | String principalId = null; |
189 | 0 | if (uSession.retrieveObject(KEWConstants.ACTION_LIST_FILTER_ATTR_NAME) == null) { |
190 | 0 | ActionListFilter filter = new ActionListFilter(); |
191 | 0 | filter.setDelegationType(DelegationType.SECONDARY.getCode()); |
192 | 0 | filter.setExcludeDelegationType(true); |
193 | 0 | uSession.addObject(KEWConstants.ACTION_LIST_FILTER_ATTR_NAME, filter); |
194 | |
} |
195 | |
|
196 | 0 | final ActionListFilter filter = (ActionListFilter) uSession.retrieveObject(KEWConstants.ACTION_LIST_FILTER_ATTR_NAME); |
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | 0 | boolean forceListRefresh = request.getSession().getAttribute(REQUERY_ACTION_LIST_KEY) != null; |
203 | 0 | if (uSession.retrieveObject(KEWConstants.HELP_DESK_ACTION_LIST_PRINCIPAL_ATTR_NAME) != null) { |
204 | 0 | principalId = ((PrincipalContract) uSession.retrieveObject(KEWConstants.HELP_DESK_ACTION_LIST_PRINCIPAL_ATTR_NAME)).getPrincipalId(); |
205 | |
} else { |
206 | 0 | if (!StringUtils.isEmpty(form.getDocType())) { |
207 | 0 | filter.setDocumentType(form.getDocType()); |
208 | 0 | filter.setExcludeDocumentType(false); |
209 | 0 | forceListRefresh = true; |
210 | |
} |
211 | 0 | principalId = uSession.getPerson().getPrincipalId(); |
212 | |
} |
213 | |
|
214 | 0 | final Preferences preferences = (Preferences) getUserSession().retrieveObject(KEWConstants.PREFERENCES); |
215 | |
|
216 | 0 | if (!StringUtils.isEmpty(form.getDelegationId())) { |
217 | 0 | if (!KEWConstants.DELEGATION_DEFAULT.equals(form.getDelegationId())) { |
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | 0 | if (StringUtils.isNotBlank(form.getPrimaryDelegateId()) && !KEWConstants.PRIMARY_DELEGATION_DEFAULT.equals(form.getPrimaryDelegateId())){ |
223 | 0 | if (form.getPrimaryDelegateId().equals(request.getParameter("oldPrimaryDelegateId")) && |
224 | |
!form.getDelegationId().equals(request.getParameter("oldDelegationId"))) { |
225 | 0 | form.setPrimaryDelegateId(KEWConstants.PRIMARY_DELEGATION_DEFAULT); |
226 | |
} else { |
227 | 0 | form.setDelegationId(KEWConstants.DELEGATION_DEFAULT); |
228 | |
} |
229 | 0 | } else if (StringUtils.isNotBlank(filter.getPrimaryDelegateId()) && |
230 | |
!KEWConstants.PRIMARY_DELEGATION_DEFAULT.equals(filter.getPrimaryDelegateId())) { |
231 | |
|
232 | |
|
233 | 0 | filter.setPrimaryDelegateId(KEWConstants.PRIMARY_DELEGATION_DEFAULT); |
234 | |
} |
235 | |
} |
236 | |
|
237 | 0 | filter.setDelegatorId(form.getDelegationId()); |
238 | 0 | filter.setExcludeDelegatorId(false); |
239 | 0 | actionList = null; |
240 | |
} |
241 | |
|
242 | 0 | if (!StringUtils.isEmpty(form.getPrimaryDelegateId())) { |
243 | |
|
244 | |
|
245 | 0 | if (StringUtils.isBlank(form.getDelegationId()) && !KEWConstants.PRIMARY_DELEGATION_DEFAULT.equals(form.getPrimaryDelegateId()) && |
246 | |
StringUtils.isNotBlank(filter.getDelegatorId()) && |
247 | |
!KEWConstants.DELEGATION_DEFAULT.equals(filter.getDelegatorId())) { |
248 | 0 | filter.setDelegatorId(KEWConstants.DELEGATION_DEFAULT); |
249 | |
} |
250 | |
|
251 | 0 | filter.setPrimaryDelegateId(form.getPrimaryDelegateId()); |
252 | 0 | filter.setExcludeDelegatorId(false); |
253 | 0 | actionList = null; |
254 | |
} |
255 | |
|
256 | |
|
257 | 0 | if (!principalId.equals(request.getSession().getAttribute(ACTION_LIST_USER_KEY))) { |
258 | 0 | actionList = null; |
259 | |
} |
260 | |
|
261 | 0 | if (isOutboxMode(form, request, preferences)) { |
262 | 0 | actionList = new ArrayList(actionListSrv.getOutbox(principalId, filter)); |
263 | 0 | form.setOutBoxEmpty(actionList.isEmpty()); |
264 | |
} else { |
265 | 0 | if (actionList == null) { |
266 | |
|
267 | 0 | actionListSrv.refreshActionList(getUserSession().getPerson().getPrincipalId()); |
268 | |
|
269 | 0 | actionList = new ArrayList(actionListSrv.getActionList(principalId, filter)); |
270 | 0 | request.getSession().setAttribute(ACTION_LIST_USER_KEY, principalId); |
271 | 0 | } else if (forceListRefresh) { |
272 | |
|
273 | 0 | actionList = new ArrayList(actionListSrv.getActionList(principalId, filter)); |
274 | 0 | request.getSession().setAttribute(ACTION_LIST_USER_KEY, principalId); |
275 | 0 | } else if (actionListSrv.refreshActionList(getUserSession().getPerson().getPrincipalId())) { |
276 | 0 | actionList = new ArrayList(actionListSrv.getActionList(principalId, filter)); |
277 | 0 | request.getSession().setAttribute(ACTION_LIST_USER_KEY, principalId); |
278 | |
} else { |
279 | 0 | Boolean update = (Boolean) uSession.retrieveObject(KEWConstants.UPDATE_ACTION_LIST_ATTR_NAME); |
280 | 0 | if (update == null || !update) { |
281 | 0 | freshActionList = false; |
282 | |
} |
283 | |
} |
284 | 0 | request.getSession().setAttribute(ACTION_LIST_KEY, actionList); |
285 | |
} |
286 | |
|
287 | 0 | request.getSession().setAttribute(REQUERY_ACTION_LIST_KEY, null); |
288 | |
|
289 | |
|
290 | 0 | if (KEWConstants.DELEGATORS_ON_ACTION_LIST_PAGE.equalsIgnoreCase(preferences.getDelegatorFilter())) { |
291 | 0 | Collection delegators = actionListSrv.findUserSecondaryDelegators(principalId); |
292 | 0 | form.setDelegators(ActionListUtil.getWebFriendlyRecipients(delegators)); |
293 | 0 | form.setDelegationId(filter.getDelegatorId()); |
294 | |
} |
295 | |
|
296 | |
|
297 | 0 | if (KEWConstants.PRIMARY_DELEGATES_ON_ACTION_LIST_PAGE.equalsIgnoreCase(preferences.getPrimaryDelegateFilter())) { |
298 | 0 | Collection<Recipient> pDelegates = actionListSrv.findUserPrimaryDelegations(principalId); |
299 | 0 | form.setPrimaryDelegates(ActionListUtil.getWebFriendlyRecipients(pDelegates)); |
300 | 0 | form.setPrimaryDelegateId(filter.getPrimaryDelegateId()); |
301 | |
} |
302 | |
|
303 | 0 | form.setFilterLegend(filter.getFilterLegend()); |
304 | 0 | plog.log("Setting attributes"); |
305 | |
|
306 | 0 | int pageSize = getPageSize(preferences); |
307 | |
|
308 | 0 | if (freshActionList) { |
309 | 0 | plog.log("calling initializeActionList"); |
310 | 0 | initializeActionList(actionList, preferences); |
311 | 0 | plog.log("done w/ initializeActionList"); |
312 | |
|
313 | |
|
314 | 0 | if (sortCriterion == null) { |
315 | 0 | sortCriterion = form.getCurrentSort(); |
316 | 0 | sortOrder = parseSortOrder(form.getCurrentDir()); |
317 | |
} |
318 | |
} |
319 | |
|
320 | 0 | if (sortCriterion != null) { |
321 | 0 | sortActionList(actionList, sortCriterion, sortOrder); |
322 | |
} |
323 | |
|
324 | 0 | plog.log("calling buildCurrentPage"); |
325 | 0 | PaginatedList currentPage = buildCurrentPage(actionList, form.getCurrentPage(), form.getCurrentSort(), |
326 | |
form.getCurrentDir(), pageSize, preferences, form); |
327 | 0 | plog.log("done w/ buildCurrentPage"); |
328 | 0 | request.setAttribute(ACTION_LIST_PAGE_KEY, currentPage); |
329 | 0 | uSession.addObject(KEWConstants.UPDATE_ACTION_LIST_ATTR_NAME, Boolean.FALSE); |
330 | 0 | uSession.addObject(KEWConstants.CURRENT_PAGE_ATTR_NAME, form.getCurrentPage()); |
331 | 0 | uSession.addObject(KEWConstants.SORT_CRITERIA_ATTR_NAME, form.getSort()); |
332 | 0 | uSession.addObject(KEWConstants.SORT_ORDER_ATTR_NAME, form.getCurrentDir()); |
333 | 0 | plog.log("finished setting attributes, finishing action list fetch"); |
334 | 0 | } catch (Exception e) { |
335 | 0 | LOG.error("Error loading action list.", e); |
336 | 0 | } |
337 | |
|
338 | 0 | LOG.debug("end start ActionListAction"); |
339 | 0 | return mapping.findForward("viewActionList"); |
340 | |
} |
341 | |
|
342 | |
private SortOrderEnum parseSortOrder(String dir) throws WorkflowException { |
343 | 0 | if ("asc".equals(dir)) { |
344 | 0 | return SortOrderEnum.ASCENDING; |
345 | 0 | } else if ("desc".equals(dir)) { |
346 | 0 | return SortOrderEnum.DESCENDING; |
347 | |
} |
348 | 0 | throw new WorkflowException("Invalid sort direction: " + dir); |
349 | |
} |
350 | |
|
351 | |
private String getSortOrderValue(SortOrderEnum sortOrder) { |
352 | 0 | if (SortOrderEnum.ASCENDING.equals(sortOrder)) { |
353 | 0 | return "asc"; |
354 | 0 | } else if (SortOrderEnum.DESCENDING.equals(sortOrder)) { |
355 | 0 | return "desc"; |
356 | |
} |
357 | 0 | return null; |
358 | |
} |
359 | |
|
360 | |
private static final String OUT_BOX_MODE = "_OUT_BOX_MODE"; |
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
private boolean isOutboxMode(ActionListForm alForm, HttpServletRequest request, Preferences preferences) { |
372 | |
|
373 | 0 | boolean outBoxView = false; |
374 | |
|
375 | 0 | if (! preferences.isUsingOutbox() || ! ConfigContext.getCurrentContextConfig().getOutBoxOn()) { |
376 | 0 | request.getSession().setAttribute(OUT_BOX_MODE, Boolean.valueOf(false)); |
377 | 0 | alForm.setViewOutbox("false"); |
378 | 0 | alForm.setShowOutbox(false); |
379 | 0 | return false; |
380 | |
} |
381 | |
|
382 | 0 | alForm.setShowOutbox(true); |
383 | 0 | if (StringUtils.isNotEmpty(alForm.getViewOutbox())) { |
384 | 0 | if (!Boolean.valueOf(alForm.getViewOutbox())) { |
385 | 0 | request.getSession().setAttribute(OUT_BOX_MODE, Boolean.valueOf(false)); |
386 | 0 | outBoxView = false; |
387 | |
} else { |
388 | 0 | request.getSession().setAttribute(OUT_BOX_MODE, Boolean.valueOf(true)); |
389 | 0 | outBoxView = true; |
390 | |
} |
391 | |
} else { |
392 | |
|
393 | 0 | if (request.getSession().getAttribute(OUT_BOX_MODE) == null) { |
394 | 0 | outBoxView = false; |
395 | |
} else { |
396 | 0 | outBoxView = (Boolean) request.getSession().getAttribute(OUT_BOX_MODE); |
397 | |
} |
398 | |
} |
399 | 0 | if (outBoxView) { |
400 | 0 | alForm.setViewOutbox("true"); |
401 | |
} else { |
402 | 0 | alForm.setViewOutbox("false"); |
403 | |
} |
404 | 0 | return outBoxView; |
405 | |
} |
406 | |
|
407 | |
private void sortActionList(List actionList, String sortName, SortOrderEnum sortOrder) { |
408 | 0 | if (StringUtils.isEmpty(sortName)) { |
409 | 0 | return; |
410 | |
} |
411 | 0 | Comparator comparator = new ActionItemComparator(sortName); |
412 | 0 | if (SortOrderEnum.DESCENDING.equals(sortOrder)) { |
413 | 0 | comparator = ComparatorUtils.reversedComparator(comparator); |
414 | |
} |
415 | 0 | Collections.sort(actionList, comparator); |
416 | |
|
417 | 0 | int index = 0; |
418 | 0 | for (Iterator iterator = actionList.iterator(); iterator.hasNext();) { |
419 | 0 | ActionItemActionListExtension actionItem = (ActionItemActionListExtension) iterator.next(); |
420 | 0 | actionItem.setActionItemIndex(Integer.valueOf(index++)); |
421 | 0 | } |
422 | 0 | } |
423 | |
|
424 | |
private void initializeActionList(List actionList, Preferences preferences) throws WorkflowException { |
425 | 0 | List actionItemProblemIds = new ArrayList(); |
426 | 0 | Map<String,DocumentRouteHeaderValue> routeHeaders = KEWServiceLocator.getRouteHeaderService().getRouteHeadersForActionItems(actionList); |
427 | |
|
428 | 0 | int index = 0; |
429 | 0 | generateActionItemErrors(actionList); |
430 | |
|
431 | 0 | for (Iterator iterator = actionList.iterator(); iterator.hasNext();) { |
432 | 0 | ActionItemActionListExtension actionItem = (ActionItemActionListExtension)iterator.next(); |
433 | 0 | if (actionItem.getDocumentId() == null) { |
434 | 0 | LOG.error("Somehow there exists an ActionItem with a null document id! actionItemId=" + actionItem.getActionItemId()); |
435 | 0 | iterator.remove(); |
436 | 0 | continue; |
437 | |
} |
438 | |
try { |
439 | 0 | actionItem.initialize(preferences); |
440 | 0 | DocumentRouteHeaderValue routeHeader = routeHeaders.get(actionItem.getDocumentId()); |
441 | |
|
442 | 0 | DocumentRouteHeaderValueActionListExtension routeHeaderExtension = toDocumentRouteHeaderValueActionListExtension(routeHeader); |
443 | 0 | routeHeaderExtension.setActionListInitiatorPrincipal(routeHeaderExtension.getInitiatorPrincipal()); |
444 | 0 | actionItem.setActionItemIndex(Integer.valueOf(index)); |
445 | 0 | actionItem.setRouteHeader(routeHeaderExtension); |
446 | |
|
447 | 0 | if (KEWConstants.ROUTE_HEADER_CANCEL_CD.equalsIgnoreCase(routeHeader.getDocRouteStatus())) { |
448 | 0 | actionItem.setRowStyleClass(KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorCanceled())); |
449 | 0 | } else if (KEWConstants.ROUTE_HEADER_DISAPPROVED_CD.equalsIgnoreCase(routeHeader.getDocRouteStatus())) { |
450 | 0 | actionItem.setRowStyleClass(KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorDissaproved())); |
451 | 0 | } else if (KEWConstants.ROUTE_HEADER_ENROUTE_CD.equalsIgnoreCase(routeHeader.getDocRouteStatus())) { |
452 | 0 | actionItem.setRowStyleClass(KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorEnroute())); |
453 | 0 | } else if (KEWConstants.ROUTE_HEADER_EXCEPTION_CD.equalsIgnoreCase(routeHeader.getDocRouteStatus())) { |
454 | 0 | actionItem.setRowStyleClass(KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorException())); |
455 | 0 | } else if (KEWConstants.ROUTE_HEADER_FINAL_CD.equalsIgnoreCase(routeHeader.getDocRouteStatus())) { |
456 | 0 | actionItem.setRowStyleClass(KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorFinal())); |
457 | 0 | } else if (KEWConstants.ROUTE_HEADER_INITIATED_CD.equalsIgnoreCase(routeHeader.getDocRouteStatus())) { |
458 | 0 | actionItem.setRowStyleClass(KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorInitiated())); |
459 | 0 | } else if (KEWConstants.ROUTE_HEADER_PROCESSED_CD.equalsIgnoreCase(routeHeader.getDocRouteStatus())) { |
460 | 0 | actionItem.setRowStyleClass(KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorProccessed())); |
461 | 0 | } else if (KEWConstants.ROUTE_HEADER_SAVED_CD.equalsIgnoreCase(routeHeader.getDocRouteStatus())) { |
462 | 0 | actionItem.setRowStyleClass(KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorSaved())); |
463 | |
} |
464 | 0 | index++; |
465 | 0 | } catch (Exception e) { |
466 | |
|
467 | |
|
468 | 0 | LOG.error("Error loading action list for action item " + actionItem.getActionItemId(), e); |
469 | 0 | iterator.remove(); |
470 | 0 | actionItemProblemIds.add(actionItem.getDocumentId()); |
471 | 0 | } |
472 | 0 | } |
473 | 0 | generateActionItemErrors(ACTIONITEM_PROP, ACTIONLIST_BAD_ACTION_ITEMS_ERRKEY, actionItemProblemIds); |
474 | 0 | } |
475 | |
|
476 | |
private DocumentRouteHeaderValueActionListExtension toDocumentRouteHeaderValueActionListExtension( |
477 | |
DocumentRouteHeaderValue routeHeader) { |
478 | |
|
479 | 0 | if(routeHeader==null){ |
480 | 0 | return null; |
481 | |
} |
482 | |
|
483 | 0 | DocumentRouteHeaderValueActionListExtension extension = new DocumentRouteHeaderValueActionListExtension(); |
484 | |
|
485 | 0 | extension.setDocumentId(routeHeader.getDocumentId()); |
486 | 0 | extension.setDocumentTypeId(routeHeader.getDocumentTypeId()); |
487 | 0 | extension.setDocRouteStatus(routeHeader.getDocRouteStatus()); |
488 | 0 | extension.setDocRouteLevel(routeHeader.getDocRouteLevel()); |
489 | 0 | extension.setStatusModDate(routeHeader.getStatusModDate()); |
490 | 0 | extension.setCreateDate(routeHeader.getCreateDate()); |
491 | 0 | extension.setApprovedDate(routeHeader.getApprovedDate()); |
492 | 0 | extension.setFinalizedDate(routeHeader.getFinalizedDate()); |
493 | 0 | extension.setRouteStatusDate(routeHeader.getRouteStatusDate()); |
494 | 0 | extension.setRouteLevelDate(routeHeader.getRouteLevelDate()); |
495 | 0 | extension.setDocTitle(routeHeader.getDocTitle()); |
496 | 0 | extension.setAppDocId(routeHeader.getAppDocId()); |
497 | 0 | extension.setDocVersion(routeHeader.getDocVersion()); |
498 | 0 | extension.setInitiatorWorkflowId(routeHeader.getInitiatorWorkflowId()); |
499 | 0 | extension.setVersionNumber(routeHeader.getVersionNumber()); |
500 | 0 | extension.setAppDocStatus(routeHeader.getAppDocStatus()); |
501 | 0 | extension.setAppDocStatusDate(routeHeader.getAppDocStatusDate()); |
502 | |
|
503 | 0 | return extension; |
504 | |
} |
505 | |
|
506 | |
|
507 | |
|
508 | |
|
509 | |
|
510 | |
protected int getPageSize(Preferences preferences) { |
511 | 0 | return Integer.parseInt(preferences.getPageSize()); |
512 | |
} |
513 | |
|
514 | |
protected PaginatedList buildCurrentPage(List actionList, Integer page, String sortCriterion, String sortDirection, |
515 | |
int pageSize, Preferences preferences, ActionListForm form) throws WorkflowException { |
516 | 0 | List currentPage = new ArrayList(pageSize); |
517 | 0 | boolean haveFyis = false; |
518 | 0 | boolean haveApproves = false; |
519 | 0 | boolean haveAcknowledges = false; |
520 | 0 | boolean haveCancels = false; |
521 | 0 | boolean haveDisapproves = false; |
522 | 0 | boolean haveCustomActions = false; |
523 | 0 | boolean haveDisplayParameters = false; |
524 | 0 | List customActionListProblemIds = new ArrayList(); |
525 | 0 | SortOrderEnum sortOrder = parseSortOrder(sortDirection); |
526 | 0 | int startIndex = (page.intValue() - 1) * pageSize; |
527 | 0 | int endIndex = startIndex + pageSize; |
528 | 0 | generateActionItemErrors(actionList); |
529 | 0 | Map<String,DocumentRouteHeaderValue> routeHeaders = KEWServiceLocator.getRouteHeaderService().getRouteHeadersForActionItems(actionList); |
530 | 0 | for (int index = startIndex; index < endIndex && index < actionList.size(); index++) { |
531 | 0 | ActionItemActionListExtension actionItem = (ActionItemActionListExtension)actionList.get(index); |
532 | |
|
533 | |
try { |
534 | 0 | boolean itemHasApproves = false; |
535 | 0 | boolean itemHasDisapproves = false; |
536 | 0 | boolean itemHasCancels = false; |
537 | 0 | boolean itemHasAcknowledges = false; |
538 | 0 | boolean itemHasFyis = false; |
539 | 0 | boolean itemHasCustomActions = false; |
540 | 0 | CustomActionListAttribute customActionListAttribute = routeHeaders.get(actionItem.getDocumentId()).getCustomActionListAttribute(); |
541 | 0 | if (customActionListAttribute != null) { |
542 | 0 | Map customActions = new LinkedHashMap(); |
543 | 0 | customActions.put("NONE", "NONE"); |
544 | 0 | ActionSet legalActions = customActionListAttribute.getLegalActions(getUserSession().getPrincipalId(), actionItem); |
545 | 0 | if (legalActions != null && legalActions.hasApprove() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_APPROVED_CD)) { |
546 | 0 | customActions.put(KEWConstants.ACTION_TAKEN_APPROVED_CD, KEWConstants.ACTION_REQUEST_APPROVE_REQ_LABEL); |
547 | 0 | itemHasApproves = true; |
548 | |
} |
549 | 0 | if (legalActions != null && legalActions.hasDisapprove() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_DENIED_CD)) { |
550 | 0 | customActions.put(KEWConstants.ACTION_TAKEN_DENIED_CD, KEWConstants.ACTION_REQUEST_DISAPPROVE_LABEL); |
551 | 0 | itemHasDisapproves = true; |
552 | |
} |
553 | 0 | if (legalActions != null && legalActions.hasCancel() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_CANCELED_CD)) { |
554 | 0 | customActions.put(KEWConstants.ACTION_TAKEN_CANCELED_CD, KEWConstants.ACTION_REQUEST_CANCEL_REQ_LABEL); |
555 | 0 | itemHasCancels = true; |
556 | |
} |
557 | 0 | if (legalActions != null && legalActions.hasAcknowledge() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD)) { |
558 | 0 | customActions.put(KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD, KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL); |
559 | 0 | itemHasAcknowledges = true; |
560 | |
} |
561 | 0 | if (legalActions != null && legalActions.hasFyi() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_FYI_CD) && KEWConstants.PREFERENCES_YES_VAL.equalsIgnoreCase(preferences.getShowClearFyi())) { |
562 | 0 | customActions.put(KEWConstants.ACTION_TAKEN_FYI_CD, KEWConstants.ACTION_REQUEST_FYI_REQ_LABEL); |
563 | 0 | itemHasFyis = true; |
564 | |
} |
565 | 0 | if (customActions.size() > 1) { |
566 | 0 | actionItem.setCustomActions(customActions); |
567 | 0 | itemHasCustomActions = true; |
568 | |
} |
569 | 0 | actionItem.setDisplayParameters(customActionListAttribute.getDocHandlerDisplayParameters(getUserSession().getPrincipalId(), actionItem)); |
570 | 0 | haveApproves = haveApproves || itemHasApproves; |
571 | 0 | haveAcknowledges = haveAcknowledges || itemHasAcknowledges; |
572 | 0 | haveFyis = haveFyis || itemHasFyis; |
573 | 0 | haveDisapproves = haveDisapproves || itemHasDisapproves; |
574 | 0 | haveCancels = haveCancels || itemHasCancels; |
575 | 0 | haveCustomActions = haveCustomActions || itemHasCustomActions; |
576 | 0 | haveDisplayParameters = haveDisplayParameters || (actionItem.getDisplayParameters() != null); |
577 | |
} |
578 | 0 | } catch (Exception e) { |
579 | |
|
580 | 0 | LOG.error("Problem loading custom action list attribute", e); |
581 | 0 | customActionListProblemIds.add(actionItem.getDocumentId()); |
582 | 0 | } |
583 | 0 | currentPage.add(actionItem); |
584 | |
} |
585 | |
|
586 | |
|
587 | 0 | form.setHasCustomActions(Boolean.valueOf(haveCustomActions)); |
588 | 0 | Map defaultActions = new LinkedHashMap(); |
589 | 0 | defaultActions.put("NONE", "NONE"); |
590 | 0 | if (haveApproves) { |
591 | 0 | defaultActions.put(KEWConstants.ACTION_TAKEN_APPROVED_CD, KEWConstants.ACTION_REQUEST_APPROVE_REQ_LABEL); |
592 | 0 | form.setCustomActionList(Boolean.TRUE); |
593 | |
} |
594 | 0 | if (haveDisapproves) { |
595 | 0 | defaultActions.put(KEWConstants.ACTION_TAKEN_DENIED_CD, KEWConstants.ACTION_REQUEST_DISAPPROVE_LABEL); |
596 | 0 | form.setCustomActionList(Boolean.TRUE); |
597 | |
} |
598 | 0 | if (haveCancels) { |
599 | 0 | defaultActions.put(KEWConstants.ACTION_TAKEN_CANCELED_CD, KEWConstants.ACTION_REQUEST_CANCEL_REQ_LABEL); |
600 | 0 | form.setCustomActionList(Boolean.TRUE); |
601 | |
} |
602 | 0 | if (haveAcknowledges) { |
603 | 0 | defaultActions.put(KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD, KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL); |
604 | 0 | form.setCustomActionList(Boolean.TRUE); |
605 | |
} |
606 | |
|
607 | 0 | if (haveFyis && KEWConstants.PREFERENCES_YES_VAL.equalsIgnoreCase(preferences.getShowClearFyi())) { |
608 | 0 | defaultActions.put(KEWConstants.ACTION_TAKEN_FYI_CD, KEWConstants.ACTION_REQUEST_FYI_REQ_LABEL); |
609 | |
} |
610 | 0 | if (defaultActions.size() > 1) { |
611 | 0 | form.setDefaultActions(defaultActions); |
612 | |
} |
613 | |
|
614 | 0 | form.setHasDisplayParameters(haveDisplayParameters); |
615 | |
|
616 | 0 | generateActionItemErrors(CUSTOMACTIONLIST_PROP, ACTIONLIST_BAD_CUSTOM_ACTION_LIST_ITEMS_ERRKEY, customActionListProblemIds); |
617 | 0 | return new PaginatedActionList(currentPage, actionList.size(), page.intValue(), pageSize, "actionList", sortCriterion, sortOrder); |
618 | |
} |
619 | |
|
620 | |
private void generateActionItemErrors(String propertyName, String errorKey, List documentIds) { |
621 | 0 | if (!documentIds.isEmpty()) { |
622 | 0 | String documentIdsString = StringUtils.join(documentIds.iterator(), ", "); |
623 | 0 | GlobalVariables.getMessageMap().putError(propertyName, errorKey, documentIdsString); |
624 | |
} |
625 | 0 | } |
626 | |
|
627 | |
private void generateActionItemErrors(List actionList) { |
628 | 0 | for (Iterator iterator = actionList.iterator(); iterator.hasNext();) { |
629 | 0 | ActionItemActionListExtension actionItem = (ActionItemActionListExtension)iterator.next(); |
630 | |
|
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | 0 | if(!KEWConstants.ACTION_REQUEST_CODES.containsKey(actionItem.getActionRequestCd())) { |
637 | 0 | GlobalVariables.getMessageMap().putError(ACTIONREQUESTCD_PROP,ACTIONITEM_ACTIONREQUESTCD_INVALID_ERRKEY,actionItem.getActionItemId()+""); |
638 | |
} |
639 | 0 | } |
640 | 0 | } |
641 | |
|
642 | |
|
643 | |
public ActionForward takeMassActions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
644 | 0 | ActionListForm actionListForm = (ActionListForm) form; |
645 | 0 | List actionList = (List) request.getSession().getAttribute(ACTION_LIST_KEY); |
646 | 0 | if (actionList == null) { |
647 | 0 | return start(mapping, new ActionListForm(), request, response); |
648 | |
} |
649 | 0 | ActionMessages messages = new ActionMessages(); |
650 | 0 | List invocations = new ArrayList(); |
651 | 0 | int index = 0; |
652 | 0 | for (Object element : actionListForm.getActionsToTake()) { |
653 | 0 | ActionToTake actionToTake = (ActionToTake) element; |
654 | 0 | if (actionToTake != null && actionToTake.getActionTakenCd() != null && |
655 | |
!"".equals(actionToTake.getActionTakenCd()) && |
656 | |
!"NONE".equalsIgnoreCase(actionToTake.getActionTakenCd()) && |
657 | |
actionToTake.getActionItemId() != null) { |
658 | 0 | ActionItem actionItem = getActionItemFromActionList(actionList, actionToTake.getActionItemId()); |
659 | 0 | if (actionItem == null) { |
660 | 0 | LOG.warn("Could not locate the ActionItem to take mass action against in the action list: " + actionToTake.getActionItemId()); |
661 | 0 | continue; |
662 | |
} |
663 | 0 | invocations.add(new ActionInvocation(actionItem.getActionItemId(), actionToTake.getActionTakenCd())); |
664 | |
} |
665 | 0 | index++; |
666 | 0 | } |
667 | 0 | KEWServiceLocator.getWorkflowDocumentService().takeMassActions(getUserSession().getPrincipalId(), invocations); |
668 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.routing.processed")); |
669 | 0 | saveMessages(request, messages); |
670 | 0 | ActionListForm cleanForm = new ActionListForm(); |
671 | 0 | request.setAttribute(mapping.getName(), cleanForm); |
672 | 0 | request.getSession().setAttribute(REQUERY_ACTION_LIST_KEY, "true"); |
673 | 0 | return start(mapping, cleanForm, request, response); |
674 | |
} |
675 | |
|
676 | |
protected ActionItem getActionItemFromActionList(List<ActionItem> actionList, String actionItemId) { |
677 | 0 | for (ActionItem actionItem : actionList) { |
678 | 0 | if (actionItem.getActionItemId().equals(actionItemId)) { |
679 | 0 | return actionItem; |
680 | |
} |
681 | |
} |
682 | 0 | return null; |
683 | |
} |
684 | |
|
685 | |
public ActionForward helpDeskActionListLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
686 | 0 | ActionListForm actionListForm = (ActionListForm) form; |
687 | 0 | String name = actionListForm.getHelpDeskActionListUserName(); |
688 | 0 | if (!"true".equals(request.getAttribute("helpDeskActionList"))) { |
689 | 0 | throw new AuthorizationException(getUserSession().getPrincipalId(), "helpDeskActionListLogin", getClass().getSimpleName()); |
690 | |
} |
691 | |
try |
692 | |
{ |
693 | 0 | final Principal helpDeskActionListPrincipal = KEWServiceLocator.getIdentityHelperService().getPrincipalByPrincipalName(name); |
694 | 0 | final Person helpDeskActionListPerson = KEWServiceLocator.getIdentityHelperService().getPersonByPrincipalName(name); |
695 | |
|
696 | 0 | GlobalVariables.getUserSession().addObject(KEWConstants.HELP_DESK_ACTION_LIST_PRINCIPAL_ATTR_NAME, helpDeskActionListPrincipal); |
697 | 0 | GlobalVariables.getUserSession().addObject(KEWConstants.HELP_DESK_ACTION_LIST_PERSON_ATTR_NAME, helpDeskActionListPerson); |
698 | |
} |
699 | 0 | catch (RiceRuntimeException rre) |
700 | |
{ |
701 | 0 | GlobalVariables.getMessageMap().putError(HELPDESK_ACTIONLIST_USERNAME, HELPDESK_LOGIN_INVALID_ERRKEY, name); |
702 | |
} |
703 | 0 | catch (RiceIllegalArgumentException e) { |
704 | 0 | GlobalVariables.getMessageMap().putError(HELPDESK_ACTIONLIST_USERNAME, HELPDESK_LOGIN_INVALID_ERRKEY, name); |
705 | |
} |
706 | 0 | catch (NullPointerException npe) |
707 | |
{ |
708 | 0 | GlobalVariables.getMessageMap().putError("null", HELPDESK_LOGIN_EMPTY_ERRKEY, name); |
709 | 0 | } |
710 | 0 | actionListForm.setDelegator(null); |
711 | 0 | request.getSession().setAttribute(REQUERY_ACTION_LIST_KEY, "true"); |
712 | 0 | return start(mapping, form, request, response); |
713 | |
} |
714 | |
|
715 | |
public ActionForward clearFilter(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
716 | 0 | LOG.debug("clearFilter ActionListAction"); |
717 | 0 | final org.kuali.rice.krad.UserSession commonUserSession = getUserSession(); |
718 | 0 | commonUserSession.removeObject(KEWConstants.ACTION_LIST_FILTER_ATTR_NAME); |
719 | 0 | request.getSession().setAttribute(REQUERY_ACTION_LIST_KEY, "true"); |
720 | 0 | KEWServiceLocator.getActionListService().saveRefreshUserOption(commonUserSession.getPrincipalId()); |
721 | 0 | LOG.debug("end clearFilter ActionListAction"); |
722 | 0 | return start(mapping, form, request, response); |
723 | |
} |
724 | |
|
725 | |
public ActionForward clearHelpDeskActionListUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
726 | 0 | LOG.debug("clearHelpDeskActionListUser ActionListAction"); |
727 | 0 | GlobalVariables.getUserSession().removeObject(KEWConstants.HELP_DESK_ACTION_LIST_PRINCIPAL_ATTR_NAME); |
728 | 0 | GlobalVariables.getUserSession().removeObject(KEWConstants.HELP_DESK_ACTION_LIST_PERSON_ATTR_NAME); |
729 | 0 | LOG.debug("end clearHelpDeskActionListUser ActionListAction"); |
730 | 0 | return start(mapping, form, request, response); |
731 | |
} |
732 | |
|
733 | |
|
734 | |
|
735 | |
|
736 | |
public ActionForward count(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
737 | 0 | ActionListForm alForm = (ActionListForm)form; |
738 | 0 | Person user = getUserSession().getPerson(); |
739 | 0 | alForm.setCount(KEWServiceLocator.getActionListService().getCount(user.getPrincipalId())); |
740 | 0 | LOG.info("Fetched Action List count of " + alForm.getCount() + " for user " + user.getPrincipalName()); |
741 | 0 | return mapping.findForward("count"); |
742 | |
} |
743 | |
|
744 | |
public ActionForward removeOutboxItems(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
745 | 0 | ActionListForm alForm = (ActionListForm)form; |
746 | 0 | if (alForm.getOutboxItems() != null) { |
747 | 0 | KEWServiceLocator.getActionListService().removeOutboxItems(getUserSession().getPrincipalId(), Arrays.asList(alForm.getOutboxItems())); |
748 | |
} |
749 | |
|
750 | 0 | alForm.setViewOutbox("true"); |
751 | 0 | return start(mapping, form, request, response); |
752 | |
} |
753 | |
|
754 | |
|
755 | |
|
756 | |
|
757 | |
public ActionForward viewFilter(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { |
758 | 0 | start(mapping, actionForm, request, response); |
759 | 0 | return mapping.findForward("viewFilter"); |
760 | |
} |
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
public ActionForward viewPreferences(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { |
766 | 0 | start(mapping, actionForm, request, response); |
767 | 0 | return mapping.findForward("viewPreferences"); |
768 | |
} |
769 | |
|
770 | |
private boolean isActionCompatibleRequest(ActionItemActionListExtension actionItem, String actionTakenCode) { |
771 | 0 | boolean actionCompatible = false; |
772 | 0 | String requestCd = actionItem.getActionRequestCd(); |
773 | |
|
774 | |
|
775 | 0 | if (KEWConstants.ACTION_REQUEST_FYI_REQ.equals(requestCd) && KEWConstants.ACTION_TAKEN_FYI_CD.equals(actionTakenCode)) { |
776 | 0 | actionCompatible = true || actionCompatible; |
777 | |
} |
778 | |
|
779 | |
|
780 | 0 | if (KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ.equals(requestCd) && KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD.equals(actionTakenCode)) { |
781 | 0 | actionCompatible = true || actionCompatible; |
782 | |
} |
783 | |
|
784 | |
|
785 | 0 | if (KEWConstants.ACTION_REQUEST_APPROVE_REQ.equals(requestCd) && !(KEWConstants.ACTION_TAKEN_FYI_CD.equals(actionTakenCode) || KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD.equals(actionTakenCode))) { |
786 | 0 | actionCompatible = true || actionCompatible; |
787 | |
} |
788 | |
|
789 | |
|
790 | 0 | if (KEWConstants.ACTION_REQUEST_COMPLETE_REQ.equals(requestCd) && !(KEWConstants.ACTION_TAKEN_FYI_CD.equals(actionTakenCode) || KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD.equals(actionTakenCode))) { |
791 | 0 | actionCompatible = true || actionCompatible; |
792 | |
} |
793 | |
|
794 | 0 | return actionCompatible; |
795 | |
} |
796 | |
|
797 | |
private UserSession getUserSession(){ |
798 | 0 | return GlobalVariables.getUserSession(); |
799 | |
} |
800 | |
|
801 | 0 | private static class ActionItemComparator implements Comparator<ActionItem> { |
802 | |
|
803 | |
private static final String DOCUMENT_ID = "documentId"; |
804 | |
|
805 | |
private final String sortName; |
806 | |
|
807 | 0 | public ActionItemComparator(String sortName) { |
808 | 0 | if (StringUtils.isEmpty(sortName)) { |
809 | 0 | sortName = DOCUMENT_ID; |
810 | |
} |
811 | 0 | this.sortName = sortName; |
812 | 0 | } |
813 | |
|
814 | |
@Override |
815 | |
public int compare(ActionItem object1, ActionItem object2) { |
816 | |
try { |
817 | 0 | ActionItem actionItem1 = object1; |
818 | 0 | ActionItem actionItem2 = object2; |
819 | |
|
820 | |
|
821 | |
|
822 | 0 | Object property1 = LookupUtil.getProperty(actionItem1, sortName); |
823 | 0 | Object property2 = LookupUtil.getProperty(actionItem2, sortName); |
824 | 0 | if (property1 == null && property2 == null) { |
825 | 0 | return 0; |
826 | 0 | } else if (property1 == null) { |
827 | 0 | return -1; |
828 | 0 | } else if (property2 == null) { |
829 | 0 | return 1; |
830 | |
} |
831 | 0 | if (property1 instanceof Comparable) { |
832 | 0 | return ((Comparable)property1).compareTo(property2); |
833 | |
} |
834 | 0 | return property1.toString().compareTo(property2.toString()); |
835 | 0 | } catch (Exception e) { |
836 | 0 | if (e instanceof RuntimeException) { |
837 | 0 | throw (RuntimeException) e; |
838 | |
} |
839 | 0 | throw new RuntimeException("Could not sort for the given sort name: " + sortName, e); |
840 | |
} |
841 | |
} |
842 | |
} |
843 | |
|
844 | |
} |