1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.overtime.weekly.rule.service;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Properties;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.hr.time.HrEffectiveDateActiveLookupableHelper;
24 import org.kuali.hr.time.overtime.weekly.rule.WeeklyOvertimeRule;
25 import org.kuali.hr.time.util.TKContext;
26 import org.kuali.hr.time.util.TKUser;
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.KRADConstants;
31 import org.kuali.rice.krad.util.UrlFactory;
32
33 public class WeeklyOvertimeRuleLookupableHelper extends HrEffectiveDateActiveLookupableHelper {
34
35 private static final long serialVersionUID = 7408152182449747106L;
36
37 @Override
38 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
39 List<HtmlData> customActionUrls = new ArrayList<HtmlData>();
40
41 List<HtmlData> defaultCustomActionUrls = super.getCustomActionUrls(businessObject, pkNames);
42
43 WeeklyOvertimeRule weeklyOvertimeRule = (WeeklyOvertimeRule) businessObject;
44 String tkWeeklyOvertimeRuleId = weeklyOvertimeRule.getTkWeeklyOvertimeRuleId();
45
46 boolean systemAdmin = TKUser.isSystemAdmin();
47
48 for (HtmlData defaultCustomActionUrl : defaultCustomActionUrls){
49 if (StringUtils.equals(defaultCustomActionUrl.getMethodToCall(), "edit")) {
50 if (systemAdmin) {
51 customActionUrls.add(defaultCustomActionUrl);
52 }
53 } else {
54 customActionUrls.add(defaultCustomActionUrl);
55 }
56 }
57
58 Properties params = new Properties();
59 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
60 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
61 params.put("tkWeeklyOvertimeRuleId", tkWeeklyOvertimeRuleId);
62 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
63 viewUrl.setDisplayText("view");
64 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
65 customActionUrls.add(viewUrl);
66
67 return customActionUrls;
68 }
69
70 }