1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kns.datadictionary;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.core.api.config.property.ConfigurationService;
21 import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase;
22 import org.kuali.rice.krad.datadictionary.HelpDefinition;
23 import org.kuali.rice.krad.datadictionary.SortDefinition;
24 import org.kuali.rice.krad.datadictionary.exception.DuplicateEntryException;
25 import org.kuali.rice.krad.service.KRADServiceLocator;
26 import org.kuali.rice.krad.util.KRADConstants;
27
28 import java.util.ArrayList;
29 import java.util.LinkedHashMap;
30 import java.util.List;
31 import java.util.Map;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 @Deprecated
58 public class LookupDefinition extends DataDictionaryDefinitionBase {
59 private static final long serialVersionUID = 6733008572890721359L;
60
61 protected String lookupableID;
62 protected String title;
63 protected String menubar;
64 protected SortDefinition defaultSort;
65
66 protected List<FieldDefinition> lookupFields = new ArrayList<FieldDefinition>();
67 protected Map<String, FieldDefinition> lookupFieldMap = new LinkedHashMap<String, FieldDefinition>();
68 protected List<FieldDefinition> resultFields = new ArrayList<FieldDefinition>();
69 protected Map<String, FieldDefinition> resultFieldMap = new LinkedHashMap<String, FieldDefinition>();
70
71 protected Integer resultSetLimit = null;
72
73 protected String extraButtonSource;
74 protected String extraButtonParams;
75
76 protected String searchIconOverride;
77
78 protected int numOfColumns;
79
80 protected HelpDefinition helpDefinition;
81 protected String helpUrl;
82
83 protected boolean translateCodes = false;
84 protected boolean disableSearchButtons = false;
85
86 public LookupDefinition() {
87 }
88
89
90
91
92
93
94
95
96
97
98
99 public void setLookupableID(String lookupableID) {
100 if (lookupableID == null) {
101 throw new IllegalArgumentException("invalid (null) lookupableID");
102 }
103
104 this.lookupableID = lookupableID;
105 }
106
107
108
109
110 public String getLookupableID() {
111 return this.lookupableID;
112 }
113
114
115
116
117 public String getTitle() {
118 return title;
119 }
120
121
122
123
124
125
126
127 public void setTitle(String title) {
128 if (StringUtils.isBlank(title)) {
129 throw new IllegalArgumentException("invalid (blank) title");
130 }
131 this.title = title;
132 }
133
134
135
136
137 public boolean hasMenubar() {
138 return (menubar != null);
139 }
140
141
142
143
144 public String getMenubar() {
145 return menubar;
146 }
147
148
149
150
151
152
153
154
155
156
157 public void setMenubar(String menubar) {
158 if (StringUtils.isBlank(menubar)) {
159 throw new IllegalArgumentException("invalid (blank) menubar");
160 }
161
162 ConfigurationService kualiConfigurationservice = KRADServiceLocator.getKualiConfigurationService();
163 this.menubar = menubar.replace("${kr.externalizable.images.url}",
164 kualiConfigurationservice.getPropertyString(KRADConstants.EXTERNALIZABLE_IMAGES_URL_KEY)).replace("${externalizable.images.url}",
165 kualiConfigurationservice.getPropertyString(KRADConstants.APPLICATION_EXTERNALIZABLE_IMAGES_URL_KEY));
166 this.menubar = this.menubar.replace("${application.url}", kualiConfigurationservice.getPropertyString(
167 KRADConstants.APPLICATION_URL_KEY));
168 }
169
170
171
172
173
174 public boolean hasDefaultSort() {
175 return (defaultSort != null);
176 }
177
178
179
180
181 public SortDefinition getDefaultSort() {
182 return defaultSort;
183 }
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203 public void setDefaultSort(SortDefinition defaultSort) {
204 if (defaultSort == null) {
205 throw new IllegalArgumentException("invalid (null) defaultSort");
206 }
207 this.defaultSort = defaultSort;
208 }
209
210
211
212
213
214 public List getLookupFieldNames() {
215 List fieldNames = new ArrayList();
216 fieldNames.addAll(this.lookupFieldMap.keySet());
217
218 return fieldNames;
219 }
220
221
222
223
224
225 public List<FieldDefinition> getLookupFields() {
226 return lookupFields;
227 }
228
229
230
231
232
233 public FieldDefinition getLookupField(String attributeName) {
234 return lookupFieldMap.get(attributeName);
235 }
236
237
238
239
240
241 public List<String> getResultFieldNames() {
242 List<String> fieldNames = new ArrayList<String>();
243 fieldNames.addAll(resultFieldMap.keySet());
244
245 return fieldNames;
246 }
247
248
249
250
251
252 public List<FieldDefinition> getResultFields() {
253 return resultFields;
254 }
255
256
257
258
259
260
261 public FieldDefinition getResultField(String attributeName) {
262 return resultFieldMap.get(attributeName);
263 }
264
265
266
267
268
269 public void setResultSetLimit(Integer resultSetLimit) {
270 this.resultSetLimit = resultSetLimit;
271 }
272
273
274
275
276 public boolean hasResultSetLimit() {
277 return (resultSetLimit != null);
278 }
279
280
281
282
283
284
285 public Integer getResultSetLimit() {
286 return resultSetLimit;
287 }
288
289
290
291
292
293
294 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
295 if (hasDefaultSort()) {
296 defaultSort.completeValidation(rootBusinessObjectClass, null);
297 }
298
299 for (FieldDefinition lookupField : lookupFields) {
300 lookupField.completeValidation(rootBusinessObjectClass, null);
301 }
302
303 for (FieldDefinition resultField : resultFields) {
304 resultField.completeValidation(rootBusinessObjectClass, null);
305 }
306 }
307
308
309
310
311 public boolean hasExtraButtonSource() {
312 return extraButtonSource != null;
313 }
314
315
316
317
318 public String getExtraButtonSource() {
319 return extraButtonSource;
320 }
321
322
323
324
325
326
327
328
329
330
331
332
333 public void setExtraButtonSource(String extraButtonSource) {
334 if (StringUtils.isBlank(extraButtonSource)) {
335 throw new IllegalArgumentException("invalid (blank) button source");
336 }
337 this.extraButtonSource = extraButtonSource;
338 }
339
340
341
342
343 public boolean hasExtraButtonParams() {
344 return extraButtonParams != null;
345 }
346
347
348
349
350 public String getExtraButtonParams() {
351 return extraButtonParams;
352 }
353
354
355
356
357
358
359
360
361
362
363 public void setExtraButtonParams(String extraButtonParams) {
364 this.extraButtonParams = extraButtonParams;
365 }
366
367
368
369
370
371 public boolean hasSearchIconOverride() {
372 return searchIconOverride != null;
373 }
374
375
376
377
378 public String getSearchIconOverride() {
379 return searchIconOverride;
380 }
381
382
383
384
385
386
387
388
389 public void setSearchIconOverride(String searchIconOverride) {
390 if (StringUtils.isBlank(searchIconOverride)) {
391 throw new IllegalArgumentException("invalid (blank) search icon override");
392 }
393 this.searchIconOverride = searchIconOverride;
394 }
395
396
397 public String toString() {
398 return "LookupDefinition '" + getTitle() + "'";
399 }
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434 public void setLookupFields(List<FieldDefinition> lookupFields) {
435 lookupFieldMap.clear();
436 for (FieldDefinition lookupField : lookupFields) {
437 if (lookupField == null) {
438 throw new IllegalArgumentException("invalid (null) lookupField");
439 }
440 String keyName = lookupField.getAttributeName();
441 if (lookupFieldMap.containsKey(keyName)) {
442 throw new DuplicateEntryException("duplicate lookupField entry for attribute '" + keyName + "'");
443 }
444
445 lookupFieldMap.put(keyName, lookupField);
446 }
447 this.lookupFields = lookupFields;
448 }
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468 public void setResultFields(List<FieldDefinition> resultFields) {
469 resultFieldMap.clear();
470 for (FieldDefinition resultField : resultFields) {
471 if (resultField == null) {
472 throw new IllegalArgumentException("invalid (null) resultField");
473 }
474
475 String keyName = resultField.getAttributeName();
476 if (resultFieldMap.containsKey(keyName)) {
477 throw new DuplicateEntryException("duplicate resultField entry for attribute '" + keyName + "'");
478 }
479
480 resultFieldMap.put(keyName, resultField);
481 }
482 this.resultFields = resultFields;
483 }
484
485
486
487
488 public int getNumOfColumns() {
489 return this.numOfColumns;
490 }
491
492
493
494
495 public void setNumOfColumns(int numOfColumns) {
496 this.numOfColumns = numOfColumns;
497 }
498
499
500
501
502 public HelpDefinition getHelpDefinition() {
503 return this.helpDefinition;
504 }
505
506
507
508
509 public void setHelpDefinition(HelpDefinition helpDefinition) {
510 this.helpDefinition = helpDefinition;
511 }
512
513
514
515
516 public String getHelpUrl() {
517 return this.helpUrl;
518 }
519
520
521
522
523 public void setHelpUrl(String helpUrl) {
524 this.helpUrl = helpUrl;
525 }
526
527 public boolean isTranslateCodes() {
528 return this.translateCodes;
529 }
530
531 public void setTranslateCodes(boolean translateCodes) {
532 this.translateCodes = translateCodes;
533 }
534
535 public boolean isDisableSearchButtons() {
536 return this.disableSearchButtons;
537 }
538
539 public void setDisableSearchButtons(boolean disableSearchButtons) {
540 this.disableSearchButtons = disableSearchButtons;
541 }
542
543 }