View Javadoc

1   package org.kuali.ole.catalog.lookup;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.rice.krad.lookup.LookupableImpl;
5   import org.kuali.rice.krad.uif.UifConstants;
6   import org.kuali.rice.krad.uif.UifParameters;
7   import org.kuali.rice.krad.uif.view.LookupView;
8   import org.kuali.rice.krad.util.KRADConstants;
9   import org.kuali.rice.krad.util.KRADUtils;
10  import org.kuali.rice.krad.util.UrlFactory;
11  import org.kuali.rice.krad.web.form.LookupForm;
12  
13  import java.util.List;
14  import java.util.Map;
15  import java.util.Properties;
16  
17  /**
18   * Created with IntelliJ IDEA.
19   * User: ?
20   * Date: 1/23/13
21   * Time: 12:33 PM
22   * To change this template use File | Settings | File Templates.
23   */
24  public class OleAccessMethodLookupableImpl extends LookupableImpl {
25      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleAccessMethodLookupableImpl.class);
26  
27  
28  
29  
30  
31      /**
32       * Generates a URL to perform a maintenance action on the given result data object
33       *
34       * <p>
35       * Will build a URL containing keys of the data object to invoke the given maintenance action method
36       * within the maintenance controller
37       * </p>
38       *
39       * @param dataObject - data object instance for the line to build the maintenance action link for
40       * @param methodToCall - method name on the maintenance controller that should be invoked
41       * @param pkNames - list of primary key field names for the data object whose key/value pairs will be added to
42       * the maintenance link
43       * @return String URL link for the maintenance action
44       */
45      protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
46                                        List<String> pkNames) {
47          LookupView lookupView = (LookupView) lookupForm.getView();
48          Properties props = new Properties();
49          props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
50  
51          Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
52          for (String primaryKey : primaryKeyValues.keySet()) {
53              String primaryKeyValue = primaryKeyValues.get(primaryKey);
54  
55              props.put(primaryKey, primaryKeyValue);
56          }
57  
58          if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
59              props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
60          }
61  
62          props.put(UifParameters.DATA_OBJECT_CLASS_NAME, lookupForm.getDataObjectClassName());
63          props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
64  
65          String maintenanceMapping = "accessMethodMaintenance";
66  
67          return UrlFactory.parameterizeUrl(maintenanceMapping, props);
68      }
69  
70  }
71  
72