1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.datadictionary;
17
18 import java.util.Comparator;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.kuali.ole.sys.businessobject.AccountingLine;
23 import org.kuali.ole.sys.document.AccountingDocument;
24 import org.kuali.ole.sys.document.authorization.AccountingLineAuthorizer;
25 import org.kuali.ole.sys.document.web.DefaultAccountingLineGroupImpl;
26 import org.kuali.ole.sys.document.web.RenderableAccountingLineContainer;
27 import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase;
28 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
29
30
31
32
33 public class AccountingLineGroupDefinition extends DataDictionaryDefinitionBase {
34 private String groupLabel;
35 private Class<? extends AccountingLine> accountingLineClass;
36 private AccountingLineViewDefinition accountingLineView;
37 private String importedLinePropertyPrefix;
38 private List<? extends TotalDefinition> totals;
39 private Class<? extends AccountingLineAuthorizer> accountingLineAuthorizerClass;
40 private int forceColumnCount = -1;
41 private String errorKey;
42 private boolean topHeadersAfterFirstLineHiding = true;
43 private boolean headerRendering = true;
44 private boolean importingAllowed = true;
45 private Class<? extends DefaultAccountingLineGroupImpl> accountingLineGroupClass = org.kuali.ole.sys.document.web.DefaultAccountingLineGroupImpl.class;
46 private Class<? extends Comparator<AccountingLine>> accountingLineComparatorClass = org.kuali.ole.sys.businessobject.AccountingLineComparator.class;
47
48 private List<? extends AccountingLineViewActionDefinition> accountingLineGroupActions;
49
50 private AccountingLineAuthorizer accountingLineAuthorizer;
51
52
53
54
55
56
57
58 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
59 if (accountingLineClass == null) {
60 throw new AttributeValidationException("Please specify an accounting line class for AccountingLineGroup "+getId());
61 }
62 if (accountingLineView == null) {
63 throw new AttributeValidationException("Please specify an accountingLineView for AccountingLineGroup "+getId());
64 }
65 }
66
67
68
69
70
71 public Class<? extends AccountingLine> getAccountingLineClass() {
72 return accountingLineClass;
73 }
74
75
76
77
78
79 public void setAccountingLineClass(Class<? extends AccountingLine> accountingLineClass) {
80 this.accountingLineClass = accountingLineClass;
81 }
82
83
84
85
86
87 public AccountingLineViewDefinition getAccountingLineView() {
88 return accountingLineView;
89 }
90
91
92
93
94
95 public void setAccountingLineView(AccountingLineViewDefinition accountingLineView) {
96 this.accountingLineView = accountingLineView;
97 }
98
99
100
101
102
103 public String getGroupLabel() {
104 return (groupLabel == null) ? "" : groupLabel;
105 }
106
107
108
109
110
111 public void setGroupLabel(String groupLabel) {
112 this.groupLabel = groupLabel;
113 }
114
115
116
117
118
119 public List<? extends TotalDefinition> getTotals() {
120 return totals;
121 }
122
123
124
125
126
127 public void setTotals(List<? extends TotalDefinition> totals) {
128 this.totals = totals;
129 }
130
131
132
133
134
135 public Class<? extends AccountingLineAuthorizer> getAccountingLineAuthorizerClass() {
136 return accountingLineAuthorizerClass;
137 }
138
139
140
141
142
143 public void setAccountingLineAuthorizerClass(Class<? extends AccountingLineAuthorizer> accountingLineAuthorizerClass) {
144 this.accountingLineAuthorizerClass = accountingLineAuthorizerClass;
145 }
146
147
148
149
150
151 public String getImportedLinePropertyPrefix() {
152 return importedLinePropertyPrefix;
153 }
154
155
156
157
158
159 public void setImportedLinePropertyPrefix(String importedLinePropertyPrefix) {
160 this.importedLinePropertyPrefix = importedLinePropertyPrefix;
161 }
162
163
164
165
166
167 public int getForceColumnCount() {
168 return forceColumnCount;
169 }
170
171
172
173
174
175 public void setForceColumnCount(int forceColumnCount) {
176 this.forceColumnCount = forceColumnCount;
177 }
178
179
180
181
182
183 public String getErrorKey() {
184 return errorKey;
185 }
186
187
188
189
190
191 public void setErrorKey(String errorKey) {
192 this.errorKey = errorKey;
193 }
194
195
196
197
198
199 public AccountingLineAuthorizer getAccountingLineAuthorizer() {
200 if (accountingLineAuthorizer == null) {
201 accountingLineAuthorizer = createAccountingLineAuthorizer();
202 }
203 return accountingLineAuthorizer;
204 }
205
206
207
208
209
210 protected AccountingLineAuthorizer createAccountingLineAuthorizer() {
211 Class<? extends AccountingLineAuthorizer> authorizerClass = getAccountingLineAuthorizerClass();
212 AccountingLineAuthorizer authorizer = null;
213 try {
214 authorizer = authorizerClass.newInstance();
215 }
216 catch (InstantiationException ie) {
217 throw new IllegalArgumentException("InstantiationException while attempting to instantiate AccountingLineAuthorization class", ie);
218 }
219 catch (IllegalAccessException iae) {
220 throw new IllegalArgumentException("IllegalAccessException while attempting to instantiate AccountingLineAuthorization class", iae);
221 }
222 return authorizer;
223 }
224
225
226
227
228
229 public boolean isTopHeadersAfterFirstLineHiding() {
230 return topHeadersAfterFirstLineHiding;
231 }
232
233
234
235
236
237 public void setTopHeadersAfterFirstLineHiding(boolean showTopHeadersAfterFirstLine) {
238 this.topHeadersAfterFirstLineHiding = showTopHeadersAfterFirstLine;
239 }
240
241
242
243
244
245 public boolean isHeaderRendering() {
246 return headerRendering;
247 }
248
249
250
251
252
253 public void setHeaderRendering(boolean headerRendering) {
254 this.headerRendering = headerRendering;
255 }
256
257
258
259
260
261 public List<? extends AccountingLineViewActionDefinition> getAccountingLineGroupActions() {
262 return accountingLineGroupActions;
263 }
264
265
266
267
268
269 public void setAccountingLineGroupActions(List<? extends AccountingLineViewActionDefinition> accountingLineGroupActions) {
270 this.accountingLineGroupActions = accountingLineGroupActions;
271 }
272
273
274
275
276
277 public boolean isImportingAllowed() {
278 return importingAllowed;
279 }
280
281
282
283
284
285 public void setImportingAllowed(boolean importingAllowed) {
286 this.importingAllowed = importingAllowed;
287 }
288
289
290
291
292
293 public Class<? extends DefaultAccountingLineGroupImpl> getAccountingLineGroupClass() {
294 return accountingLineGroupClass;
295 }
296
297
298
299
300
301 public void setAccountingLineGroupClass(Class<? extends DefaultAccountingLineGroupImpl> accountingLineGroupClass) {
302 this.accountingLineGroupClass = accountingLineGroupClass;
303 }
304
305
306
307
308
309 public void setAccountingLineComparatorClass(Class<? extends Comparator<AccountingLine>> accountingLineComparatorClass) {
310 this.accountingLineComparatorClass = accountingLineComparatorClass;
311 }
312
313
314
315
316 public Comparator<AccountingLine> getAccountingLineComparator() {
317 Comparator<AccountingLine> comparator = null;
318 try {
319 comparator = accountingLineComparatorClass.newInstance();
320 }
321 catch (InstantiationException ie) {
322 throw new RuntimeException("Could not instantiate class for AccountingLineComparator for group", ie);
323 }
324 catch (IllegalAccessException iae) {
325 throw new RuntimeException("Illegal access attempting to instantiate class for AccountingLineComparator for group", iae);
326 }
327 return comparator;
328 }
329
330
331
332
333
334
335
336
337
338
339
340 public DefaultAccountingLineGroupImpl createAccountingLineGroup(AccountingDocument accountingDocument, List<RenderableAccountingLineContainer> containers, String collectionPropertyName, String collectionItemPropertyName, Map<String, Object> displayedErrors, Map<String, Object> displayedWarnings, Map<String, Object> displayedInfo, boolean canEdit) {
341 DefaultAccountingLineGroupImpl accountingLineGroup = null;
342 try {
343 accountingLineGroup = getAccountingLineGroupClass().newInstance();
344 accountingLineGroup.initialize(this, accountingDocument, containers, collectionPropertyName, collectionItemPropertyName, displayedErrors, displayedWarnings, displayedInfo, canEdit);
345 }
346 catch (InstantiationException ie) {
347 throw new RuntimeException("Could not initialize new AccountingLineGroup implementation of class: "+getAccountingLineGroupClass().getName(), ie);
348 }
349 catch (IllegalAccessException iae) {
350 throw new RuntimeException("Could not initialize new AccountingLineGroup implementation of class: "+getAccountingLineGroupClass().getName(), iae);
351 }
352 return accountingLineGroup;
353 }
354 }