1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.rules.lunch.department.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.KPMELookupableHelperServiceImpl;
24 import org.kuali.kpme.core.util.TKUtils;
25 import org.kuali.kpme.tklm.time.rules.lunch.department.DeptLunchRule;
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 DepartmentLunchRuleLookupableHelperServiceImpl extends KPMELookupableHelperServiceImpl {
36
37 private static final long serialVersionUID = -6171434403261481651L;
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 DeptLunchRule deptLunchRule = (DeptLunchRule) businessObject;
45 String tkDeptLunchRuleId = deptLunchRule.getTkDeptLunchRuleId();
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("tkDeptLunchRuleId", tkDeptLunchRuleId);
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 @Override
69 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
70 String principalId = fieldValues.get("principalId");
71 String jobNumber = fieldValues.get("jobNumber");
72 String dept = fieldValues.get("dept");
73 String workArea = fieldValues.get("workArea");
74 String active = fieldValues.get("active");
75 String history = fieldValues.get("history");
76 String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
77 String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
78
79 if (StringUtils.equals(workArea,"%") || StringUtils.equals(workArea,"*")){
80 workArea = "";
81 }
82
83 if (StringUtils.equals(jobNumber,"%") || StringUtils.equals(jobNumber,"*")){
84 jobNumber = "";
85 }
86
87
88 if (StringUtils.equals(dept,"%") || StringUtils.equals(dept,"*")){
89 dept = "";
90 }
91
92 return TkServiceLocator.getDepartmentLunchRuleService().getDepartmentLunchRules(GlobalVariables.getUserSession().getPrincipalId(), dept,
93 workArea, principalId, jobNumber, TKUtils.formatDateString(fromEffdt), TKUtils.formatDateString(toEffdt), active, history);
94 }
95 }