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