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.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.krad.bo.BusinessObject; |
20 | |
import org.kuali.rice.krad.datadictionary.exception.ClassValidationException; |
21 | |
|
22 | |
import java.util.List; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | 100 | public class BusinessObjectEntry extends DataObjectEntry { |
33 | |
|
34 | |
protected Class<? extends BusinessObject> baseBusinessObjectClass; |
35 | |
|
36 | |
public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) { |
37 | 0 | super.setDataObjectClass(businessObjectClass); |
38 | |
|
39 | 0 | if (businessObjectClass == null) { |
40 | 0 | throw new IllegalArgumentException("invalid (null) dataObjectClass"); |
41 | |
} |
42 | |
|
43 | 0 | if (getRelationships() != null) { |
44 | 0 | for (RelationshipDefinition rd : getRelationships()) { |
45 | 0 | rd.setSourceClass(businessObjectClass); |
46 | |
} |
47 | |
} |
48 | 0 | } |
49 | |
|
50 | |
public Class<? extends BusinessObject> getBusinessObjectClass() { |
51 | 0 | return (Class<? extends BusinessObject>) super.getDataObjectClass(); |
52 | |
} |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
public void setBaseBusinessObjectClass(Class<? extends BusinessObject> baseBusinessObjectClass) { |
61 | 0 | this.baseBusinessObjectClass = baseBusinessObjectClass; |
62 | 0 | } |
63 | |
|
64 | |
public Class<? extends BusinessObject> getBaseBusinessObjectClass() { |
65 | 0 | return baseBusinessObjectClass; |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
@Override |
72 | |
public void completeValidation() { |
73 | |
try { |
74 | |
|
75 | 0 | if (baseBusinessObjectClass != null && !baseBusinessObjectClass.isAssignableFrom(getDataObjectClass())) { |
76 | 0 | throw new ClassValidationException("The baseBusinessObjectClass " + baseBusinessObjectClass.getName() + |
77 | |
" is not a superclass of the dataObjectClass " + getDataObjectClass().getName()); |
78 | |
} |
79 | |
|
80 | 0 | super.completeValidation(); |
81 | |
|
82 | 0 | if (inactivationBlockingDefinitions != null && !inactivationBlockingDefinitions.isEmpty()) { |
83 | 0 | for (InactivationBlockingDefinition inactivationBlockingDefinition : inactivationBlockingDefinitions) { |
84 | 0 | inactivationBlockingDefinition.completeValidation(getDataObjectClass(), null); |
85 | |
} |
86 | |
} |
87 | 0 | } catch (DataDictionaryException ex) { |
88 | |
|
89 | 0 | throw ex; |
90 | 0 | } catch (Exception ex) { |
91 | 0 | throw new DataDictionaryException("Exception validating " + this, ex); |
92 | 0 | } |
93 | 0 | } |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
@SuppressWarnings("unchecked") |
99 | |
@Override |
100 | |
public void afterPropertiesSet() throws Exception { |
101 | 0 | super.afterPropertiesSet(); |
102 | 0 | if (inactivationBlockingDefinitions != null) { |
103 | 0 | for (InactivationBlockingDefinition ibd : inactivationBlockingDefinitions) { |
104 | 0 | ibd.setBusinessObjectClass(getBusinessObjectClass()); |
105 | 0 | if (StringUtils.isNotBlank(ibd.getBlockedReferencePropertyName()) && |
106 | |
ibd.getBlockedBusinessObjectClass() == null) { |
107 | |
|
108 | 0 | ibd.setBlockedBusinessObjectClass(DataDictionary |
109 | |
.getAttributeClass(getDataObjectClass(), ibd.getBlockedReferencePropertyName())); |
110 | |
} |
111 | 0 | ibd.setBlockingReferenceBusinessObjectClass(getBusinessObjectClass()); |
112 | |
} |
113 | |
} |
114 | 0 | } |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
@Override |
120 | |
public String toString() { |
121 | 0 | return "BusinessObjectEntry for " + getBusinessObjectClass(); |
122 | |
} |
123 | |
} |