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.validator.ErrorReport;
20 import org.kuali.rice.krad.datadictionary.validator.TracerToken;
21 import org.kuali.rice.krad.util.ExternalizableBusinessObjectUtils;
22
23 import java.util.ArrayList;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 public class SupportAttributeDefinition extends PrimitiveAttributeDefinition {
40 private static final long serialVersionUID = -1719022365280776405L;
41
42 protected boolean identifier;
43
44 public SupportAttributeDefinition() {}
45
46 public boolean isIdentifier() {
47 return identifier;
48 }
49
50
51
52
53
54 public void setIdentifier(boolean identifier) {
55 this.identifier = identifier;
56 }
57
58
59
60
61
62
63 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
64 if (!DataDictionary.isPropertyOf(rootBusinessObjectClass, getSourceName())) {
65 throw new AttributeValidationException("unable to find attribute '" + getSourceName() + "' in relationship class '" + rootBusinessObjectClass + "' (" + "" + ")");
66 }
67 if (!DataDictionary.isPropertyOf(otherBusinessObjectClass, getTargetName())
68 && !ExternalizableBusinessObjectUtils.isExternalizableBusinessObjectInterface( otherBusinessObjectClass )) {
69 throw new AttributeValidationException("unable to find attribute '" + getTargetName() + "' in related class '" + otherBusinessObjectClass.getName() + "' (" + "" + ")");
70 }
71 }
72
73
74
75
76
77
78 public ArrayList<ErrorReport> completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass, TracerToken tracer) {
79 ArrayList<ErrorReport> reports = new ArrayList<ErrorReport>();
80 tracer.addBean(this.getClass().getSimpleName(),TracerToken.NO_BEAN_ID);
81
82 try{
83 if (!DataDictionary.isPropertyOf(rootBusinessObjectClass, getSourceName())) {
84 ErrorReport error = ErrorReport.createError("Unable to find attribute in class", tracer);
85 error.addCurrentValue("attribute = "+getSourceName());
86 error.addCurrentValue("class = "+rootBusinessObjectClass);
87 reports.add(error);
88 }
89 if (!DataDictionary.isPropertyOf(otherBusinessObjectClass, getTargetName())
90 && !ExternalizableBusinessObjectUtils.isExternalizableBusinessObjectInterface( otherBusinessObjectClass )) {
91 ErrorReport error = ErrorReport.createError("Unable to find attribute in class", tracer);
92 error.addCurrentValue("attribute = "+getTargetName());
93 error.addCurrentValue("class = "+otherBusinessObjectClass);
94 reports.add(error);
95 }
96 }catch (RuntimeException ex) {
97 ErrorReport error = ErrorReport.createError("Unable to validate attribute",tracer);
98 error.addCurrentValue("Exception = "+ex.getMessage());
99 reports.add(error);
100 }
101
102
103 return reports;
104 }
105
106
107
108
109 @Override
110 public String toString() {
111 return "SupportAttributeDefinition (" + getSourceName()+","+getTargetName()+","+identifier+")";
112 }
113
114 }
115