1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.lookup;
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.kuali.kpme.core.bo.HrBusinessObject;
24 import org.kuali.kpme.core.util.HrContext;
25 import org.kuali.rice.kns.lookup.HtmlData;
26 import org.kuali.rice.krad.lookup.LookupableImpl;
27 import org.kuali.rice.krad.uif.UifConstants;
28 import org.kuali.rice.krad.uif.UifParameters;
29 import org.kuali.rice.krad.util.KRADConstants;
30 import org.kuali.rice.krad.util.KRADUtils;
31 import org.kuali.rice.krad.util.UrlFactory;
32 import org.kuali.rice.krad.web.form.LookupForm;
33
34 public class KPMELookupableImpl extends LookupableImpl {
35
36 private static final long serialVersionUID = 7098170370881970354L;
37
38 @Override
39 protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall, List<String> pkNames) {
40 if (!StringUtils.equals(methodToCall, "maintenanceView")) {
41 return super.getActionUrlHref(lookupForm, dataObject, methodToCall, pkNames);
42 } else {
43 Properties urlParameters = new Properties();
44
45 urlParameters.setProperty(UifParameters.DATA_OBJECT_CLASS_NAME, dataObject.getClass().getName());
46 urlParameters.setProperty(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.START);
47
48 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
49 for (String primaryKey : primaryKeyValues.keySet()) {
50 String primaryKeyValue = primaryKeyValues.get(primaryKey);
51
52 urlParameters.put(primaryKey, primaryKeyValue);
53 }
54
55 return UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, urlParameters);
56 }
57 }
58
59
60 @Override
61 public boolean allowsMaintenanceEditAction(Object dataObject) {
62 boolean allowsEdit = super.allowsMaintenanceEditAction(dataObject);
63 if (dataObject instanceof HrBusinessObject) {
64 HrBusinessObject bo = (HrBusinessObject) dataObject;
65 if (!bo.isActive()) {
66 if (!HrContext.canEditInactiveRecords()) {
67 allowsEdit = false;
68 }
69 }
70 }
71 return allowsEdit;
72 }
73 }