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