View Javadoc
1   package org.kuali.ole.deliver.lookup;
2   
3   import org.kuali.rice.krad.lookup.LookupUtils;
4   import org.kuali.rice.krad.lookup.LookupableImpl;
5   import org.kuali.rice.krad.service.BusinessObjectService;
6   import org.kuali.rice.krad.service.KRADServiceLocator;
7   import org.kuali.rice.krad.util.GlobalVariables;
8   import org.kuali.rice.krad.web.form.LookupForm;
9   
10  import javax.jws.WebParam;
11  import java.util.*;
12  
13  /**
14   * Created with IntelliJ IDEA.
15   * User: divyaj
16   * Date: 11/22/13
17   * Time: 12:01 PM
18   * To change this template use File | Settings | File Templates.
19   */
20  public class OleEmploymentStatusLookupableImpl extends LookupableImpl{
21      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleEmploymentStatusLookupableImpl.class);
22  
23      protected List<?> getSearchResults(LookupForm form, Map<String, String> searchCriteria, boolean unbounded) {
24          Collection<?> searchResults = null;
25  
26          try {
27              Class entityEmploymentStatusBo = Class.forName("org.kuali.rice.kim.impl.identity.employment.EntityEmploymentStatusBo") ;
28              Map<String, String> nonBlankSearchCriteria = processSearchCriteria(form, searchCriteria);
29              if (nonBlankSearchCriteria == null) {
30                  return new ArrayList<Object>();
31              }
32              try {
33                  Integer searchResultsLimit = null;
34  
35                  if (!unbounded) {
36                      searchResultsLimit = LookupUtils.getSearchResultsLimit(entityEmploymentStatusBo, form);
37                  }
38  
39                  if (LookupUtils.hasExternalBusinessObjectProperty(entityEmploymentStatusBo, nonBlankSearchCriteria)) {
40                      Map<String, String> eboSearchCriteria = adjustCriteriaForNestedEBOs(nonBlankSearchCriteria, unbounded);
41  
42                      if (LOG.isDebugEnabled()) {
43                          LOG.debug("Passing these results into the lookup service: " + eboSearchCriteria);
44                      }
45                      searchResults = getLookupService().findCollectionBySearchHelper(entityEmploymentStatusBo, eboSearchCriteria,
46                              unbounded, searchResultsLimit);
47                      generateLookupResultsMessages(form, eboSearchCriteria, searchResults, unbounded);
48                  } else {
49                      searchResults = getLookupService().findCollectionBySearchHelper(entityEmploymentStatusBo,
50                              nonBlankSearchCriteria, unbounded, searchResultsLimit);
51                      generateLookupResultsMessages(form, nonBlankSearchCriteria, searchResults, unbounded);
52                  }
53  
54              } catch (IllegalAccessException e) {
55                  throw new RuntimeException("Error trying to perform search", e);
56              } catch (InstantiationException e1) {
57                  throw new RuntimeException("Error trying to perform search", e1);
58              }
59              if(GlobalVariables.getMessageMap().getInfoMessages().size()!=0){
60  
61                  GlobalVariables.getMessageMap().getInfoMessages().clear();
62  
63              }
64              if (searchResults == null) {
65                  searchResults = new ArrayList<Object>();
66              } else {
67                  sortSearchResults(form, (List<?>) searchResults);
68              }
69  
70  
71  
72          } catch (ClassNotFoundException e) {
73              e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
74          }        // removed blank search values and decrypt any encrypted search values
75          return (List<?>) searchResults;
76      }
77  
78  }