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.ImportBibUserPreferences;
6   import org.kuali.rice.krad.lookup.LookupableImpl;
7   import org.kuali.rice.krad.service.KRADServiceLocator;
8   import org.kuali.rice.krad.uif.UifConstants;
9   import org.kuali.rice.krad.uif.UifParameters;
10  import org.kuali.rice.krad.uif.view.LookupView;
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.*;
17  
18  /**
19   * Created with IntelliJ IDEA.
20   * User: PJ7789
21   * Date: 27/12/12
22   * Time: 6:41 PM
23   * To change this template use File | Settings | File Templates.
24   */
25  public class OleUserPreferencesLookupableImpl
26          extends LookupableImpl {
27      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(
28              OleUserPreferencesLookupableImpl.class);
29  
30      /**
31       * This method is to override the maintenance mapping
32       *
33       * @param lookupForm
34       * @param dataObject
35       * @param methodToCall
36       * @param pkNames
37       * @return mapping Url
38       */
39      @Override
40      protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
41                                        List<String> pkNames) {
42          LOG.debug("Inside getActionUrlHref()");
43          Properties props = new Properties();
44          props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
45          LOG.info("Method to call = " + methodToCall);
46          Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
47          for (String primaryKey : primaryKeyValues.keySet()) {
48              String primaryKeyValue = primaryKeyValues.get(primaryKey);
49  
50              props.put(primaryKey, primaryKeyValue);
51          }
52  
53          if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
54              props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
55          }
56  
57          props.put(UifParameters.DATA_OBJECT_CLASS_NAME, ImportBibUserPreferences.class.getName());
58          props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
59  
60          String maintenanceMapping = OLEConstants.OleUserPreferences.USER_PREF_MAINTENANCE_ACTION_LINK;
61  
62          return UrlFactory.parameterizeUrl(maintenanceMapping, props);
63      }
64  
65      @Override
66      public Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded) {
67          LOG.debug("Inside performSearch()");
68          Map<String, String> criteriaMap = new HashMap<String, String>();
69          List<ImportBibUserPreferences> importBibUserPreferencesList = new ArrayList<ImportBibUserPreferences>();
70  
71          String shelvingScheme = ((String) searchCriteria.get("shelvingScheme"));
72          if (shelvingScheme != null && !shelvingScheme.equals("")) {
73              criteriaMap.put("shelvingScheme", shelvingScheme);
74              LOG.info("shelvingScheme = " + shelvingScheme);
75          }
76          String importStatus = ((String) searchCriteria.get("importStatus"));
77          if (importStatus != null && !importStatus.equals("")) {
78              criteriaMap.put("importStatus", importStatus);
79              LOG.info("importStatus = " + importStatus);
80          }
81  
82          String importType = ((String) searchCriteria.get("importType"));
83          if (importType != null && !importType.equals("")) {
84              criteriaMap.put("importType", importType);
85              LOG.info("importType = " + importType);
86          }
87  
88          String removalTags = ((String) searchCriteria.get("removalTags"));
89          if (removalTags != null && !removalTags.equals("")) {
90              criteriaMap.put("removalTags", removalTags);
91              LOG.info("removalTags = " + removalTags);
92          }
93  
94          String protectedTags = ((String) searchCriteria.get("protectedTags"));
95          if (protectedTags != null && !protectedTags.equals("")) {
96              criteriaMap.put("protectedTags", protectedTags);
97              LOG.info("protectedTags = " + protectedTags);
98          }
99  
100         String permLocation = ((String) searchCriteria.get("permLocation"));
101         if (permLocation != null && !permLocation.equals("")) {
102             criteriaMap.put("permLocation", permLocation);
103             LOG.info("permLocation = " + permLocation);
104         }
105 
106         String callNumberSource1 = ((String) searchCriteria.get("callNumberSource1"));
107         if (callNumberSource1 != null && !callNumberSource1.equals("")) {
108             criteriaMap.put("callNumberSource1", callNumberSource1);
109             LOG.info("callNumberSource1 = " + callNumberSource1);
110         }
111 
112         String callNumberSource2 = ((String) searchCriteria.get("callNumberSource2"));
113         if (callNumberSource2 != null && !callNumberSource2.equals("")) {
114             criteriaMap.put("callNumberSource2", callNumberSource2);
115             LOG.info("callNumberSource2 = " + callNumberSource2);
116         }
117 
118         String callNumberSource3 = ((String) searchCriteria.get("callNumberSource3"));
119         if (callNumberSource3 != null && !callNumberSource3.equals("")) {
120             criteriaMap.put("callNumberSource3", callNumberSource3);
121             LOG.info("callNumberSource3 = " + callNumberSource3);
122         }
123 
124         String prefName = ((String) searchCriteria.get("prefName"));
125         if (prefName != null && !prefName.equals("")) {
126             criteriaMap.put("prefName", prefName);
127             LOG.info("prefName = " + prefName);
128         }
129 
130         String tempLocation = ((String) searchCriteria.get("tempLocation"));
131         if (tempLocation != null && !tempLocation.equals("")) {
132             criteriaMap.put("tempLocation", tempLocation);
133             LOG.info("tempLocation = " + tempLocation);
134         }
135         importBibUserPreferencesList = (List<ImportBibUserPreferences>) KRADServiceLocator.getBusinessObjectService().findMatching(ImportBibUserPreferences.class, criteriaMap);
136         return importBibUserPreferencesList;
137     }
138 }