1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.principal.web;
17
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Properties;
21
22 import org.kuali.kpme.core.lookup.KPMELookupableHelperServiceImpl;
23 import org.kuali.kpme.core.principal.PrincipalHRAttributesBo;
24 import org.kuali.kpme.core.service.HrServiceLocator;
25 import org.kuali.kpme.core.util.TKUtils;
26 import org.kuali.rice.core.api.mo.ModelObjectUtils;
27 import org.kuali.rice.kns.lookup.HtmlData;
28 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
29 import org.kuali.rice.krad.bo.BusinessObject;
30 import org.kuali.rice.krad.util.GlobalVariables;
31 import org.kuali.rice.krad.util.KRADConstants;
32 import org.kuali.rice.krad.util.UrlFactory;
33
34 @SuppressWarnings("deprecation")
35 public class PrincipalHRAttributesLookupableHelper extends KPMELookupableHelperServiceImpl {
36
37 private static final long serialVersionUID = 6198072858175242923L;
38
39 @Override
40 @SuppressWarnings("rawtypes")
41 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
42 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
43
44 PrincipalHRAttributesBo principalHRAttributes = (PrincipalHRAttributesBo) businessObject;
45 String hrPrincipalAttributeId = principalHRAttributes.getHrPrincipalAttributeId();
46
47 Properties params = new Properties();
48 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
49 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
50 params.put("hrPrincipalAttributeId", hrPrincipalAttributeId);
51 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
52 viewUrl.setDisplayText("view");
53 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
54 customActionUrls.add(viewUrl);
55
56
57 customActionUrls.add(getUrlData(principalHRAttributes, KRADConstants.MAINTENANCE_COPY_METHOD_TO_CALL, pkNames));
58
59 return customActionUrls;
60 }
61
62 @Override
63 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
64 String principalId = fieldValues.get("principalId");
65 String leavePlan = fieldValues.get("leavePlan");
66 String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
67 String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
68 String active = fieldValues.get("active");
69 String showHist = fieldValues.get("history");
70
71 return ModelObjectUtils.transform(HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes(GlobalVariables.getUserSession().getPrincipalId(), principalId, leavePlan, TKUtils.formatDateString(fromEffdt),
72 TKUtils.formatDateString(toEffdt), active, showHist), PrincipalHRAttributesBo.toBo);
73 }
74
75 }