1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.rice.kns.datadictionary; |
17 |
|
|
18 |
|
import java.util.ArrayList; |
19 |
|
import java.util.LinkedHashMap; |
20 |
|
import java.util.List; |
21 |
|
import java.util.Map; |
22 |
|
import java.util.Set; |
23 |
|
|
24 |
|
import org.apache.commons.lang.StringUtils; |
25 |
|
import org.kuali.rice.kns.datadictionary.exception.DuplicateEntryException; |
26 |
|
import org.kuali.rice.kns.exception.ValidationException; |
27 |
|
import org.springframework.beans.factory.InitializingBean; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
|
|
| 0% |
Uncovered Elements: 107 (107) |
Complexity: 29 |
Complexity Density: 0.45 |
|
34 |
|
abstract public class DataDictionaryEntryBase implements DataDictionaryEntry, InitializingBean { |
35 |
|
|
36 |
|
protected List<AttributeDefinition> attributes; |
37 |
|
protected List<CollectionDefinition> collections; |
38 |
|
protected List<RelationshipDefinition> relationships; |
39 |
|
protected Map<String, AttributeDefinition> attributeMap; |
40 |
|
protected Map<String, CollectionDefinition> collectionMap; |
41 |
|
protected Map<String, RelationshipDefinition> relationshipMap; |
42 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
43 |
0
|
public DataDictionaryEntryBase() {... |
44 |
0
|
this.attributes = new ArrayList<AttributeDefinition>(); |
45 |
0
|
this.collections = new ArrayList<CollectionDefinition>(); |
46 |
0
|
this.relationships = new ArrayList<RelationshipDefinition>(); |
47 |
0
|
this.attributeMap = new LinkedHashMap<String, AttributeDefinition>(); |
48 |
0
|
this.collectionMap = new LinkedHashMap<String, CollectionDefinition>(); |
49 |
0
|
this.relationshipMap = new LinkedHashMap<String, RelationshipDefinition>(); |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
public abstract Class getEntryClass(); |
54 |
|
|
55 |
|
|
56 |
|
@param |
57 |
|
@return |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
59 |
0
|
public AttributeDefinition getAttributeDefinition(String attributeName) {... |
60 |
0
|
if (StringUtils.isBlank(attributeName)) { |
61 |
0
|
throw new IllegalArgumentException("invalid (blank) attributeName"); |
62 |
|
} |
63 |
0
|
return (AttributeDefinition) attributeMap.get(attributeName); |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
|
@return |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0
|
public List<AttributeDefinition> getAttributes() {... |
70 |
0
|
return this.attributes; |
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
|
@param |
75 |
|
@return |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
77 |
0
|
public CollectionDefinition getCollectionDefinition(String collectionName) {... |
78 |
0
|
if (StringUtils.isBlank(collectionName)) { |
79 |
0
|
throw new IllegalArgumentException("invalid (blank) collectionName"); |
80 |
|
} |
81 |
0
|
return (CollectionDefinition) collectionMap.get(collectionName); |
82 |
|
} |
83 |
|
|
84 |
|
|
85 |
|
@return |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
0
|
public List<CollectionDefinition> getCollections() {... |
88 |
0
|
return this.collections; |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
@param |
93 |
|
@return |
94 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
95 |
0
|
public RelationshipDefinition getRelationshipDefinition(String relationshipName) {... |
96 |
0
|
if (StringUtils.isBlank(relationshipName)) { |
97 |
0
|
throw new IllegalArgumentException("invalid (blank) relationshipName"); |
98 |
|
} |
99 |
0
|
return (RelationshipDefinition) relationshipMap.get(relationshipName); |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
|
@return |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0
|
public List<RelationshipDefinition> getRelationships() {... |
106 |
0
|
return this.relationships; |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
113 |
0
|
public void completeValidation() {... |
114 |
|
|
115 |
0
|
for ( AttributeDefinition attributeDefinition : attributes ) { |
116 |
0
|
attributeDefinition.completeValidation(getEntryClass(), null); |
117 |
|
} |
118 |
|
|
119 |
0
|
for ( CollectionDefinition collectionDefinition : collections ) { |
120 |
0
|
collectionDefinition.completeValidation(getEntryClass(), null); |
121 |
|
} |
122 |
|
|
123 |
0
|
for ( RelationshipDefinition relationshipDefinition : relationships ) { |
124 |
0
|
relationshipDefinition.completeValidation(getEntryClass(), null); |
125 |
|
} |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 5 |
Complexity Density: 0.38 |
|
177 |
0
|
public void setAttributes(List<AttributeDefinition> attributes) {... |
178 |
0
|
attributeMap.clear(); |
179 |
0
|
for ( AttributeDefinition attribute : attributes ) { |
180 |
0
|
if (attribute == null) { |
181 |
0
|
throw new IllegalArgumentException("invalid (null) attributeDefinition"); |
182 |
|
} |
183 |
0
|
String attributeName = attribute.getName(); |
184 |
0
|
if (StringUtils.isBlank(attributeName)) { |
185 |
0
|
throw new ValidationException("invalid (blank) attributeName"); |
186 |
|
} |
187 |
|
|
188 |
0
|
if (attributeMap.containsKey(attributeName)) { |
189 |
0
|
throw new DuplicateEntryException("collection '" + attributeName + "' already defined as an Attribute for class '" + getEntryClass().getName() + "'"); |
190 |
0
|
} else if (collectionMap.containsKey(attributeName)) { |
191 |
0
|
throw new DuplicateEntryException("attribute '" + attributeName + "' already defined as a Collection for class '" + getEntryClass().getName() + "'"); |
192 |
|
} |
193 |
|
|
194 |
0
|
attributeMap.put(attributeName, attribute); |
195 |
|
} |
196 |
0
|
this.attributes = attributes; |
197 |
|
} |
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 5 |
Complexity Density: 0.38 |
|
227 |
0
|
public void setCollections(List<CollectionDefinition> collections) {... |
228 |
0
|
collectionMap.clear(); |
229 |
0
|
for ( CollectionDefinition collection : collections ) { |
230 |
0
|
if (collection == null) { |
231 |
0
|
throw new IllegalArgumentException("invalid (null) collectionDefinition"); |
232 |
|
} |
233 |
0
|
String collectionName = collection.getName(); |
234 |
0
|
if (StringUtils.isBlank(collectionName)) { |
235 |
0
|
throw new ValidationException("invalid (blank) collectionName"); |
236 |
|
} |
237 |
|
|
238 |
0
|
if (collectionMap.containsKey(collectionName)) { |
239 |
0
|
throw new DuplicateEntryException("collection '" + collectionName + "' already defined for class '" + getEntryClass().getName() + "'"); |
240 |
0
|
} else if (attributeMap.containsKey(collectionName)) { |
241 |
0
|
throw new DuplicateEntryException("collection '" + collectionName + "' already defined as an Attribute for class '" + getEntryClass().getName() + "'"); |
242 |
|
} |
243 |
|
|
244 |
0
|
collectionMap.put(collectionName, collection); |
245 |
|
|
246 |
|
} |
247 |
0
|
this.collections = collections; |
248 |
|
} |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
281 |
0
|
public void setRelationships(List<RelationshipDefinition> relationships) {... |
282 |
0
|
this.relationships = relationships; |
283 |
|
} |
284 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
285 |
0
|
public Set<String> getCollectionNames() {... |
286 |
0
|
return collectionMap.keySet(); |
287 |
|
} |
288 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
289 |
0
|
public Set<String> getAttributeNames() {... |
290 |
0
|
return attributeMap.keySet(); |
291 |
|
} |
292 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
293 |
0
|
public Set<String> getRelationshipNames() {... |
294 |
0
|
return relationshipMap.keySet(); |
295 |
|
} |
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
@see |
301 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
302 |
0
|
public void afterPropertiesSet() throws Exception {... |
303 |
0
|
if ( relationships != null ) { |
304 |
0
|
relationshipMap.clear(); |
305 |
0
|
for ( RelationshipDefinition relationship : relationships ) { |
306 |
0
|
if (relationship == null) { |
307 |
0
|
throw new IllegalArgumentException("invalid (null) relationshipDefinition"); |
308 |
|
} |
309 |
0
|
String relationshipName = relationship.getObjectAttributeName(); |
310 |
0
|
if (StringUtils.isBlank(relationshipName)) { |
311 |
0
|
throw new ValidationException("invalid (blank) relationshipName"); |
312 |
|
} |
313 |
0
|
relationship.setSourceClass(getEntryClass()); |
314 |
0
|
relationshipMap.put(relationshipName, relationship); |
315 |
|
} |
316 |
|
} |
317 |
|
} |
318 |
|
} |