1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.calendar.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.calendar.CalendarEntries;
24 import org.kuali.hr.time.util.TKContext;
25 import org.kuali.rice.kns.lookup.HtmlData;
26 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
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 CalendarEntriesLookupableHelper extends KualiLookupableHelperServiceImpl {
33
34 private static final long serialVersionUID = 6008647804840459542L;
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 CalendarEntries calendarEntries = (CalendarEntries) businessObject;
43 String hrCalendarEntriesId = calendarEntries.getHrCalendarEntriesId();
44 String calendarName = calendarEntries.getCalendarName();
45
46 boolean systemAdmin = TKContext.getUser().isSystemAdmin();
47 boolean locationAdmin = TKContext.getUser().isLocationAdmin();
48
49 for (HtmlData defaultCustomActionUrl : defaultCustomActionUrls){
50 if (StringUtils.equals(defaultCustomActionUrl.getMethodToCall(), "edit")) {
51 if (systemAdmin || locationAdmin) {
52 customActionUrls.add(defaultCustomActionUrl);
53 }
54 } else if (!StringUtils.equals(defaultCustomActionUrl.getMethodToCall(), "copy")){
55 customActionUrls.add(defaultCustomActionUrl);
56 }
57 }
58
59 Properties params = new Properties();
60 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
61 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
62 params.put("hrCalendarEntriesId", hrCalendarEntriesId);
63 params.put("calendarName", calendarName);
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 }