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.OleCirculationDesk;
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
23
24 public class OleCirculationDeskLocationLookupableImpl extends LookupableImpl {
25 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleCirculationDeskLocationLookupableImpl.class);
26
27
28
29
30
31
32
33
34
35
36 protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
37 List<String> pkNames) {
38 LOG.debug("Inside getActionUrlHref()");
39 LookupView lookupView = (LookupView) lookupForm.getView();
40
41 Properties props = new Properties();
42 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
43 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
44 for (String primaryKey : primaryKeyValues.keySet()) {
45 String primaryKeyValue = primaryKeyValues.get(primaryKey);
46
47 props.put(primaryKey, primaryKeyValue);
48 }
49
50 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
51 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
52 }
53
54 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, OleCirculationDesk.class.getName());
55 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
56
57 String maintenanceMapping = "oleCirculationDeskMaintenance";
58
59 return UrlFactory.parameterizeUrl(maintenanceMapping, props);
60 }
61
62 @Override
63 protected List<?> getSearchResults(LookupForm form, Map<String, String> searchCriteria, boolean unbounded) {
64
65 List<?> searchResults;
66 List<OleCirculationDesk> finalSearchResult = new ArrayList<OleCirculationDesk>();
67 List<OleCirculationDesk> oleCirculationDesk = new ArrayList<OleCirculationDesk>();
68
69 oleCirculationDesk = (List<OleCirculationDesk>) super.getSearchResults(form, searchCriteria, unbounded);
70 finalSearchResult.addAll(oleCirculationDesk);
71
72 searchResults = finalSearchResult;
73 if (searchResults.size() == 0) {
74 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.NO_RECORD_FOUND);
75 }
76 sortSearchResults(form, searchResults);
77 return searchResults;
78 }
79
80
81 }