| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.kuali.rice.kns.datadictionary; |
| 18 |
|
|
| 19 |
|
import java.math.BigDecimal; |
| 20 |
|
|
| 21 |
|
import org.apache.commons.lang.ClassUtils; |
| 22 |
|
import org.apache.commons.lang.StringUtils; |
| 23 |
|
import org.apache.log4j.Logger; |
| 24 |
|
import org.kuali.rice.core.util.ClassLoaderUtils; |
| 25 |
|
import org.kuali.rice.core.web.format.Formatter; |
| 26 |
|
import org.kuali.rice.kns.datadictionary.control.ControlDefinition; |
| 27 |
|
import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException; |
| 28 |
|
import org.kuali.rice.kns.datadictionary.exception.ClassValidationException; |
| 29 |
|
import org.kuali.rice.kns.datadictionary.validation.ValidationPattern; |
| 30 |
|
import org.springframework.beans.factory.InitializingBean; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
|
|
|
| 0% |
Uncovered Elements: 133 (133) |
Complexity: 55 |
Complexity Density: 0.82 |
|
| 39 |
|
public class AttributeDefinition extends DataDictionaryDefinitionBase implements InitializingBean { |
| 40 |
|
private static final long serialVersionUID = -2490613377818442742L; |
| 41 |
|
|
| 42 |
|
protected Boolean forceUppercase = Boolean.FALSE; |
| 43 |
|
|
| 44 |
|
protected String name; |
| 45 |
|
protected String label; |
| 46 |
|
protected String shortLabel; |
| 47 |
|
protected String displayLabelAttribute; |
| 48 |
|
|
| 49 |
|
protected Integer maxLength; |
| 50 |
|
protected Boolean unique; |
| 51 |
|
|
| 52 |
|
protected BigDecimal exclusiveMin; |
| 53 |
|
protected BigDecimal inclusiveMax; |
| 54 |
|
|
| 55 |
|
protected ValidationPattern validationPattern; |
| 56 |
|
protected Boolean required = Boolean.FALSE; |
| 57 |
|
|
| 58 |
|
protected ControlDefinition control; |
| 59 |
|
|
| 60 |
|
protected String summary; |
| 61 |
|
protected String description; |
| 62 |
|
|
| 63 |
|
protected String formatterClass; |
| 64 |
|
|
| 65 |
|
protected AttributeSecurity attributeSecurity; |
| 66 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 67 |
0
|
public AttributeDefinition() {}... |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 74 |
0
|
public void setForceUppercase(Boolean forceUppercase) {... |
| 75 |
0
|
this.forceUppercase = forceUppercase; |
| 76 |
|
} |
| 77 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 78 |
0
|
public Boolean getForceUppercase() {... |
| 79 |
0
|
return this.forceUppercase; |
| 80 |
|
} |
| 81 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 82 |
0
|
public String getName() {... |
| 83 |
0
|
return name; |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 89 |
0
|
public void setName(String name) {... |
| 90 |
0
|
if (StringUtils.isBlank(name)) { |
| 91 |
0
|
throw new IllegalArgumentException("invalid (blank) name"); |
| 92 |
|
} |
| 93 |
0
|
this.name = name; |
| 94 |
|
} |
| 95 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 96 |
0
|
public String getLabel() {... |
| 97 |
0
|
return label; |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 105 |
0
|
public void setLabel(String label) {... |
| 106 |
0
|
if (StringUtils.isBlank(label)) { |
| 107 |
0
|
throw new IllegalArgumentException("invalid (blank) label"); |
| 108 |
|
} |
| 109 |
0
|
this.label = label; |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
@return |
| 114 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 115 |
0
|
public String getShortLabel() {... |
| 116 |
0
|
return (shortLabel != null) ? shortLabel : getLabel(); |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
@return |
| 121 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 122 |
0
|
protected String getDirectShortLabel() {... |
| 123 |
0
|
return shortLabel; |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 131 |
0
|
public void setShortLabel(String shortLabel) {... |
| 132 |
0
|
if (StringUtils.isBlank(shortLabel)) { |
| 133 |
0
|
throw new IllegalArgumentException("invalid (blank) shortLabel"); |
| 134 |
|
} |
| 135 |
0
|
this.shortLabel = shortLabel; |
| 136 |
|
} |
| 137 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 138 |
0
|
public Integer getMaxLength() {... |
| 139 |
0
|
return maxLength; |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 146 |
0
|
public void setMaxLength(Integer maxLength) {... |
| 147 |
0
|
this.maxLength = maxLength; |
| 148 |
|
} |
| 149 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 150 |
0
|
public BigDecimal getExclusiveMin() {... |
| 151 |
0
|
return exclusiveMin; |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 159 |
0
|
public void setExclusiveMin(BigDecimal exclusiveMin) {... |
| 160 |
0
|
this.exclusiveMin = exclusiveMin; |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 170 |
0
|
public BigDecimal getInclusiveMax() {... |
| 171 |
0
|
return inclusiveMax; |
| 172 |
|
} |
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 181 |
0
|
public void setInclusiveMax(BigDecimal inclusiveMax) {... |
| 182 |
0
|
this.inclusiveMax = inclusiveMax; |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
|
| 186 |
|
@return |
| 187 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 188 |
0
|
public boolean hasValidationPattern() {... |
| 189 |
0
|
return (validationPattern != null); |
| 190 |
|
} |
| 191 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 192 |
0
|
public ValidationPattern getValidationPattern() {... |
| 193 |
0
|
return this.validationPattern; |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
| 225 |
|
|
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
|
| 242 |
|
|
| 243 |
|
|
| 244 |
|
|
| 245 |
|
|
| 246 |
|
|
| 247 |
|
|
| 248 |
|
|
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
|
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 259 |
0
|
public void setValidationPattern(ValidationPattern validationPattern) {... |
| 260 |
0
|
this.validationPattern = validationPattern; |
| 261 |
|
} |
| 262 |
|
|
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 269 |
0
|
public void setRequired(Boolean required) {... |
| 270 |
0
|
this.required = required; |
| 271 |
|
} |
| 272 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 273 |
0
|
public Boolean isRequired() {... |
| 274 |
0
|
return this.required; |
| 275 |
|
} |
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
@return |
| 280 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 281 |
0
|
public ControlDefinition getControl() {... |
| 282 |
0
|
return control; |
| 283 |
|
} |
| 284 |
|
|
| 285 |
|
|
| 286 |
|
|
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
|
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
|
| 295 |
|
|
| 296 |
|
|
| 297 |
|
|
| 298 |
|
|
| 299 |
|
|
| 300 |
|
|
| 301 |
|
|
| 302 |
|
|
| 303 |
|
|
| 304 |
|
|
| 305 |
|
|
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
|
| 311 |
|
|
| 312 |
|
|
| 313 |
|
|
| 314 |
|
|
| 315 |
|
|
| 316 |
|
|
| 317 |
|
|
| 318 |
|
|
| 319 |
|
|
| 320 |
|
|
| 321 |
|
|
| 322 |
|
|
| 323 |
|
|
| 324 |
|
|
| 325 |
|
|
| 326 |
|
|
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| 330 |
|
|
| 331 |
|
|
| 332 |
|
|
| 333 |
|
@param |
| 334 |
|
@throws |
| 335 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 336 |
0
|
public void setControl(ControlDefinition control) {... |
| 337 |
0
|
if (control == null) { |
| 338 |
0
|
throw new IllegalArgumentException("invalid (null) control"); |
| 339 |
|
} |
| 340 |
0
|
this.control = control; |
| 341 |
|
} |
| 342 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 343 |
0
|
public String getSummary() {... |
| 344 |
0
|
return summary; |
| 345 |
|
} |
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 351 |
0
|
public void setSummary(String summary) {... |
| 352 |
0
|
this.summary = summary; |
| 353 |
|
} |
| 354 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 355 |
0
|
public String getDescription() {... |
| 356 |
0
|
return description; |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
|
| 360 |
|
|
| 361 |
|
|
| 362 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 363 |
0
|
public void setDescription(String description) {... |
| 364 |
0
|
this.description = description; |
| 365 |
|
} |
| 366 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 367 |
0
|
public boolean hasFormatterClass() {... |
| 368 |
0
|
return (formatterClass != null); |
| 369 |
|
} |
| 370 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 371 |
0
|
public String getFormatterClass() {... |
| 372 |
0
|
return formatterClass; |
| 373 |
|
} |
| 374 |
|
|
| 375 |
|
|
| 376 |
|
|
| 377 |
|
|
| 378 |
|
|
| 379 |
|
|
| 380 |
|
|
| 381 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 382 |
0
|
public void setFormatterClass(String formatterClass) {... |
| 383 |
0
|
if (formatterClass == null) { |
| 384 |
0
|
throw new IllegalArgumentException("invalid (null) formatterClass"); |
| 385 |
|
} |
| 386 |
0
|
this.formatterClass = formatterClass; |
| 387 |
|
} |
| 388 |
|
|
| 389 |
|
|
| 390 |
|
|
| 391 |
|
|
| 392 |
|
@see |
| 393 |
|
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 9 |
Complexity Density: 0.5 |
|
| 394 |
0
|
public void completeValidation(Class rootObjectClass, Class otherObjectClass) {... |
| 395 |
0
|
try { |
| 396 |
0
|
if (!DataDictionary.isPropertyOf(rootObjectClass, getName())) { |
| 397 |
0
|
throw new AttributeValidationException("property '" + getName() + "' is not a property of class '" + rootObjectClass.getName() + "' (" + "" + ")"); |
| 398 |
|
} |
| 399 |
|
|
| 400 |
0
|
if ( getControl() == null ) { |
| 401 |
0
|
throw new AttributeValidationException( "property '" + getName() + "' in class '" + rootObjectClass.getName() + " does not have a control defined" ); |
| 402 |
|
} |
| 403 |
|
|
| 404 |
0
|
getControl().completeValidation(rootObjectClass, otherObjectClass); |
| 405 |
|
|
| 406 |
0
|
if(attributeSecurity != null){ |
| 407 |
0
|
attributeSecurity.completeValidation(rootObjectClass, otherObjectClass); |
| 408 |
|
} |
| 409 |
|
|
| 410 |
0
|
if (validationPattern != null) { |
| 411 |
0
|
validationPattern.completeValidation(); |
| 412 |
|
} |
| 413 |
|
|
| 414 |
0
|
if (formatterClass != null) { |
| 415 |
0
|
try { |
| 416 |
0
|
Class formatterClassObject = ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getFormatterClass()); |
| 417 |
0
|
if (!Formatter.class.isAssignableFrom(formatterClassObject)) { |
| 418 |
0
|
throw new ClassValidationException("formatterClass is not a valid instance of " + Formatter.class.getName() + " instead was: " + formatterClassObject.getName()); |
| 419 |
|
} |
| 420 |
|
} catch (ClassNotFoundException e) { |
| 421 |
0
|
throw new ClassValidationException("formatterClass could not be found: " + getFormatterClass(), e); |
| 422 |
|
} |
| 423 |
|
} |
| 424 |
|
} catch ( RuntimeException ex ) { |
| 425 |
0
|
Logger.getLogger(getClass()).error("Unable to validate attribute " + rootObjectClass + "." + getName() + ": " + ex.getMessage(), ex ); |
| 426 |
0
|
throw ex; |
| 427 |
|
} |
| 428 |
|
} |
| 429 |
|
|
| 430 |
|
|
| 431 |
|
|
| 432 |
|
@see |
| 433 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 434 |
0
|
@Override... |
| 435 |
|
public String toString() { |
| 436 |
0
|
return "AttributeDefinition for attribute " + getName(); |
| 437 |
|
} |
| 438 |
|
|
| 439 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 440 |
0
|
public String getDisplayLabelAttribute() {... |
| 441 |
0
|
return displayLabelAttribute; |
| 442 |
|
} |
| 443 |
|
|
| 444 |
|
|
| 445 |
|
|
| 446 |
|
|
| 447 |
|
|
| 448 |
|
|
| 449 |
|
|
| 450 |
|
|
| 451 |
|
|
| 452 |
|
|
| 453 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 454 |
0
|
public void setDisplayLabelAttribute(String displayLabelAttribute) {... |
| 455 |
0
|
this.displayLabelAttribute = displayLabelAttribute; |
| 456 |
|
} |
| 457 |
|
|
| 458 |
|
|
| 459 |
|
|
| 460 |
|
@return |
| 461 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 462 |
0
|
public AttributeSecurity getAttributeSecurity() {... |
| 463 |
0
|
return this.attributeSecurity; |
| 464 |
|
} |
| 465 |
|
|
| 466 |
|
|
| 467 |
|
|
| 468 |
|
@param |
| 469 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 470 |
0
|
public void setAttributeSecurity(AttributeSecurity attributeSecurity) {... |
| 471 |
0
|
this.attributeSecurity = attributeSecurity; |
| 472 |
|
} |
| 473 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 474 |
0
|
public boolean hasAttributeSecurity() {... |
| 475 |
0
|
return (attributeSecurity != null); |
| 476 |
|
} |
| 477 |
|
|
| 478 |
|
|
| 479 |
|
|
| 480 |
|
|
| 481 |
|
|
| 482 |
|
@see |
| 483 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 484 |
0
|
public void afterPropertiesSet() throws Exception {... |
| 485 |
0
|
if ( StringUtils.isEmpty(name) ) { |
| 486 |
0
|
throw new RuntimeException( "blank name for bean: " + id ); |
| 487 |
|
} |
| 488 |
|
|
| 489 |
|
} |
| 490 |
|
|
| 491 |
|
|
| 492 |
|
|
| 493 |
|
@return |
| 494 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 495 |
0
|
public Boolean getUnique() {... |
| 496 |
0
|
return this.unique; |
| 497 |
|
} |
| 498 |
|
|
| 499 |
|
|
| 500 |
|
|
| 501 |
|
@param |
| 502 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 503 |
0
|
public void setUnique(Boolean unique) {... |
| 504 |
0
|
this.unique = unique; |
| 505 |
|
} |
| 506 |
|
} |