1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
21 import org.kuali.rice.krad.datadictionary.validation.capability.CollectionSizeConstrainable;
22 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
23
24
25
26
27
28
29
30
31
32
33
34
35
36 @BeanTag(name = "collectionDefinition-bean")
37 public class CollectionDefinition extends DataDictionaryDefinitionBase implements CollectionSizeConstrainable {
38 private static final long serialVersionUID = -2644072136271281041L;
39
40 protected String dataObjectClass;
41
42 protected String name;
43
44 protected String label;
45
46 protected String shortLabel;
47
48 protected String elementLabel;
49
50 protected String summary;
51
52 protected String description;
53
54 protected Integer minOccurs;
55
56 protected Integer maxOccurs;
57
58
59
60
61 public CollectionDefinition() {
62
63 }
64
65
66
67
68
69
70 public String getName() {
71 return name;
72 }
73
74
75
76
77
78
79
80 public void setName(String name) {
81 if (StringUtils.isBlank(name)) {
82 throw new IllegalArgumentException("invalid (blank) name");
83 }
84 this.name = name;
85 }
86
87
88
89
90
91
92 public String getLabel() {
93 return label;
94 }
95
96
97
98
99
100
101 public void setLabel(String label) {
102 if (StringUtils.isBlank(label)) {
103 throw new IllegalArgumentException("invalid (blank) label");
104 }
105 this.label = label;
106 }
107
108
109
110
111
112
113 public String getShortLabel() {
114 return (shortLabel != null) ? shortLabel : label;
115 }
116
117
118
119
120
121
122
123 public void setShortLabel(String shortLabel) {
124 if (StringUtils.isBlank(shortLabel)) {
125 throw new IllegalArgumentException("invalid (blank) shortLabel");
126 }
127 this.shortLabel = shortLabel;
128 }
129
130
131
132
133
134
135 public String getElementLabel() {
136 return elementLabel;
137 }
138
139
140
141
142
143
144
145
146 public void setElementLabel(String elementLabel) {
147 this.elementLabel = elementLabel;
148 }
149
150
151
152
153
154
155
156
157
158 public String getSummary() {
159 return summary;
160 }
161
162
163
164
165 public void setSummary(String summary) {
166 this.summary = summary;
167 }
168
169
170
171
172
173
174
175
176
177 public String getDescription() {
178 return description;
179 }
180
181
182
183
184
185
186 public void setDescription(String description) {
187 this.description = description;
188 }
189
190
191
192
193
194
195
196
197 public String getDataObjectClass() {
198 return this.dataObjectClass;
199 }
200
201
202
203
204
205
206 public void setDataObjectClass(String dataObjectClass) {
207 this.dataObjectClass = dataObjectClass;
208 }
209
210
211
212
213
214
215 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
216 if (!DataDictionary.isCollectionPropertyOf(rootBusinessObjectClass, name)) {
217 throw new AttributeValidationException("property '"
218 + name
219 + "' is not a collection property of class '"
220 + rootBusinessObjectClass
221 + "' ("
222 + ""
223 + ")");
224 }
225 }
226
227
228
229
230
231
232
233 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass,
234 ValidationTrace tracer) {
235 tracer.addBean(this.getClass().getSimpleName(), "Attribute: " + getName());
236 if (!DataDictionary.isCollectionPropertyOf(rootBusinessObjectClass, name)) {
237 String currentValues[] = {"property = " + getName(), "Class =" + rootBusinessObjectClass};
238 tracer.createError("Property is not collection property of the class", currentValues);
239 }
240 }
241
242
243
244
245
246 @Override
247 public String toString() {
248 return "CollectionDefinition for collection " + getName();
249 }
250
251
252
253
254 @Override
255 public Integer getMaximumNumberOfElements() {
256 return this.maxOccurs;
257 }
258
259
260
261
262 @Override
263 public Integer getMinimumNumberOfElements() {
264 return this.minOccurs;
265 }
266
267
268
269
270
271
272 public Integer getMinOccurs() {
273 return this.minOccurs;
274 }
275
276
277
278
279
280
281 public void setMinOccurs(Integer minOccurs) {
282 this.minOccurs = minOccurs;
283 }
284
285
286
287
288
289
290 public Integer getMaxOccurs() {
291 return this.maxOccurs;
292 }
293
294
295
296
297
298
299 public void setMaxOccurs(Integer maxOccurs) {
300 this.maxOccurs = maxOccurs;
301 }
302
303 }