1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.location.web;
17
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Properties;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.joda.time.DateTime;
24 import org.kuali.kpme.core.KPMENamespace;
25 import org.kuali.kpme.core.location.Location;
26 import org.kuali.kpme.core.lookup.KPMELookupableHelper;
27 import org.kuali.kpme.core.role.KPMERole;
28 import org.kuali.kpme.core.service.HrServiceLocator;
29 import org.kuali.rice.kns.lookup.HtmlData;
30 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
31 import org.kuali.rice.krad.bo.BusinessObject;
32 import org.kuali.rice.krad.util.GlobalVariables;
33 import org.kuali.rice.krad.util.KRADConstants;
34 import org.kuali.rice.krad.util.UrlFactory;
35
36 @SuppressWarnings("deprecation")
37 public class LocationLookupableHelper extends KPMELookupableHelper {
38
39 private static final long serialVersionUID = 1285833127534968764L;
40
41 @Override
42 @SuppressWarnings("rawtypes")
43 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
44 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
45
46 Location locationObj = (Location) businessObject;
47 String hrLocationId = locationObj.getHrLocationId();
48 Properties params = new Properties();
49 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
50 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
51 params.put("hrLocationId", hrLocationId);
52 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
53 viewUrl.setDisplayText("view");
54 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
55 customActionUrls.add(viewUrl);
56
57 return customActionUrls;
58 }
59
60 @Override
61 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
62 String location = fieldValues.get("location");
63 String descr = fieldValues.get("description");
64 String active = fieldValues.get("active");
65 String showHist = fieldValues.get("history");
66
67 if (StringUtils.contains(location, "*")) {
68 location = "";
69 }
70
71 return HrServiceLocator.getLocationService().searchLocations(GlobalVariables.getUserSession().getPrincipalId(), location, descr, active, showHist);
72 }
73
74 @Override
75 protected void validateSearchParameterWildcardAndOperators(
76 String attributeName, String attributeValue) {
77 if (!StringUtils.equals(attributeValue, "*")) {
78 super.validateSearchParameterWildcardAndOperators(attributeName,
79 attributeValue);
80 }
81 }
82
83 }