1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.accrual.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.accrual.TimeOffAccrual;
25 import org.kuali.hr.time.service.base.TkServiceLocator;
26 import org.kuali.rice.kns.lookup.HtmlData;
27 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
28 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
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 TimeOffAccrualLookupableHelper extends KualiLookupableHelperServiceImpl {
34
35 private static final long serialVersionUID = -8156015437451479966L;
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 TimeOffAccrual timeOffAccrual = (TimeOffAccrual) businessObject;
44 final String lmAccrualId = timeOffAccrual.getLmAccrualId();
45
46 for (HtmlData defaultCustomActionUrl : defaultCustomActionUrls){
47 if (!StringUtils.equals(defaultCustomActionUrl.getMethodToCall(), "copy")){
48 customActionUrls.add(defaultCustomActionUrl);
49 }
50 }
51
52 Properties params = new Properties();
53 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
54 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
55 params.put("lmAccrualId", lmAccrualId);
56 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
57 viewUrl.setDisplayText("view");
58 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
59 customActionUrls.add(viewUrl);
60
61 return customActionUrls;
62 }
63
64 @SuppressWarnings({"unchecked"})
65 @Override
66 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
67
68 String principalId = fieldValues.get("principalId");
69 String accrualCategory = fieldValues.get("accrualCategory");
70
71 List<TimeOffAccrual> timeOffAccruals = TkServiceLocator.getTimeOffAccrualService().getTimeOffAccruals(principalId, accrualCategory);
72
73 return timeOffAccruals;
74 }
75 }