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