View Javadoc
1   package org.kuali.ole.deliver.lookup;
2   
3   import org.eclipse.jdt.internal.eval.GlobalVariable;
4   import org.kuali.ole.sys.OLEConstants;
5   import org.kuali.rice.core.api.criteria.QueryByCriteria;
6   import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
7   import org.kuali.rice.core.api.exception.RiceIllegalStateException;
8   import org.kuali.rice.kim.api.identity.CodedAttribute;
9   import org.kuali.rice.kim.api.identity.IdentityService;
10  import org.kuali.rice.kim.api.identity.Person;
11  import org.kuali.rice.kim.api.identity.PersonService;
12  import org.kuali.rice.kim.api.identity.address.EntityAddress;
13  import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
14  import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliationType;
15  import org.kuali.rice.kim.api.identity.citizenship.EntityCitizenship;
16  import org.kuali.rice.kim.api.identity.email.EntityEmail;
17  import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
18  import org.kuali.rice.kim.api.identity.entity.Entity;
19  import org.kuali.rice.kim.api.identity.entity.EntityDefault;
20  import org.kuali.rice.kim.api.identity.entity.EntityDefaultQueryResults;
21  import org.kuali.rice.kim.api.identity.entity.EntityQueryResults;
22  import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifier;
23  import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifierType;
24  import org.kuali.rice.kim.api.identity.name.EntityName;
25  import org.kuali.rice.kim.api.identity.personal.EntityBioDemographics;
26  import org.kuali.rice.kim.api.identity.personal.EntityEthnicity;
27  import org.kuali.rice.kim.api.identity.phone.EntityPhone;
28  import org.kuali.rice.kim.api.identity.principal.EntityNamePrincipalName;
29  import org.kuali.rice.kim.api.identity.principal.Principal;
30  import org.kuali.rice.kim.api.identity.principal.PrincipalQueryResults;
31  import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences;
32  import org.kuali.rice.kim.api.identity.residency.EntityResidency;
33  import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo;
34  import org.kuali.rice.kim.api.identity.visa.EntityVisa;
35  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
36  import org.kuali.rice.kim.impl.KIMPropertyConstants;
37  import org.kuali.rice.kim.impl.identity.employment.EntityEmploymentStatusBo;
38  import org.kuali.rice.kim.impl.identity.employment.EntityEmploymentTypeBo;
39  import org.kuali.rice.krad.bo.ExternalizableBusinessObject;
40  import org.kuali.rice.krad.lookup.LookupUtils;
41  import org.kuali.rice.krad.lookup.LookupableImpl;
42  import org.kuali.rice.krad.service.BusinessObjectService;
43  import org.kuali.rice.krad.service.KRADServiceLocator;
44  import org.kuali.rice.krad.util.GlobalVariables;
45  import org.kuali.rice.krad.web.form.LookupForm;
46  
47  import javax.jws.WebParam;
48  import java.util.*;
49  
50  /**
51   * Created with IntelliJ IDEA.
52   * User: divyaj
53   * Date: 11/22/13
54   * Time: 12:01 PM
55   * To change this template use File | Settings | File Templates.
56   */
57  public class OleEmploymentStatusLookupableImpl extends LookupableImpl{
58      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleEmploymentStatusLookupableImpl.class);
59  
60      protected List<?> getSearchResults(LookupForm form, Map<String, String> searchCriteria, boolean unbounded) {
61          Collection<?> searchResults = null;
62  
63          try {
64              Class entityEmploymentStatusBo = Class.forName("org.kuali.rice.kim.impl.identity.employment.EntityEmploymentStatusBo") ;
65              Map<String, String> nonBlankSearchCriteria = processSearchCriteria(form, searchCriteria);
66              if (nonBlankSearchCriteria == null) {
67                  return new ArrayList<Object>();
68              }
69              try {
70                  Integer searchResultsLimit = null;
71  
72                  if (!unbounded) {
73                      searchResultsLimit = LookupUtils.getSearchResultsLimit(entityEmploymentStatusBo, form);
74                  }
75  
76                  if (LookupUtils.hasExternalBusinessObjectProperty(entityEmploymentStatusBo, nonBlankSearchCriteria)) {
77                      Map<String, String> eboSearchCriteria = adjustCriteriaForNestedEBOs(nonBlankSearchCriteria, unbounded);
78  
79                      if (LOG.isDebugEnabled()) {
80                          LOG.debug("Passing these results into the lookup service: " + eboSearchCriteria);
81                      }
82                      searchResults = getLookupService().findCollectionBySearchHelper(entityEmploymentStatusBo, eboSearchCriteria,
83                              unbounded, searchResultsLimit);
84                      generateLookupResultsMessages(form, eboSearchCriteria, searchResults, unbounded);
85                  } else {
86                      searchResults = getLookupService().findCollectionBySearchHelper(entityEmploymentStatusBo,
87                              nonBlankSearchCriteria, unbounded, searchResultsLimit);
88                      generateLookupResultsMessages(form, nonBlankSearchCriteria, searchResults, unbounded);
89                  }
90  
91              } catch (IllegalAccessException e) {
92                  throw new RuntimeException("Error trying to perform search", e);
93              } catch (InstantiationException e1) {
94                  throw new RuntimeException("Error trying to perform search", e1);
95              }
96              if(GlobalVariables.getMessageMap().getInfoMessages().size()!=0){
97  
98                  GlobalVariables.getMessageMap().getInfoMessages().clear();
99  
100             }
101             if (searchResults == null) {
102                 searchResults = new ArrayList<Object>();
103             } else {
104                 sortSearchResults(form, (List<?>) searchResults);
105             }
106 
107 
108 
109         } catch (ClassNotFoundException e) {
110             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
111         }        // removed blank search values and decrypt any encrypted search values
112         return (List<?>) searchResults;
113     }
114 
115 }