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.krad.bo.BusinessObject;
20 import org.kuali.rice.krad.datadictionary.DataDictionary;
21 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
22 import org.kuali.rice.krad.datadictionary.exception.DuplicateEntryException;
23
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 @Deprecated
55 public class MaintainableCollectionDefinition extends MaintainableItemDefinition implements CollectionDefinitionI {
56 private static final long serialVersionUID = -5617868782623587053L;
57
58
59
60
61 protected Class<? extends BusinessObject> businessObjectClass;
62
63 protected Class<? extends BusinessObject> sourceClassName;
64 protected String summaryTitle;
65 protected String attributeToHighlightOnDuplicateKey;
66
67 protected boolean includeAddLine = true;
68 protected boolean includeMultipleLookupLine = true;
69 private boolean alwaysAllowCollectionDeletion = false;
70
71 protected Map<String,MaintainableFieldDefinition> maintainableFieldMap = new HashMap<String, MaintainableFieldDefinition>();
72 protected Map<String,MaintainableCollectionDefinition> maintainableCollectionMap = new HashMap<String, MaintainableCollectionDefinition>();
73 protected Map<String,MaintainableFieldDefinition> summaryFieldMap = new HashMap<String, MaintainableFieldDefinition>();
74 protected Map<String,MaintainableFieldDefinition> duplicateIdentificationFieldMap = new HashMap<String, MaintainableFieldDefinition>();
75 protected List<MaintainableFieldDefinition> maintainableFields = new ArrayList<MaintainableFieldDefinition>();
76 protected List<MaintainableCollectionDefinition> maintainableCollections = new ArrayList<MaintainableCollectionDefinition>();
77 protected List<MaintainableFieldDefinition> summaryFields = new ArrayList<MaintainableFieldDefinition>();
78 protected List<MaintainableFieldDefinition> duplicateIdentificationFields = new ArrayList<MaintainableFieldDefinition>();
79
80 public MaintainableCollectionDefinition() {}
81
82
83
84
85
86
87 public Class<? extends BusinessObject> getBusinessObjectClass() {
88 return businessObjectClass;
89 }
90
91
92
93
94 public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) {
95 if (businessObjectClass == null) {
96 throw new IllegalArgumentException("invalid (null) dataObjectClass");
97 }
98
99 this.businessObjectClass = businessObjectClass;
100 }
101
102
103
104
105
106 public List<MaintainableFieldDefinition> getMaintainableFields() {
107 return maintainableFields;
108 }
109
110 public List<? extends FieldDefinitionI> getFields() {
111 return maintainableFields;
112 }
113
114
115
116
117
118
119 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
120 if (!DataDictionary.isCollectionPropertyOf(rootBusinessObjectClass, getName())) {
121 throw new AttributeValidationException("unable to find collection named '" + getName() + "' in rootBusinessObjectClass '" + rootBusinessObjectClass.getName() + "' (" + "" + ")");
122 }
123
124 if (dissallowDuplicateKey()) {
125 if (!DataDictionary.isPropertyOf(businessObjectClass, attributeToHighlightOnDuplicateKey)) {
126 throw new AttributeValidationException("unable to find attribute named '" + attributeToHighlightOnDuplicateKey + "'in dataObjectClass '" + businessObjectClass.getName() + "' of collection '" + getName() + "' in rootBusinessObjectClass '" + rootBusinessObjectClass.getName() + "' (" + "" + ")");
127 }
128 }
129
130 for (MaintainableFieldDefinition maintainableField : maintainableFields ) {
131 maintainableField.completeValidation(businessObjectClass, null);
132 }
133
134 for (MaintainableCollectionDefinition maintainableCollection : maintainableCollections ) {
135 maintainableCollection.completeValidation(businessObjectClass, null);
136 }
137
138
139
140
141
142
143
144
145 }
146
147
148
149
150
151 public String toString() {
152 return "MaintainableCollectionDefinition for " + getName();
153 }
154
155
156 public Class<? extends BusinessObject> getSourceClassName() {
157 return sourceClassName;
158 }
159
160
161
162
163 public void setSourceClassName(Class<? extends BusinessObject> sourceClass) {
164 this.sourceClassName = sourceClass;
165 }
166
167 public boolean getIncludeAddLine() {
168 return includeAddLine;
169 }
170
171
172
173 public void setIncludeAddLine(boolean includeAddLine) {
174 this.includeAddLine = includeAddLine;
175 }
176
177
178
179
180
181 public List<MaintainableCollectionDefinition> getMaintainableCollections() {
182 return maintainableCollections;
183 }
184
185 public List<? extends CollectionDefinitionI> getCollections() {
186 return maintainableCollections;
187 }
188
189
190
191
192
193
194 public List<? extends FieldDefinitionI> getSummaryFields() {
195 return summaryFields;
196 }
197
198 public boolean hasSummaryField(String key) {
199 return summaryFieldMap.containsKey(key);
200 }
201
202 public boolean isIncludeMultipleLookupLine() {
203 return includeMultipleLookupLine;
204 }
205
206
207 public void setIncludeMultipleLookupLine(boolean includeMultipleLookupLine) {
208 this.includeMultipleLookupLine = includeMultipleLookupLine;
209 }
210
211 public String getSummaryTitle() {
212 return summaryTitle;
213 }
214
215
216
217
218 public void setSummaryTitle(String overrideSummaryName) {
219 this.summaryTitle = overrideSummaryName;
220 }
221
222
223 public String getAttributeToHighlightOnDuplicateKey() {
224 return attributeToHighlightOnDuplicateKey;
225 }
226
227
228
229
230
231
232 public void setAttributeToHighlightOnDuplicateKey(String attributeToHighlightOnDuplicate) {
233 this.attributeToHighlightOnDuplicateKey = attributeToHighlightOnDuplicate;
234 }
235
236 public boolean dissallowDuplicateKey() {
237 return StringUtils.isNotBlank(getAttributeToHighlightOnDuplicateKey());
238 }
239
240 public List<MaintainableFieldDefinition> getDuplicateIdentificationFields() {
241 return duplicateIdentificationFields;
242 }
243
244
245 public void setMaintainableFields(List<MaintainableFieldDefinition> maintainableFields) {
246 maintainableFieldMap.clear();
247 for ( MaintainableFieldDefinition maintainableField : maintainableFields ) {
248 if (maintainableField == null) {
249 throw new IllegalArgumentException("invalid (null) maintainableField");
250 }
251
252 String fieldName = maintainableField.getName();
253 if (maintainableFieldMap.containsKey(fieldName)) {
254 throw new DuplicateEntryException("duplicate fieldName entry for field '" + fieldName + "'");
255 }
256
257 maintainableFieldMap.put(fieldName, maintainableField);
258 }
259 this.maintainableFields = maintainableFields;
260 }
261
262
263 public void setMaintainableCollections(List<MaintainableCollectionDefinition> maintainableCollections) {
264 maintainableCollectionMap.clear();
265 for (MaintainableCollectionDefinition maintainableCollection : maintainableCollections ) {
266 if (maintainableCollection == null) {
267 throw new IllegalArgumentException("invalid (null) maintainableCollection");
268 }
269
270 String fieldName = maintainableCollection.getName();
271 if (maintainableCollectionMap.containsKey(fieldName)) {
272 throw new DuplicateEntryException("duplicate fieldName entry for field '" + fieldName + "'");
273 }
274
275 maintainableCollectionMap.put(fieldName, maintainableCollection);
276 }
277 this.maintainableCollections = maintainableCollections;
278 }
279
280
281
282
283
284
285 public void setSummaryFields(List<MaintainableFieldDefinition> summaryFields) {
286 summaryFieldMap.clear();
287 for (MaintainableFieldDefinition summaryField : summaryFields ) {
288 if (summaryField == null) {
289 throw new IllegalArgumentException("invalid (null) summaryField");
290 }
291
292 String fieldName = summaryField.getName();
293 if (summaryFieldMap.containsKey(fieldName)) {
294 throw new DuplicateEntryException("duplicate fieldName entry for field '" + fieldName + "'");
295 }
296
297 summaryFieldMap.put(fieldName, summaryField);
298 }
299 this.summaryFields = summaryFields;
300 }
301
302
303
304
305
306
307 public void setDuplicateIdentificationFields(List<MaintainableFieldDefinition> duplicateIdentificationFields) {
308 duplicateIdentificationFieldMap.clear();
309 for (MaintainableFieldDefinition identifierField : duplicateIdentificationFields) {
310 if (identifierField == null) {
311 throw new IllegalArgumentException("invalid (null) identifierField");
312 }
313
314 String fieldName = identifierField.getName();
315 if (duplicateIdentificationFieldMap.containsKey(fieldName)) {
316 throw new DuplicateEntryException("duplicate fieldName entry for field '" + fieldName + "'");
317 }
318
319 duplicateIdentificationFieldMap.put(fieldName, identifierField);
320 }
321 this.duplicateIdentificationFields = duplicateIdentificationFields;
322 }
323
324
325
326 public boolean isAlwaysAllowCollectionDeletion() {
327 return this.alwaysAllowCollectionDeletion;
328 }
329
330
331
332 public void setAlwaysAllowCollectionDeletion(
333 boolean alwaysAllowCollectionDeletion) {
334 this.alwaysAllowCollectionDeletion = alwaysAllowCollectionDeletion;
335 }
336
337 }