1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary;
17
18 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
22 import org.kuali.rice.krad.util.ExternalizableBusinessObjectUtils;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 @BeanTag(name = "supportAttributeDefinition-bean")
39 public class SupportAttributeDefinition extends PrimitiveAttributeDefinition {
40 private static final long serialVersionUID = -1719022365280776405L;
41
42 protected boolean identifier;
43
44 public SupportAttributeDefinition() {}
45
46 @BeanTagAttribute(name = "identifier")
47 public boolean isIdentifier() {
48 return identifier;
49 }
50
51
52
53
54
55 public void setIdentifier(boolean identifier) {
56 this.identifier = identifier;
57 }
58
59
60
61
62
63
64
65 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
66 if (!DataDictionary.isPropertyOf(rootBusinessObjectClass, getSourceName())) {
67 throw new AttributeValidationException("unable to find attribute '"
68 + getSourceName()
69 + "' in relationship class '"
70 + rootBusinessObjectClass
71 + "' ("
72 + ""
73 + ")");
74 }
75 if (!DataDictionary.isPropertyOf(otherBusinessObjectClass, getTargetName())
76 && !ExternalizableBusinessObjectUtils.isExternalizableBusinessObjectInterface(
77 otherBusinessObjectClass)) {
78 throw new AttributeValidationException(
79 "unable to find attribute '" + getTargetName() + "' in related class '" + otherBusinessObjectClass
80 .getName() + "' (" + "" + ")");
81 }
82 }
83
84
85
86
87
88
89 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass,
90 ValidationTrace tracer) {
91 tracer.addBean(this.getClass().getSimpleName(), ValidationTrace.NO_BEAN_ID);
92 try {
93 if (!DataDictionary.isPropertyOf(rootBusinessObjectClass, getSourceName())) {
94 String currentValues[] = {"attribute = " + getSourceName(), "class = " + rootBusinessObjectClass};
95 tracer.createError("Unable to find attribute in class", currentValues);
96 }
97 if (!DataDictionary.isPropertyOf(otherBusinessObjectClass, getTargetName())
98 && !ExternalizableBusinessObjectUtils.isExternalizableBusinessObjectInterface(
99 otherBusinessObjectClass)) {
100
101 String currentValues[] = {"attribute = " + getTargetName(), "class = " + otherBusinessObjectClass};
102 tracer.createError("Unable to find attribute in class", currentValues);
103 }
104 } catch (RuntimeException ex) {
105 String currentValues[] = {"Exception = " + ex.getMessage()};
106 tracer.createError("Unable to validate attribute", currentValues);
107 }
108 }
109
110
111
112
113 @Override
114 public String toString() {
115 return "SupportAttributeDefinition (" + getSourceName() + "," + getTargetName() + "," + identifier + ")";
116 }
117
118 }
119