1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leaveplan.service;
17
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Properties;
21
22 import org.kuali.hr.lm.leaveplan.LeavePlan;
23 import org.kuali.hr.time.HrEffectiveDateActiveLookupableHelper;
24 import org.kuali.hr.time.service.base.TkServiceLocator;
25 import org.kuali.hr.time.util.TKUtils;
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 LeavePlanLookupableHelper extends HrEffectiveDateActiveLookupableHelper {
33
34 private static final long serialVersionUID = 3382815973444543931L;
35
36 @Override
37 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
38 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
39
40 LeavePlan leavePlan = (LeavePlan) businessObject;
41 String lmLeavePlanId = leavePlan.getLmLeavePlanId();
42
43 Properties params = new Properties();
44 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
45 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
46 params.put("lmLeavePlanId", lmLeavePlanId);
47 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
48 viewUrl.setDisplayText("view");
49 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
50 customActionUrls.add(viewUrl);
51
52 return customActionUrls;
53 }
54
55 @Override
56 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues){
57 String leavePlan = fieldValues.get("leavePlan");
58 String calendarYearStart = fieldValues.get("calendarYearStart");
59 String descr = fieldValues.get("descr");
60 String planningMonths = fieldValues.get("planningMonths");
61 String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
62 String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
63 String active = fieldValues.get("active");
64 String showHistory = fieldValues.get("history");
65
66 return TkServiceLocator.getLeavePlanService().getLeavePlans(leavePlan, calendarYearStart, descr, planningMonths, TKUtils.formatDateString(fromEffdt),
67 TKUtils.formatDateString(toEffdt), active, showHistory);
68 }
69 }