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 org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
public class ApcRuleDefinition extends DataDictionaryDefinitionBase { |
35 | |
private static final long serialVersionUID = 8600032669267029028L; |
36 | |
|
37 | |
protected String attributeName; |
38 | |
protected String parameterNamespace; |
39 | |
protected String parameterDetailType; |
40 | |
protected String parameterName; |
41 | |
protected String errorMessage; |
42 | |
|
43 | |
|
44 | 0 | public ApcRuleDefinition() { |
45 | 0 | } |
46 | |
|
47 | |
public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) { |
48 | |
|
49 | |
|
50 | 0 | if (!DataDictionary.isPropertyOf(rootBusinessObjectClass, attributeName)) { |
51 | 0 | throw new AttributeValidationException("unable to find attribute '" + attributeName + "' in rootBusinessObjectClass '" + rootBusinessObjectClass.getName() + "'" ); |
52 | |
} |
53 | |
|
54 | |
|
55 | 0 | Class attributeClass = DataDictionary.getAttributeClass(rootBusinessObjectClass, attributeName); |
56 | 0 | if (!attributeClass.equals(String.class)) { |
57 | 0 | throw new AttributeValidationException("the attribute '" + attributeName + "' in rootBusinessObjectClass '" + rootBusinessObjectClass.getName() + "' is of type '" + attributeClass.getName() + "'. These attributes may only be string." ); |
58 | |
} |
59 | |
|
60 | |
|
61 | 0 | } |
62 | |
|
63 | |
public String getParameterNamespace() { |
64 | 0 | return parameterNamespace; |
65 | |
} |
66 | |
|
67 | |
public void setParameterNamespace(String parameterNamespace) { |
68 | 0 | if (StringUtils.isBlank(parameterNamespace)) { |
69 | 0 | throw new IllegalArgumentException("invalid (blank) parameterNamespace"); |
70 | |
} |
71 | 0 | this.parameterNamespace = parameterNamespace; |
72 | 0 | } |
73 | |
|
74 | |
public String getParameterName() { |
75 | 0 | return parameterName; |
76 | |
} |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
void setParameterName(String parameterName) { |
89 | 0 | if (StringUtils.isBlank(parameterName)) { |
90 | 0 | throw new IllegalArgumentException("invalid (blank) parameterName"); |
91 | |
} |
92 | 0 | this.parameterName = parameterName; |
93 | 0 | } |
94 | |
|
95 | |
public String getAttributeName() { |
96 | 0 | return attributeName; |
97 | |
} |
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
public void setAttributeName(String attributeName) { |
110 | 0 | if (StringUtils.isBlank(attributeName)) { |
111 | 0 | throw new IllegalArgumentException("invalid (blank) attributeName"); |
112 | |
} |
113 | 0 | this.attributeName = attributeName; |
114 | 0 | } |
115 | |
|
116 | |
public String getErrorMessage() { |
117 | 0 | return errorMessage; |
118 | |
} |
119 | |
|
120 | |
public void setErrorMessage(String errorMessage) { |
121 | 0 | if (StringUtils.isBlank(errorMessage)) { |
122 | 0 | throw new IllegalArgumentException("invalid (blank) errorMessage"); |
123 | |
} |
124 | 0 | this.errorMessage = errorMessage; |
125 | 0 | } |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
public String toString() { |
131 | 0 | return "ApcRuleDefinition for attribute " + getAttributeName(); |
132 | |
} |
133 | |
|
134 | |
public String getParameterDetailType() { |
135 | 0 | return this.parameterDetailType; |
136 | |
} |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
public void setParameterDetailType(String parameterDetailType) { |
149 | 0 | if (StringUtils.isBlank(parameterDetailType)) { |
150 | 0 | throw new IllegalArgumentException("invalid (blank) parameterDetailType"); |
151 | |
} |
152 | 0 | this.parameterDetailType = parameterDetailType; |
153 | 0 | } |
154 | |
} |