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 | 33 | public class BusinessObjectEntry extends DataObjectEntry { |
34 | |
|
35 | |
protected Class<? extends BusinessObject> baseBusinessObjectClass; |
36 | |
|
37 | 33 | protected boolean boNotesEnabled = false; |
38 | |
|
39 | |
protected List<InactivationBlockingDefinition> inactivationBlockingDefinitions; |
40 | |
|
41 | |
public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) { |
42 | 0 | super.setDataObjectClass(businessObjectClass); |
43 | |
|
44 | 0 | if (businessObjectClass == null) { |
45 | 0 | throw new IllegalArgumentException("invalid (null) dataObjectClass"); |
46 | |
} |
47 | |
|
48 | 0 | if (getRelationships() != null) { |
49 | 0 | for (RelationshipDefinition rd : getRelationships()) { |
50 | 0 | rd.setSourceClass(businessObjectClass); |
51 | |
} |
52 | |
} |
53 | 0 | } |
54 | |
|
55 | |
public Class<? extends BusinessObject> getBusinessObjectClass() { |
56 | 0 | return (Class<? extends BusinessObject>) super.getDataObjectClass(); |
57 | |
} |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
public void setBaseBusinessObjectClass(Class<? extends BusinessObject> baseBusinessObjectClass) { |
66 | 0 | this.baseBusinessObjectClass = baseBusinessObjectClass; |
67 | 0 | } |
68 | |
|
69 | |
public Class<? extends BusinessObject> getBaseBusinessObjectClass() { |
70 | 0 | return baseBusinessObjectClass; |
71 | |
} |
72 | |
|
73 | |
public boolean isBoNotesEnabled() { |
74 | 0 | return boNotesEnabled; |
75 | |
} |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
public void setBoNotesEnabled(boolean boNotesEnabled) { |
85 | 0 | this.boNotesEnabled = boNotesEnabled; |
86 | 0 | } |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
@Override |
92 | |
public void completeValidation() { |
93 | |
try { |
94 | |
|
95 | 0 | if (baseBusinessObjectClass != null && !baseBusinessObjectClass.isAssignableFrom(getDataObjectClass())) { |
96 | 0 | throw new ClassValidationException("The baseBusinessObjectClass " + baseBusinessObjectClass.getName() + |
97 | |
" is not a superclass of the dataObjectClass " + getDataObjectClass().getName()); |
98 | |
} |
99 | |
|
100 | 0 | super.completeValidation(); |
101 | |
|
102 | 0 | if (inactivationBlockingDefinitions != null && !inactivationBlockingDefinitions.isEmpty()) { |
103 | 0 | for (InactivationBlockingDefinition inactivationBlockingDefinition : inactivationBlockingDefinitions) { |
104 | 0 | inactivationBlockingDefinition.completeValidation(getDataObjectClass(), null); |
105 | |
} |
106 | |
} |
107 | 0 | } catch (DataDictionaryException ex) { |
108 | |
|
109 | 0 | throw ex; |
110 | 0 | } catch (Exception ex) { |
111 | 0 | throw new DataDictionaryException("Exception validating " + this, ex); |
112 | 0 | } |
113 | 0 | } |
114 | |
|
115 | |
public List<InactivationBlockingDefinition> getInactivationBlockingDefinitions() { |
116 | 0 | return this.inactivationBlockingDefinitions; |
117 | |
} |
118 | |
|
119 | |
public void setInactivationBlockingDefinitions( |
120 | |
List<InactivationBlockingDefinition> inactivationBlockingDefinitions) { |
121 | 0 | this.inactivationBlockingDefinitions = inactivationBlockingDefinitions; |
122 | 0 | } |
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
@SuppressWarnings("unchecked") |
128 | |
@Override |
129 | |
public void afterPropertiesSet() throws Exception { |
130 | 0 | super.afterPropertiesSet(); |
131 | 0 | if (inactivationBlockingDefinitions != null) { |
132 | 0 | for (InactivationBlockingDefinition ibd : inactivationBlockingDefinitions) { |
133 | 0 | ibd.setBusinessObjectClass(getBusinessObjectClass()); |
134 | 0 | if (StringUtils.isNotBlank(ibd.getBlockedReferencePropertyName()) && |
135 | |
ibd.getBlockedBusinessObjectClass() == null) { |
136 | |
|
137 | 0 | ibd.setBlockedBusinessObjectClass(DataDictionary |
138 | |
.getAttributeClass(getDataObjectClass(), ibd.getBlockedReferencePropertyName())); |
139 | |
} |
140 | 0 | ibd.setBlockingReferenceBusinessObjectClass(getBusinessObjectClass()); |
141 | |
} |
142 | |
} |
143 | 0 | } |
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
@Override |
149 | |
public String toString() { |
150 | 0 | return "BusinessObjectEntry for " + getBusinessObjectClass(); |
151 | |
} |
152 | |
} |