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