1 package org.kuali.ole.select.lookup;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.ole.OLEConstants;
5 import org.kuali.rice.krad.lookup.LookupableImpl;
6 import org.kuali.rice.krad.uif.UifConstants;
7 import org.kuali.rice.krad.uif.UifParameters;
8 import org.kuali.rice.krad.uif.view.LookupView;
9 import org.kuali.rice.krad.util.KRADConstants;
10 import org.kuali.rice.krad.util.KRADUtils;
11 import org.kuali.rice.krad.util.UrlFactory;
12 import org.kuali.rice.krad.web.form.LookupForm;
13
14 import java.util.List;
15 import java.util.Map;
16 import java.util.Properties;
17
18
19
20
21
22
23
24
25 public class OleBibProtectedFieldLookupableImpl extends LookupableImpl {
26
27
28
29
30
31
32
33
34
35 @Override
36 protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
37 List<String> pkNames) {
38 LookupView lookupView = (LookupView) lookupForm.getView();
39
40 Properties props = new Properties();
41 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
42
43 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
44 for (String primaryKey : primaryKeyValues.keySet()) {
45 String primaryKeyValue = primaryKeyValues.get(primaryKey);
46
47 props.put(primaryKey, primaryKeyValue);
48 }
49
50 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
51 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
52 }
53
54 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, lookupForm.getDataObjectClassName());
55 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
56
57 String maintenanceMapping = OLEConstants.OleBibProtectedField.BIB_PROTECTED_ACTION_LINK;
58 return UrlFactory.parameterizeUrl(maintenanceMapping, props);
59 }
60 }