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.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21 import java.util.Properties;
22
23 import org.apache.commons.lang.StringUtils;
24 import org.kuali.kpme.core.api.bo.HrBusinessObjectContract;
25 import org.kuali.kpme.core.lookup.KpmeHrBusinessObjectLookupableHelper;
26 import org.kuali.kpme.tklm.time.rules.lunch.department.DeptLunchRule;
27 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
28 import org.kuali.rice.kns.lookup.HtmlData;
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
33 @SuppressWarnings("deprecation")
34 public class DepartmentLunchRuleLookupableHelperServiceImpl extends KpmeHrBusinessObjectLookupableHelper {
35
36 private static final long serialVersionUID = -6171434403261481651L;
37
38 @Override
39 @SuppressWarnings("rawtypes")
40 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
41 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
42
43 DeptLunchRule deptLunchRule = (DeptLunchRule) businessObject;
44 String tkDeptLunchRuleId = deptLunchRule.getTkDeptLunchRuleId();
45
46 Properties params = new Properties();
47 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
48 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
49 params.put("tkDeptLunchRuleId", tkDeptLunchRuleId);
50
51 return customActionUrls;
52 }
53
54 @Override
55 protected void validateSearchParameterWildcardAndOperators(
56 String attributeName, String attributeValue) {
57 if (!StringUtils.equals(attributeValue, "%")) {
58 super.validateSearchParameterWildcardAndOperators(attributeName,
59 attributeValue);
60 }
61 }
62
63 @Override
64 public List<? extends HrBusinessObjectContract> getSearchResults(Map<String, String> fieldValues) {
65
66 List<? extends HrBusinessObjectContract> temp = new ArrayList<HrBusinessObjectContract>();
67 temp = super.getSearchResults(fieldValues);
68
69 if (temp != null){
70 List<DeptLunchRule> results = new ArrayList<DeptLunchRule>();
71 for (int i = 0; i < temp.size(); i++) {
72 DeptLunchRule deptLunchRule = (DeptLunchRule)temp.get(i);
73 results.add(deptLunchRule);
74 }
75
76 return TkServiceLocator.getDepartmentLunchRuleService().getDepartmentLunchRules(GlobalVariables.getUserSession().getPrincipalId(), results);
77 } else {
78 return temp;
79 }
80
81 }
82 }