View Javadoc
1   package org.kuali.ole.describe.lookup;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.ole.OLEConstants;
5   import org.kuali.ole.describe.bo.ExternalDataSourceConfig;
6   import org.kuali.rice.krad.lookup.LookupableImpl;
7   import org.kuali.rice.krad.uif.UifConstants;
8   import org.kuali.rice.krad.uif.UifParameters;
9   import org.kuali.rice.krad.uif.view.LookupView;
10  import org.kuali.rice.krad.util.KRADConstants;
11  import org.kuali.rice.krad.util.KRADUtils;
12  import org.kuali.rice.krad.util.UrlFactory;
13  import org.kuali.rice.krad.web.form.LookupForm;
14  
15  import java.util.List;
16  import java.util.Map;
17  import java.util.Properties;
18  
19  /**
20   * Created with IntelliJ IDEA.
21   * User: PJ7789
22   * Date: 10/12/12
23   * Time: 5:18 PM
24   * To change this template use File | Settings | File Templates.
25   */
26  public class OleExternalDataSourceConfigLookupableImpl
27          extends LookupableImpl {
28      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(
29              OleExternalDataSourceConfigLookupableImpl.class);
30  
31      /**
32       * This method is to override the maintenance mapping
33       *
34       * @param lookupForm
35       * @param dataObject
36       * @param methodToCall
37       * @param pkNames
38       * @return mapping Url
39       */
40      @Override
41      protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
42                                        List<String> pkNames) {
43          LOG.debug("Inside getActionUrlHref()");
44          LookupView lookupView = (LookupView) lookupForm.getView();
45  
46          Properties props = new Properties();
47          props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
48          Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
49          for (String primaryKey : primaryKeyValues.keySet()) {
50              String primaryKeyValue = primaryKeyValues.get(primaryKey);
51  
52              props.put(primaryKey, primaryKeyValue);
53          }
54  
55          if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
56              props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
57          }
58  
59          props.put(UifParameters.DATA_OBJECT_CLASS_NAME, ExternalDataSourceConfig.class.getName());
60          props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
61  
62          String maintenanceMapping = OLEConstants.OleExternalDataSourceConfig.DATA_SOURCE_MAINTENANCE_ACTION_LINK;
63  
64          return UrlFactory.parameterizeUrl(maintenanceMapping, props);
65      }
66  }