1 package org.kuali.ole.select.lookup;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.ole.OLEConstants;
5 import org.kuali.ole.select.bo.OleCheckListBo;
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 OleCheckListLookupableImpl extends LookupableImpl {
25 private String returnLocation = "";
26
27
28
29
30
31
32 public String getReturnLocation() {
33 return returnLocation;
34 }
35
36
37
38
39
40
41 public void setReturnLocation(String returnLocation) {
42 this.returnLocation = returnLocation;
43 }
44
45
46
47
48
49
50
51
52
53
54 @Override
55 protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
56 List<String> pkNames) {
57 LookupView lookupView = (LookupView) lookupForm.getView();
58
59 Properties props = new Properties();
60 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
61
62 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
63 for (String primaryKey : primaryKeyValues.keySet()) {
64 String primaryKeyValue = primaryKeyValues.get(primaryKey);
65
66 props.put(primaryKey, primaryKeyValue);
67 }
68
69 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
70 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
71 returnLocation = lookupForm.getReturnLocation();
72 }
73
74 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, lookupForm.getDataObjectClassName());
75 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
76
77 String maintenanceMapping = OLEConstants.OleCheckList.CHECK_LIST_MAINTENANCE_ACTION_LINK;
78 return UrlFactory.parameterizeUrl(maintenanceMapping, props);
79 }
80
81
82
83
84
85
86
87 public String performDownload(Object object) {
88 OleCheckListBo oleCheckListBo = (OleCheckListBo) object;
89 String url = OLEConstants.OleCheckList.CHECK_LIST_LINK + getReturnLocation() + OLEConstants.OleCheckList.METHOD_TO_CALL
90 + oleCheckListBo.getOleCheckListId();
91
92 return url;
93 }
94
95
96
97
98
99
100
101 public String getCheckListName(Object object) {
102 String checkListName = "";
103 OleCheckListBo oleCheckListBo = (OleCheckListBo) object;
104 checkListName = oleCheckListBo.getName();
105 return checkListName;
106 }
107
108 @Override
109 protected List<?> getSearchResults(LookupForm form, Map<String, String> searchCriteria, boolean unbounded) {
110 List<?> searchResults;
111 List<OleCheckListBo> finalSearchResult = new ArrayList<OleCheckListBo>();
112 List<OleCheckListBo> oleCheckListBo = new ArrayList<OleCheckListBo>();
113
114
115 oleCheckListBo = (List<OleCheckListBo>) super.getSearchResults(form, searchCriteria, unbounded);
116 finalSearchResult.addAll(oleCheckListBo);
117
118 searchResults = finalSearchResult;
119
120 if (searchResults.size() == 0) {
121 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.NO_RECORD_FOUND);
122 }
123 sortSearchResults(form, searchResults);
124 return searchResults;
125 }
126 }