1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kns.datadictionary.control;
18
19 import org.apache.commons.lang.ClassUtils;
20 import org.apache.commons.lang.builder.EqualsBuilder;
21 import org.kuali.rice.core.util.ClassLoaderUtils;
22 import org.kuali.rice.krad.bo.BusinessObject;
23 import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase;
24 import org.kuali.rice.krad.datadictionary.control.ControlDefinition;
25 import org.kuali.rice.krad.datadictionary.exception.ClassValidationException;
26 import org.kuali.rice.krad.datadictionary.exception.CompletionException;
27 import org.kuali.rice.krad.keyvalues.KeyValuesFinder;
28
29
30
31
32
33
34
35
36 @Deprecated
37 public abstract class ControlDefinitionBase extends DataDictionaryDefinitionBase implements ControlDefinition {
38 private static final long serialVersionUID = 4372435175782501152L;
39
40 protected boolean datePicker;
41 protected boolean expandedTextArea;
42 protected String script;
43 protected String valuesFinderClass;
44 protected String businessObjectClass;
45 protected String keyAttribute;
46 protected String labelAttribute;
47 protected Boolean includeBlankRow;
48 protected Boolean includeKeyInLabel;
49 protected Integer size;
50 protected Integer rows;
51 protected Integer cols;
52 protected boolean ranged;
53
54
55 public ControlDefinitionBase() {
56 ranged = true;
57 }
58
59 public boolean isDatePicker() {
60 return datePicker;
61 }
62
63
64
65
66
67
68 public void setDatePicker(boolean datePicker) {
69 this.datePicker=datePicker;
70 }
71
72 public boolean isExpandedTextArea() {
73 return expandedTextArea;
74 }
75
76
77
78
79
80
81 public void setExpandedTextArea(boolean eTextArea) {
82 this.expandedTextArea=eTextArea;
83 }
84
85
86
87
88 public boolean isCheckbox() {
89 return false;
90 }
91
92
93
94
95 public boolean isHidden() {
96 return false;
97 }
98
99
100
101
102 public boolean isRadio() {
103 return false;
104 }
105
106
107
108
109 public boolean isSelect() {
110 return false;
111 }
112
113
114
115
116 public boolean isMultiselect() {
117 return false;
118 }
119
120
121
122
123 public boolean isText() {
124 return false;
125 }
126
127
128
129
130 public boolean isTextarea() {
131 return false;
132 }
133
134
135
136
137 public boolean isCurrency() {
138 return false;
139 }
140
141
142
143
144
145 public boolean isKualiUser() {
146 return false;
147 }
148
149
150
151
152 public boolean isWorkflowWorkgroup() {
153 return false;
154 }
155
156
157
158
159 public boolean isFile() {
160 return false;
161 }
162
163
164
165
166 public boolean isLookupHidden() {
167 return false;
168 }
169
170
171
172
173 public boolean isLookupReadonly() {
174 return false;
175 }
176
177
178
179
180 public boolean isButton() {
181 return false;
182 }
183
184
185
186
187 public boolean isLink() {
188 return false;
189 }
190
191
192
193
194
195 public void setValuesFinderClass(String valuesFinderClass) {
196 if (valuesFinderClass == null) {
197 throw new IllegalArgumentException("invalid (null) valuesFinderClass");
198 }
199
200 this.valuesFinderClass = valuesFinderClass;
201 }
202
203
204
205
206 public String getBusinessObjectClass() {
207 return this.businessObjectClass;
208 }
209
210
211
212
213
214
215
216
217
218 public void setBusinessObjectClass(String businessObjectClass) {
219 if (businessObjectClass == null) {
220 throw new IllegalArgumentException("invalid (null) dataObjectClass");
221 }
222
223 this.businessObjectClass = businessObjectClass;
224 }
225
226
227
228
229 public Boolean getIncludeBlankRow() {
230 return this.includeBlankRow;
231 }
232
233
234
235
236 public void setIncludeBlankRow(Boolean includeBlankRow) {
237 this.includeBlankRow = includeBlankRow;
238 }
239
240
241
242
243 public Boolean getIncludeKeyInLabel() {
244 return this.includeKeyInLabel;
245 }
246
247
248
249
250 public void setIncludeKeyInLabel(Boolean includeKeyInLabel) {
251 this.includeKeyInLabel = includeKeyInLabel;
252 }
253
254
255
256
257 public String getKeyAttribute() {
258 return this.keyAttribute;
259 }
260
261
262
263
264
265 public void setKeyAttribute(String keyAttribute) {
266 this.keyAttribute = keyAttribute;
267 }
268
269
270
271
272 public String getLabelAttribute() {
273 return this.labelAttribute;
274 }
275
276
277
278
279
280 public void setLabelAttribute(String labelAttribute) {
281 this.labelAttribute = labelAttribute;
282 }
283
284
285
286
287 public String getValuesFinderClass() {
288 return valuesFinderClass;
289 }
290
291
292
293
294
295
296 public void setSize(Integer size) {
297 this.size = size;
298 }
299
300
301
302
303 public Integer getSize() {
304 return size;
305 }
306
307
308
309
310 public boolean hasScript() {
311 return false;
312 }
313
314
315
316
317
318
319 public void setRows(Integer rows) {
320 this.rows = rows;
321 }
322
323
324
325
326 public Integer getRows() {
327 return rows;
328 }
329
330
331
332
333
334
335 public void setCols(Integer cols) {
336 this.cols = cols;
337 }
338
339
340
341
342 public Integer getCols() {
343 return cols;
344 }
345
346
347
348
349
350
351 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
352 if (!isCheckbox() && !isHidden() && !isRadio() && !isSelect() && !isMultiselect() && !isText() && !isTextarea() && !isCurrency() && !isKualiUser() && !isLookupHidden() && !isLookupReadonly() && !isWorkflowWorkgroup() && !isFile()&& !isButton() && !isLink()) {
353 throw new CompletionException("error validating " + rootBusinessObjectClass.getName() + " control: unknown control type in control definition (" + "" + ")");
354 }
355 if (valuesFinderClass != null) {
356 try {
357 Class valuesFinderClassObject = ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getValuesFinderClass());
358 if (!KeyValuesFinder.class.isAssignableFrom(valuesFinderClassObject)) {
359 throw new ClassValidationException("valuesFinderClass is not a valid instance of " + KeyValuesFinder.class.getName() + " instead was: " + valuesFinderClassObject.getName());
360 }
361 } catch (ClassNotFoundException e) {
362 throw new ClassValidationException("valuesFinderClass could not be found: " + getValuesFinderClass(), e);
363 }
364 }
365 if (businessObjectClass != null) {
366 try {
367 Class businessObjectClassObject = ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getBusinessObjectClass());
368 if (!BusinessObject.class.isAssignableFrom(businessObjectClassObject)) {
369 throw new ClassValidationException("dataObjectClass is not a valid instance of " + BusinessObject.class.getName() + " instead was: " + businessObjectClassObject.getName());
370 }
371 } catch (ClassNotFoundException e) {
372 throw new ClassValidationException("dataObjectClass could not be found: " + getBusinessObjectClass(), e);
373 }
374 }
375 }
376
377
378
379
380 public String getScript() {
381 return script;
382 }
383
384
385
386
387
388
389 public void setScript(String script) {
390 this.script = script;
391 }
392
393
394
395
396 public boolean isRanged() {
397 return this.ranged;
398 }
399
400
401
402
403
404
405 public void setRanged(boolean ranged) {
406 this.ranged = ranged;
407 }
408
409
410
411
412 public boolean equals(Object object) {
413 if ( !(object instanceof ControlDefinitionBase) ) {
414 return false;
415 }
416 ControlDefinitionBase rhs = (ControlDefinitionBase)object;
417 return new EqualsBuilder()
418 .append( this.cols, rhs.cols )
419 .append( this.businessObjectClass, rhs.businessObjectClass )
420 .append( this.valuesFinderClass, rhs.valuesFinderClass )
421 .append( this.rows, rhs.rows )
422 .append( this.script, rhs.script )
423 .append( this.size, rhs.size )
424 .append( this.datePicker, rhs.datePicker )
425 .append( this.ranged, rhs.ranged )
426 .append( this.labelAttribute,rhs.labelAttribute )
427 .append( this.includeKeyInLabel, rhs.includeKeyInLabel )
428 .append( this.keyAttribute, rhs.keyAttribute )
429 .isEquals();
430 }
431
432
433 }