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