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.api.leaveplan.LeavePlan;
23 import org.kuali.kpme.core.leaveplan.LeavePlanBo;
24 import org.kuali.kpme.core.lookup.KPMELookupableHelperServiceImpl;
25 import org.kuali.kpme.core.service.HrServiceLocator;
26 import org.kuali.kpme.core.util.TKUtils;
27 import org.kuali.rice.core.api.mo.ModelObjectUtils;
28 import org.kuali.rice.kns.lookup.HtmlData;
29 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
30 import org.kuali.rice.krad.bo.BusinessObject;
31 import org.kuali.rice.krad.util.KRADConstants;
32 import org.kuali.rice.krad.util.UrlFactory;
33
34 @SuppressWarnings("deprecation")
35 public class LeavePlanLookupableHelper extends KPMELookupableHelperServiceImpl {
36
37 private static final long serialVersionUID = 3382815973444543931L;
38 private static final ModelObjectUtils.Transformer<LeavePlan, LeavePlanBo> toLeavePlanBo =
39 new ModelObjectUtils.Transformer<LeavePlan, LeavePlanBo>() {
40 public LeavePlanBo transform(LeavePlan input) {
41 return LeavePlanBo.from(input);
42 };
43 };
44 @Override
45 @SuppressWarnings("rawtypes")
46 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
47 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
48
49 LeavePlanBo leavePlan = (LeavePlanBo) businessObject;
50 String lmLeavePlanId = leavePlan.getLmLeavePlanId();
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("lmLeavePlanId", lmLeavePlanId);
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 @Override
65 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues){
66 String leavePlan = fieldValues.get("leavePlan");
67 String calendarYearStart = fieldValues.get("calendarYearStart");
68 String descr = fieldValues.get("descr");
69 String planningMonths = fieldValues.get("planningMonths");
70 String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
71 String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
72 String active = fieldValues.get("active");
73 String showHistory = fieldValues.get("history");
74
75 return ModelObjectUtils.transform(HrServiceLocator.getLeavePlanService().getLeavePlans(leavePlan, calendarYearStart, descr, planningMonths, TKUtils.formatDateString(fromEffdt),
76 TKUtils.formatDateString(toEffdt), active, showHistory), toLeavePlanBo);
77 }
78
79 }