View Javadoc
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   * Created with IntelliJ IDEA.
20   * User: JuliyaMonica.S
21   * Date: 10/26/12
22   * Time: 7:44 PM
23   * To change this template use File | Settings | File Templates.
24   */
25  public class OleGloballyProtectedFieldLookupableImpl extends LookupableImpl {
26  
27      /**
28       * This method returns  URL for checklist maintenance action.
29       *
30       * @param lookupForm
31       * @param dataObject
32       * @param methodToCall
33       * @param pkNames
34       * @return String
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  }