View Javadoc
1   package org.kuali.ole.deliver.lookup;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.ole.OLEConstants;
5   import org.kuali.ole.deliver.bo.OleFixedDueDate;
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.GlobalVariables;
11  import org.kuali.rice.krad.util.KRADConstants;
12  import org.kuali.rice.krad.util.KRADUtils;
13  import org.kuali.rice.krad.util.UrlFactory;
14  import org.kuali.rice.krad.web.form.LookupForm;
15  
16  import java.util.ArrayList;
17  import java.util.List;
18  import java.util.Map;
19  import java.util.Properties;
20  
21  /**
22   * Created with IntelliJ IDEA.
23   * User: ?
24   * Date: 12/19/12
25   * Time: 6:35 PM
26   * To change this template use File | Settings | File Templates.
27   */
28  public class OleFixedDueDateLookupableImpl extends LookupableImpl {
29      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleFixedDueDateLookupableImpl.class);
30  
31      @Override
32      protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
33                                        List<String> pkNames) {
34          LOG.debug("Inside getActionUrlHref()");
35          LookupView lookupView = (LookupView) lookupForm.getView();
36  
37          Properties props = new Properties();
38          props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
39          Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
40          for (String primaryKey : primaryKeyValues.keySet()) {
41              String primaryKeyValue = primaryKeyValues.get(primaryKey);
42  
43              props.put(primaryKey, primaryKeyValue);
44          }
45  
46          if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
47              props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
48          }
49  
50          props.put(UifParameters.DATA_OBJECT_CLASS_NAME, OleFixedDueDate.class.getName());
51          props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
52  
53          String maintenanceMapping = OLEConstants.FIXED_DUE_DATE_CONTROLLER;
54  
55          return UrlFactory.parameterizeUrl(maintenanceMapping, props);
56      }
57  
58  
59      @Override
60      protected List<?> getSearchResults(LookupForm form, Map<String, String> searchCriteria, boolean unbounded) {
61          List<?> searchResults;
62          List<OleFixedDueDate> finalSearchResult = new ArrayList<OleFixedDueDate>();
63          List<OleFixedDueDate> oleFixedDueDate = new ArrayList<OleFixedDueDate>();
64  
65  
66          oleFixedDueDate = (List<OleFixedDueDate>) super.getSearchResults(form, searchCriteria, unbounded);
67          finalSearchResult.addAll(oleFixedDueDate);
68  
69          searchResults = finalSearchResult;
70  
71          if (searchResults.size() == 0) {
72              GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.NO_RECORD_FOUND);
73          }
74          sortSearchResults(form, searchResults);
75          return searchResults;
76      }
77  }