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