1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.lookup;
17
18 import org.kuali.rice.kns.document.authorization.BusinessObjectRestrictions;
19 import org.kuali.rice.kns.web.struts.form.LookupForm;
20 import org.kuali.rice.kns.web.ui.Field;
21 import org.kuali.rice.kns.web.ui.ResultRow;
22 import org.kuali.rice.kns.web.ui.Row;
23 import org.kuali.rice.krad.bo.BusinessObject;
24 import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
25 import org.kuali.rice.krad.service.DataDictionaryService;
26 import org.kuali.rice.krad.util.KRADConstants;
27 import org.kuali.rice.krad.util.UrlFactory;
28 import org.springframework.transaction.annotation.Transactional;
29
30 import java.util.Collection;
31 import java.util.List;
32 import java.util.Map;
33 import java.util.Properties;
34
35
36
37
38 @Transactional
39 public class KualiLookupableImpl implements Lookupable {
40 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiLookupableImpl.class);
41 protected static final String[] IGNORE_LIST = { KRADConstants.DOC_FORM_KEY, KRADConstants.BACK_LOCATION };
42
43 protected Class businessObjectClass;
44 protected LookupableHelperService lookupableHelperService;
45 protected String extraOnLoad = "";
46
47
48
49
50 public KualiLookupableImpl() {
51 }
52
53
54
55
56
57
58 public void setBusinessObjectClass(Class boClass) {
59 if (boClass == null) {
60 throw new RuntimeException("Business object class is null.");
61 }
62
63 this.businessObjectClass = boClass;
64
65
66 getLookupableHelperService().setBusinessObjectClass(boClass);
67 }
68
69
70
71
72
73
74 public void setParameters(Map parameters) {
75 getLookupableHelperService().setParameters(parameters);
76 }
77
78
79
80
81 public Map getParameters() {
82 return getLookupableHelperService().getParameters();
83 }
84
85
86
87
88 public List getColumns() {
89 return getLookupableHelperService().getColumns();
90 }
91
92
93
94
95
96
97 public void validateSearchParameters(Map fieldValues) {
98 getLookupableHelperService().validateSearchParameters(fieldValues);
99 }
100
101
102
103
104
105
106
107
108 public List<BusinessObject> getSearchResultsUnbounded(Map<String, String> fieldValues) {
109 return getLookupableHelperService().getSearchResultsUnbounded(fieldValues);
110 }
111
112
113
114
115
116
117
118
119 public List<BusinessObject> getSearchResults(Map<String, String> fieldValues) {
120 return getLookupableHelperService().getSearchResults(fieldValues);
121 }
122
123
124
125
126 public HtmlData getReturnUrl(BusinessObject bo, Map fieldConversions, String lookupImpl, BusinessObjectRestrictions businessObjectRestrictions) {
127 return getLookupableHelperService().getReturnUrl(bo, fieldConversions, lookupImpl, getReturnKeys(), businessObjectRestrictions);
128 }
129
130
131
132
133 public String getCreateNewUrl() {
134 String url = "";
135
136 if (getLookupableHelperService().allowsMaintenanceNewOrCopyAction()) {
137 Properties parameters = new Properties();
138 parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
139 parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, this.businessObjectClass.getName());
140
141 url = UrlFactory.parameterizeUrl(KRADConstants.MAINTENANCE_ACTION, parameters);
142 url = "<a title=\"Create a new record\" href=\"" + url + "\"><img src=\"images/tinybutton-createnew.gif\" alt=\"create new\" width=\"70\" height=\"15\"/></a>";
143 }
144
145 return url;
146 }
147
148
149
150
151
152 public String getHtmlMenuBar() {
153 return getBusinessObjectDictionaryService().getLookupMenuBar(getBusinessObjectClass());
154 }
155
156
157
158
159 public String getSupplementalMenuBar() {
160 return getLookupableHelperService().getSupplementalMenuBar();
161 }
162
163
164
165
166 public List<? extends Row> getRows() {
167 return getLookupableHelperService().getRows();
168 }
169
170
171
172
173 public String getTitle() {
174 return getLookupableHelperService().getTitle();
175 }
176
177
178
179
180 public String getReturnLocation() {
181 return getLookupableHelperService().getReturnLocation();
182 }
183
184
185
186
187 public Class getBusinessObjectClass() {
188 return businessObjectClass;
189 }
190
191
192
193
194 public List getReturnKeys() {
195 return getLookupableHelperService().getReturnKeys();
196 }
197
198
199
200
201
202 public String getExtraButtonSource() {
203 return getBusinessObjectDictionaryService().getExtraButtonSource(getBusinessObjectClass());
204 }
205
206
207
208
209 public String getExtraButtonParams() {
210 return getBusinessObjectDictionaryService().getExtraButtonParams(getBusinessObjectClass());
211 }
212
213
214
215
216 public List getDefaultSortColumns() {
217 return getLookupableHelperService().getDefaultSortColumns();
218 }
219
220
221
222
223 public boolean checkForAdditionalFields(Map fieldValues) {
224 return getLookupableHelperService().checkForAdditionalFields(fieldValues);
225 }
226
227
228
229
230 public String getBackLocation() {
231 return getLookupableHelperService().getBackLocation();
232 }
233
234
235
236
237 public void setBackLocation(String backLocation) {
238 getLookupableHelperService().setBackLocation(backLocation);
239 }
240
241
242
243
244 public String getDocFormKey() {
245 return getLookupableHelperService().getDocFormKey();
246 }
247
248
249
250
251
252 public void setDocFormKey(String docFormKey) {
253 getLookupableHelperService().setDocFormKey(docFormKey);
254 }
255
256
257
258
259 protected BusinessObjectDictionaryService getBusinessObjectDictionaryService() {
260 return getLookupableHelperService().getBusinessObjectDictionaryService();
261 }
262
263
264
265
266 public void setFieldConversions(Map fieldConversions) {
267 getLookupableHelperService().setFieldConversions(fieldConversions);
268 }
269
270
271
272
273 protected DataDictionaryService getDataDictionaryService() {
274 return getLookupableHelperService().getDataDictionaryService();
275 }
276
277
278
279
280
281
282
283 public void setReadOnlyFieldsList(List<String> readOnlyFieldsList) {
284 getLookupableHelperService().setReadOnlyFieldsList(readOnlyFieldsList);
285 }
286
287
288 public LookupableHelperService getLookupableHelperService() {
289 return lookupableHelperService;
290 }
291
292
293
294
295
296
297 public void setLookupableHelperService(LookupableHelperService lookupableHelperService) {
298 this.lookupableHelperService = lookupableHelperService;
299 }
300
301
302
303
304
305 public Collection performLookup(LookupForm lookupForm, List<ResultRow> resultTable, boolean bounded) {
306 return getLookupableHelperService().performLookup(lookupForm, resultTable, bounded);
307 }
308
309
310 public boolean isSearchUsingOnlyPrimaryKeyValues() {
311 return getLookupableHelperService().isSearchUsingOnlyPrimaryKeyValues();
312 }
313
314
315 public String getPrimaryKeyFieldLabels() {
316 return getLookupableHelperService().getPrimaryKeyFieldLabels();
317 }
318
319
320
321
322
323
324 public void performClear(LookupForm lookupForm) {
325 getLookupableHelperService().performClear(lookupForm);
326 }
327
328
329
330
331
332
333 public boolean shouldDisplayHeaderNonMaintActions() {
334 return getLookupableHelperService().shouldDisplayHeaderNonMaintActions();
335 }
336
337
338
339
340
341
342 public boolean shouldDisplayLookupCriteria() {
343 return getLookupableHelperService().shouldDisplayLookupCriteria();
344 }
345
346 protected String getCreateNewUrl(String url){
347 return "<a title=\"Create a new record\" href=\"" + url + "\"><img src=\"images/tinybutton-createnew.gif\" alt=\"create new\" width=\"70\" height=\"15\"/></a>";
348 }
349
350
351
352
353 public boolean performCustomAction(boolean ignoreErrors) {
354 return getLookupableHelperService().performCustomAction(ignoreErrors);
355 }
356
357
358
359
360
361
362 public Field getExtraField() {
363 return getLookupableHelperService().getExtraField();
364 }
365
366
367
368
369
370
371 public void applyFieldAuthorizationsFromNestedLookups(Field field) {
372 getLookupableHelperService().applyFieldAuthorizationsFromNestedLookups(field);
373 }
374
375
376
377
378
379
380
381
382 public String getExtraOnLoad() {
383 return extraOnLoad;
384 }
385
386
387
388
389 public void setExtraOnLoad(String extraOnLoad) {
390 this.extraOnLoad = extraOnLoad;
391 }
392
393
394
395
396 public void applyConditionalLogicForFieldDisplay() {
397 getLookupableHelperService().applyConditionalLogicForFieldDisplay();
398 }
399
400 }