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 OleGloballyProtectedFieldLookupableImpl extends LookupableImpl {
26
27
28
29
30
31
32
33
34
35
36 @Override
37 protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
38 List<String> pkNames) {
39 LookupView lookupView = (LookupView) lookupForm.getView();
40
41 Properties props = new Properties();
42 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
43
44 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
45 for (String primaryKey : primaryKeyValues.keySet()) {
46 String primaryKeyValue = primaryKeyValues.get(primaryKey);
47
48 props.put(primaryKey, primaryKeyValue);
49 }
50
51 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
52 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
53 }
54
55 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, lookupForm.getDataObjectClassName());
56 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
57
58 String maintenanceMapping = OLEConstants.OleGloballyProtectedField.GLOBALLY_PROTECTED_ACTION_LINK;
59 return UrlFactory.parameterizeUrl(maintenanceMapping, props);
60 }
61 }