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