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