1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.kuali.rice.kns.datadictionary; |
18 |
|
|
19 |
|
import org.apache.commons.lang.StringUtils; |
20 |
|
import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException; |
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
|
|
| 0% |
Uncovered Elements: 41 (41) |
Complexity: 20 |
Complexity Density: 0.91 |
|
37 |
|
public class PrimitiveAttributeDefinition extends DataDictionaryDefinitionBase { |
38 |
|
private static final long serialVersionUID = -715128943756700821L; |
39 |
|
|
40 |
|
protected String sourceName; |
41 |
|
protected String targetName; |
42 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
43 |
0
|
public PrimitiveAttributeDefinition() {}... |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@return |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
0
|
public String getSourceName() {... |
50 |
0
|
return sourceName; |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@throws |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
58 |
0
|
public void setSourceName(String sourceName) {... |
59 |
0
|
if (StringUtils.isBlank(sourceName)) { |
60 |
0
|
throw new IllegalArgumentException("invalid (blank) sourceName"); |
61 |
|
} |
62 |
|
|
63 |
0
|
this.sourceName = sourceName; |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
@return |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0
|
public String getTargetName() {... |
71 |
0
|
return targetName; |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
@throws |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
79 |
0
|
public void setTargetName(String targetName) {... |
80 |
0
|
if (StringUtils.isBlank(targetName)) { |
81 |
0
|
throw new IllegalArgumentException("invalid (blank) targetName"); |
82 |
|
} |
83 |
|
|
84 |
0
|
this.targetName = targetName; |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
@see |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 12 |
Complexity Density: 0.92 |
|
93 |
0
|
public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {... |
94 |
0
|
if (!DataDictionary.isPropertyOf(rootBusinessObjectClass, sourceName)) { |
95 |
0
|
throw new AttributeValidationException("unable to find attribute '" + sourceName + "' in relationship class '" + rootBusinessObjectClass + "' (" + "" + ")"); |
96 |
|
} |
97 |
0
|
if (!DataDictionary.isPropertyOf(otherBusinessObjectClass, targetName)) { |
98 |
0
|
throw new AttributeValidationException("unable to find attribute '" + targetName + "' in related class '" + otherBusinessObjectClass.getName() + "' (" + "" + ")"); |
99 |
|
} |
100 |
|
|
101 |
0
|
Class sourceClass = DataDictionary.getAttributeClass(rootBusinessObjectClass, sourceName); |
102 |
0
|
Class targetClass = DataDictionary.getAttributeClass(otherBusinessObjectClass, targetName); |
103 |
0
|
if ((null == sourceClass && null != targetClass) || (null != sourceClass && null == targetClass) || !StringUtils.equals(sourceClass.getName(), targetClass.getName())) { |
104 |
0
|
String sourceClassName = rootBusinessObjectClass.getName(); |
105 |
0
|
String targetClassName = otherBusinessObjectClass.getName(); |
106 |
0
|
String sourcePath = sourceClassName + "." + sourceName; |
107 |
0
|
String targetPath = targetClassName + "." + targetName; |
108 |
|
|
109 |
|
|
110 |
0
|
if ((sourcePath != null && !StringUtils.contains(sourcePath, ".principalId")) && (targetPath != null && !StringUtils.contains(targetPath, ".principalId"))) { |
111 |
0
|
throw new AttributeValidationException("source attribute '" + sourcePath + "' (" + sourceClass + ") and target attribute '" + targetPath + "' (" + targetClass + ") are of differing types (" + "" + ")"); |
112 |
|
} |
113 |
|
} |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
@see |
119 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
0
|
@Override... |
121 |
|
public String toString() { |
122 |
0
|
return "PrimitiveAttributeDefinition (" + getSourceName()+","+getTargetName()+")"; |
123 |
|
} |
124 |
|
} |