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