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.kuali.hr.time.authorization.TkAuthorizedLookupableHelperBase;
22 import org.kuali.hr.time.service.base.TkServiceLocator;
23 import org.kuali.hr.time.util.TKUtils;
24 import org.kuali.rice.kns.document.authorization.BusinessObjectRestrictions;
25 import org.kuali.rice.kns.lookup.HtmlData;
26 import org.kuali.rice.kns.web.struts.form.LookupForm;
27 import org.kuali.rice.kns.web.ui.Field;
28 import org.kuali.rice.kns.web.ui.Row;
29 import org.kuali.rice.krad.bo.BusinessObject;
30
31 public class TaskLookupableHelper extends TkAuthorizedLookupableHelperBase {
32
33 private static final long serialVersionUID = 7525044777337159013L;
34
35 @Override
36 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
37 String task = fieldValues.get("task");
38 String description = fieldValues.get("description");
39 String workArea = fieldValues.get("workArea");
40 String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
41 String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
42
43 return TkServiceLocator.getTaskService().getTasks(task, description, workArea, TKUtils.formatDateString(fromEffdt), TKUtils.formatDateString(toEffdt));
44 }
45
46 @SuppressWarnings("rawtypes")
47 @Override
48 public HtmlData getReturnUrl(BusinessObject businessObject,
49 LookupForm lookupForm, List returnKeys,
50 BusinessObjectRestrictions businessObjectRestrictions) {
51 if (lookupForm.getFieldConversions().containsKey("effectiveDate")) {
52 lookupForm.getFieldConversions().remove("effectiveDate");
53 }
54 if (returnKeys.contains("effectiveDate")) {
55 returnKeys.remove("effectiveDate");
56 }
57 if (lookupForm.getFieldConversions().containsKey("workArea")) {
58 lookupForm.getFieldConversions().remove("workArea");
59 }
60 if (returnKeys.contains("workArea")) {
61 returnKeys.remove("workArea");
62 }
63
64 return super.getReturnUrl(businessObject, lookupForm, returnKeys,
65 businessObjectRestrictions);
66 }
67
68 @Override
69
70 public List<Row> getRows() {
71 List<Row> rowList = super.getRows();
72 for (Row aRow : rowList) {
73 List<Field> fields = aRow.getFields();
74 for (Field aField : fields) {
75 if (aField.getFieldLabel() != null && aField.getFieldLabel().equals("Task")) {
76 if (aField.getPropertyValue() != null && aField.getPropertyValue().equals("0")) {
77 aField.setPropertyValue("");
78 }
79 }
80 }
81 }
82 return rowList;
83 }
84
85 @Override
86 public boolean shouldShowBusinessObject(BusinessObject bo) {
87 return true;
88 }
89 }