1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.shiftdiff.rule.service;
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.hr.time.HrEffectiveDateActiveLookupableHelper;
25 import org.kuali.hr.time.service.base.TkServiceLocator;
26 import org.kuali.hr.time.shiftdiff.rule.ShiftDifferentialRule;
27 import org.kuali.hr.time.util.TKContext;
28 import org.kuali.hr.time.util.TKUtils;
29 import org.kuali.rice.kns.lookup.HtmlData;
30 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
31 import org.kuali.rice.krad.bo.BusinessObject;
32 import org.kuali.rice.krad.util.KRADConstants;
33 import org.kuali.rice.krad.util.UrlFactory;
34
35 public class ShiftDifferentialRuleLookupableHelper extends HrEffectiveDateActiveLookupableHelper {
36
37 private static final long serialVersionUID = -7636153206208704542L;
38
39 @Override
40 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
41 List<HtmlData> customActionUrls = new ArrayList<HtmlData>();
42
43 List<HtmlData> defaultCustomActionUrls = super.getCustomActionUrls(businessObject, pkNames);
44
45 ShiftDifferentialRule shiftDifferentialRule = (ShiftDifferentialRule) businessObject;
46 String tkShiftDiffRuleId = shiftDifferentialRule.getTkShiftDiffRuleId();
47
48 boolean systemAdmin = TKContext.getUser().isSystemAdmin();
49
50 for (HtmlData defaultCustomActionUrl : defaultCustomActionUrls){
51 if (StringUtils.equals(defaultCustomActionUrl.getMethodToCall(), "edit")) {
52 if (systemAdmin) {
53 customActionUrls.add(defaultCustomActionUrl);
54 }
55 } else {
56 customActionUrls.add(defaultCustomActionUrl);
57 }
58 }
59
60 Properties params = new Properties();
61 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
62 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
63 params.put("tkShiftDiffRuleId", tkShiftDiffRuleId);
64 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
65 viewUrl.setDisplayText("view");
66 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
67 customActionUrls.add(viewUrl);
68
69 return customActionUrls;
70 }
71
72 @Override
73 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
74 String location = fieldValues.get("location");
75 String payGrade = fieldValues.get("payGrade");
76 String hrSalGroup = fieldValues.get("hrSalGroup");
77 String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
78 String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
79 String active = fieldValues.get("active");
80 String showHist = fieldValues.get("history");
81
82 return TkServiceLocator.getShiftDifferentialRuleService().getShiftDifferentialRules(location, hrSalGroup, payGrade, TKUtils.formatDateString(fromEffdt),
83 TKUtils.formatDateString(toEffdt), active, showHist);
84 }
85
86 }