1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.rules.clocklocation.web;
17
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Properties;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.kpme.core.lookup.KPMELookupableHelper;
24 import org.kuali.kpme.core.util.TKUtils;
25 import org.kuali.kpme.tklm.time.rules.clocklocation.ClockLocationRule;
26 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
27 import org.kuali.rice.kns.lookup.HtmlData;
28 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
29 import org.kuali.rice.krad.bo.BusinessObject;
30 import org.kuali.rice.krad.util.GlobalVariables;
31 import org.kuali.rice.krad.util.KRADConstants;
32 import org.kuali.rice.krad.util.UrlFactory;
33
34 @SuppressWarnings("deprecation")
35 public class ClockLocationRuleLookupableHelper extends KPMELookupableHelper {
36
37 private static final long serialVersionUID = 7261054962204557586L;
38
39 @Override
40 @SuppressWarnings("rawtypes")
41 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
42 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
43
44 ClockLocationRule clockLocationRule = (ClockLocationRule) businessObject;
45 String tkClockLocationRuleId = clockLocationRule.getTkClockLocationRuleId();
46
47 Properties params = new Properties();
48 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
49 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
50 params.put("tkClockLocationRuleId", tkClockLocationRuleId);
51 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
52 viewUrl.setDisplayText("view");
53 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
54 customActionUrls.add(viewUrl);
55
56 return customActionUrls;
57 }
58
59 @Override
60 protected void validateSearchParameterWildcardAndOperators(
61 String attributeName, String attributeValue) {
62 if (!StringUtils.equals(attributeValue, "%")) {
63 super.validateSearchParameterWildcardAndOperators(attributeName,
64 attributeValue);
65 }
66 }
67
68 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
69 String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
70 String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
71 String principalId = fieldValues.get("principalId");
72 String jobNumber = fieldValues.get("jobNumber");
73 String dept = fieldValues.get("dept");
74 String workArea = fieldValues.get("workArea");
75 String active = fieldValues.get("active");
76 String showHist = fieldValues.get("history");
77
78 if (StringUtils.contains(workArea, "%")) {
79 workArea = "";
80 }
81
82 if (StringUtils.contains(jobNumber, "%")) {
83 jobNumber = "";
84 }
85
86
87 return TkServiceLocator.getClockLocationRuleService().getClockLocationRules(GlobalVariables.getUserSession().getPrincipalId(), TKUtils.formatDateString(fromEffdt), TKUtils.formatDateString(toEffdt),
88 principalId, jobNumber, dept, workArea, active, showHist);
89 }
90
91 }