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