1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.graceperiod.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.graceperiod.rule.GracePeriodRule;
25 import org.kuali.hr.time.util.TKContext;
26 import org.kuali.rice.kns.lookup.HtmlData;
27 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
28 import org.kuali.rice.krad.bo.BusinessObject;
29 import org.kuali.rice.krad.util.KRADConstants;
30 import org.kuali.rice.krad.util.UrlFactory;
31
32 public class GracePeriodRuleLookupableHelper extends HrEffectiveDateActiveLookupableHelper {
33
34 private static final long serialVersionUID = -1656060180428314707L;
35
36 @Override
37 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
38 List<HtmlData> customActionUrls = new ArrayList<HtmlData>();
39
40 List<HtmlData> defaultCustomActionUrls = super.getCustomActionUrls(businessObject, pkNames);
41
42 GracePeriodRule gracePeriodRule = (GracePeriodRule) businessObject;
43 String tkGracePeriodRuleId = gracePeriodRule.getTkGracePeriodRuleId();
44
45 boolean systemAdmin = TKContext.getUser().isSystemAdmin();
46
47 for (HtmlData defaultCustomActionUrl : defaultCustomActionUrls){
48 if (StringUtils.equals(defaultCustomActionUrl.getMethodToCall(), "edit")) {
49 if (systemAdmin) {
50 customActionUrls.add(defaultCustomActionUrl);
51 }
52 } else {
53 customActionUrls.add(defaultCustomActionUrl);
54 }
55 }
56
57 Properties params = new Properties();
58 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
59 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
60 params.put("tkGracePeriodRuleId", tkGracePeriodRuleId);
61 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
62 viewUrl.setDisplayText("view");
63 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
64 customActionUrls.add(viewUrl);
65
66 return customActionUrls;
67 }
68
69 }