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.LookupView;
7 import org.kuali.rice.krad.lookup.LookupableImpl;
8 import org.kuali.rice.krad.uif.UifConstants;
9 import org.kuali.rice.krad.uif.UifParameters;
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.lookup.LookupForm;
15
16 import java.util.*;
17
18
19
20
21 public class OleCirculationDeskLocationLookupableImpl extends LookupableImpl {
22 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleCirculationDeskLocationLookupableImpl.class);
23
24
25
26
27
28
29
30
31
32
33 protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
34 List<String> pkNames) {
35 LOG.debug("Inside getActionUrlHref()");
36 LookupView lookupView = (LookupView) lookupForm.getView();
37
38 Properties props = new Properties();
39 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
40 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
41 for (String primaryKey : primaryKeyValues.keySet()) {
42 String primaryKeyValue = primaryKeyValues.get(primaryKey);
43
44 props.put(primaryKey, primaryKeyValue);
45 }
46
47 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
48 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
49 }
50
51 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, OleCirculationDesk.class.getName());
52 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
53
54 String maintenanceMapping = "oleCirculationDeskMaintenance";
55
56 return UrlFactory.parameterizeUrl(maintenanceMapping, props);
57 }
58
59 @Override
60
61 public Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean unbounded) {
62
63 List<?> searchResults;
64 List<OleCirculationDesk> finalSearchResult = new ArrayList<OleCirculationDesk>();
65 List<OleCirculationDesk> oleCirculationDesk = new ArrayList<OleCirculationDesk>();
66
67
68 oleCirculationDesk = (List<OleCirculationDesk>) super.performSearch(form, searchCriteria, unbounded);
69 finalSearchResult.addAll(oleCirculationDesk);
70
71 searchResults = finalSearchResult;
72 if (searchResults.size() == 0) {
73 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.NO_RECORD_FOUND);
74 }
75 sortSearchResults(form, searchResults);
76 return searchResults;
77 }
78
79 @Override
80 protected String getMaintenanceActionUrl(LookupForm lookupForm, Object dataObject, String methodToCall,
81 List<String> pkNames) {
82 LookupView lookupView = (LookupView) lookupForm.getView();
83
84 Properties props = new Properties();
85 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
86
87 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
88 for (String primaryKey : primaryKeyValues.keySet()) {
89 String primaryKeyValue = primaryKeyValues.get(primaryKey);
90
91 props.put(primaryKey, primaryKeyValue);
92 }
93
94 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
95 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
96 }
97
98 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, lookupForm.getDataObjectClassName());
99 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
100
101 String maintenanceMapping = OLEConstants.OleCirculationDesk.OLE_CIRCULATION_DESK_MAINTENANCE_ACTION_LINK;
102
103 return UrlFactory.parameterizeUrl(maintenanceMapping, props);
104 }
105
106
107 }