1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.datadictionary;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.CoreApiServiceLocator;
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.util.KRADConstants;
26
27 import java.util.ArrayList;
28 import java.util.LinkedHashMap;
29 import java.util.List;
30 import java.util.Map;
31
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 @Deprecated
57 public class LookupDefinition extends DataDictionaryDefinitionBase {
58 private static final long serialVersionUID = 6733008572890721359L;
59
60 protected String lookupableID;
61 protected String title;
62 protected String menubar;
63 protected SortDefinition defaultSort;
64
65 protected List<FieldDefinition> lookupFields = new ArrayList<FieldDefinition>();
66 protected Map<String, FieldDefinition> lookupFieldMap = new LinkedHashMap<String, FieldDefinition>();
67 protected List<FieldDefinition> resultFields = new ArrayList<FieldDefinition>();
68 protected Map<String, FieldDefinition> resultFieldMap = new LinkedHashMap<String, FieldDefinition>();
69
70 protected Integer resultSetLimit = null;
71 protected Integer multipleValuesResultSetLimit = 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 = CoreApiServiceLocator.getKualiConfigurationService();
163 this.menubar = menubar.replace("${kr.externalizable.images.url}",
164 kualiConfigurationservice.getPropertyValueAsString(KRADConstants.EXTERNALIZABLE_IMAGES_URL_KEY)).replace("${externalizable.images.url}",
165 kualiConfigurationservice.getPropertyValueAsString(
166 KRADConstants.APPLICATION_EXTERNALIZABLE_IMAGES_URL_KEY));
167 this.menubar = this.menubar.replace("${application.url}", kualiConfigurationservice.getPropertyValueAsString(
168 KRADConstants.APPLICATION_URL_KEY));
169 }
170
171
172
173
174
175 public boolean hasDefaultSort() {
176 return (defaultSort != null);
177 }
178
179
180
181
182 public SortDefinition getDefaultSort() {
183 return defaultSort;
184 }
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204 public void setDefaultSort(SortDefinition defaultSort) {
205 if (defaultSort == null) {
206 throw new IllegalArgumentException("invalid (null) defaultSort");
207 }
208 this.defaultSort = defaultSort;
209 }
210
211
212
213
214
215 public List getLookupFieldNames() {
216 List fieldNames = new ArrayList();
217 fieldNames.addAll(this.lookupFieldMap.keySet());
218
219 return fieldNames;
220 }
221
222
223
224
225
226 public List<FieldDefinition> getLookupFields() {
227 return lookupFields;
228 }
229
230
231
232
233
234 public FieldDefinition getLookupField(String attributeName) {
235 return lookupFieldMap.get(attributeName);
236 }
237
238
239
240
241
242 public List<String> getResultFieldNames() {
243 List<String> fieldNames = new ArrayList<String>();
244 fieldNames.addAll(resultFieldMap.keySet());
245
246 return fieldNames;
247 }
248
249
250
251
252
253 public List<FieldDefinition> getResultFields() {
254 return resultFields;
255 }
256
257
258
259
260
261
262 public FieldDefinition getResultField(String attributeName) {
263 return resultFieldMap.get(attributeName);
264 }
265
266
267
268
269
270 public void setResultSetLimit(Integer resultSetLimit) {
271 this.resultSetLimit = resultSetLimit;
272 }
273
274
275
276
277 public boolean hasResultSetLimit() {
278 return (resultSetLimit != null);
279 }
280
281
282
283
284
285
286 public Integer getResultSetLimit() {
287 return resultSetLimit;
288 }
289
290
291
292
293
294 public void setMultipleValuesResultSetLimit(Integer multipleValuesResultSetLimit) {
295 this.multipleValuesResultSetLimit = multipleValuesResultSetLimit;
296 }
297
298
299
300
301 public boolean hasMultipleValuesResultSetLimit() {
302 return (multipleValuesResultSetLimit != null);
303 }
304
305
306
307
308
309
310 public Integer getMultipleValuesResultSetLimit() {
311 return multipleValuesResultSetLimit;
312 }
313
314
315
316
317
318
319 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
320 if (hasDefaultSort()) {
321 defaultSort.completeValidation(rootBusinessObjectClass, null);
322 }
323
324 for (FieldDefinition lookupField : lookupFields) {
325 lookupField.completeValidation(rootBusinessObjectClass, null);
326 }
327
328 for (FieldDefinition resultField : resultFields) {
329 resultField.completeValidation(rootBusinessObjectClass, null);
330 }
331 }
332
333
334
335
336 public boolean hasExtraButtonSource() {
337 return extraButtonSource != null;
338 }
339
340
341
342
343 public String getExtraButtonSource() {
344 return extraButtonSource;
345 }
346
347
348
349
350
351
352
353
354
355
356
357
358 public void setExtraButtonSource(String extraButtonSource) {
359 if (StringUtils.isBlank(extraButtonSource)) {
360 throw new IllegalArgumentException("invalid (blank) button source");
361 }
362 this.extraButtonSource = extraButtonSource;
363 }
364
365
366
367
368 public boolean hasExtraButtonParams() {
369 return extraButtonParams != null;
370 }
371
372
373
374
375 public String getExtraButtonParams() {
376 return extraButtonParams;
377 }
378
379
380
381
382
383
384
385
386
387
388 public void setExtraButtonParams(String extraButtonParams) {
389 this.extraButtonParams = extraButtonParams;
390 }
391
392
393
394
395
396 public boolean hasSearchIconOverride() {
397 return searchIconOverride != null;
398 }
399
400
401
402
403 public String getSearchIconOverride() {
404 return searchIconOverride;
405 }
406
407
408
409
410
411
412
413
414 public void setSearchIconOverride(String searchIconOverride) {
415 if (StringUtils.isBlank(searchIconOverride)) {
416 throw new IllegalArgumentException("invalid (blank) search icon override");
417 }
418 this.searchIconOverride = searchIconOverride;
419 }
420
421
422 public String toString() {
423 return "LookupDefinition '" + getTitle() + "'";
424 }
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459 public void setLookupFields(List<FieldDefinition> lookupFields) {
460 lookupFieldMap.clear();
461 for (FieldDefinition lookupField : lookupFields) {
462 if (lookupField == null) {
463 throw new IllegalArgumentException("invalid (null) lookupField");
464 }
465 String keyName = lookupField.getAttributeName();
466 if (lookupFieldMap.containsKey(keyName)) {
467 throw new DuplicateEntryException("duplicate lookupField entry for attribute '" + keyName + "'");
468 }
469
470 lookupFieldMap.put(keyName, lookupField);
471 }
472 this.lookupFields = lookupFields;
473 }
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493 public void setResultFields(List<FieldDefinition> resultFields) {
494 resultFieldMap.clear();
495 for (FieldDefinition resultField : resultFields) {
496 if (resultField == null) {
497 throw new IllegalArgumentException("invalid (null) resultField");
498 }
499
500 String keyName = resultField.getAttributeName();
501 if (resultFieldMap.containsKey(keyName)) {
502 throw new DuplicateEntryException("duplicate resultField entry for attribute '" + keyName + "'");
503 }
504
505 resultFieldMap.put(keyName, resultField);
506 }
507 this.resultFields = resultFields;
508 }
509
510
511
512
513 public int getNumOfColumns() {
514 return this.numOfColumns;
515 }
516
517
518
519
520 public void setNumOfColumns(int numOfColumns) {
521 this.numOfColumns = numOfColumns;
522 }
523
524
525
526
527 public HelpDefinition getHelpDefinition() {
528 return this.helpDefinition;
529 }
530
531
532
533
534 public void setHelpDefinition(HelpDefinition helpDefinition) {
535 this.helpDefinition = helpDefinition;
536 }
537
538
539
540
541 public String getHelpUrl() {
542 return this.helpUrl;
543 }
544
545
546
547
548 public void setHelpUrl(String helpUrl) {
549 this.helpUrl = helpUrl;
550 }
551
552 public boolean isTranslateCodes() {
553 return this.translateCodes;
554 }
555
556 public void setTranslateCodes(boolean translateCodes) {
557 this.translateCodes = translateCodes;
558 }
559
560 public boolean isDisableSearchButtons() {
561 return this.disableSearchButtons;
562 }
563
564 public void setDisableSearchButtons(boolean disableSearchButtons) {
565 this.disableSearchButtons = disableSearchButtons;
566 }
567
568 }