1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.task.service;
17
18 import java.util.List;
19 import java.util.Map;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.hr.time.authorization.TkAuthorizedLookupableHelperBase;
23 import org.kuali.hr.time.service.base.TkServiceLocator;
24 import org.kuali.hr.time.task.Task;
25 import org.kuali.hr.time.util.TKUtils;
26 import org.kuali.rice.kns.document.authorization.BusinessObjectRestrictions;
27 import org.kuali.rice.kns.lookup.HtmlData;
28 import org.kuali.rice.kns.web.struts.form.LookupForm;
29 import org.kuali.rice.kns.web.ui.Field;
30 import org.kuali.rice.kns.web.ui.Row;
31 import org.kuali.rice.krad.bo.BusinessObject;
32
33 public class TaskLookupableHelper extends TkAuthorizedLookupableHelperBase {
34
35
36
37 private static final long serialVersionUID = 1L;
38
39 @SuppressWarnings({"unchecked"})
40 @Override
41 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
42
43 String task = fieldValues.get("task");
44 String description = fieldValues.get("description");
45 String workArea = fieldValues.get("workArea");
46 String workAreaDescription = fieldValues.get("workAreaDescription");
47 String fromEffdt = fieldValues.get("rangeLowerBoundKeyPrefix_effectiveDate");
48 String toEffdt = StringUtils.isNotBlank(fieldValues.get("effectiveDate")) ? fieldValues.get("effectiveDate").replace("<=", "") : "";
49
50 List<Task> tasks = TkServiceLocator.getTaskService().getTasks(task, description, workArea, workAreaDescription,
51 TKUtils.formatDateString(fromEffdt), TKUtils.formatDateString(toEffdt));
52
53 return tasks;
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 }
86
87 @SuppressWarnings("rawtypes")
88 @Override
89 public HtmlData getReturnUrl(BusinessObject businessObject,
90 LookupForm lookupForm, List returnKeys,
91 BusinessObjectRestrictions businessObjectRestrictions) {
92 if (lookupForm.getFieldConversions().containsKey("effectiveDate")) {
93 lookupForm.getFieldConversions().remove("effectiveDate");
94 }
95 if (returnKeys.contains("effectiveDate")) {
96 returnKeys.remove("effectiveDate");
97 }
98 if (lookupForm.getFieldConversions().containsKey("workArea")) {
99 lookupForm.getFieldConversions().remove("workArea");
100 }
101 if (returnKeys.contains("workArea")) {
102 returnKeys.remove("workArea");
103 }
104
105 return super.getReturnUrl(businessObject, lookupForm, returnKeys,
106 businessObjectRestrictions);
107 }
108
109 @Override
110
111 public List<Row> getRows() {
112 List<Row> rowList = super.getRows();
113 for (Row aRow : rowList) {
114 List<Field> fields = aRow.getFields();
115 for (Field aField : fields) {
116 if (aField.getFieldLabel() != null && aField.getFieldLabel().equals("Task")) {
117 if (aField.getPropertyValue() != null && aField.getPropertyValue().equals("0")) {
118 aField.setPropertyValue("");
119 }
120 }
121 }
122 }
123 return rowList;
124 }
125
126 @Override
127 public boolean shouldShowBusinessObject(BusinessObject bo) {
128 return true;
129 }
130 }