1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.report;
17
18 import java.util.ArrayList;
19 import java.util.Collection;
20 import java.util.Collections;
21 import java.util.HashMap;
22 import java.util.Iterator;
23 import java.util.LinkedHashMap;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.Set;
27 import java.util.SortedMap;
28 import java.util.TreeMap;
29 import java.util.TreeSet;
30
31 import org.kuali.ole.gl.batch.CollectorBatch;
32 import org.kuali.ole.gl.batch.service.impl.DocumentGroupData;
33 import org.kuali.ole.gl.batch.service.impl.OriginEntryTotals;
34 import org.kuali.ole.gl.businessobject.CollectorDetail;
35 import org.kuali.ole.gl.businessobject.DemergerReportData;
36 import org.kuali.ole.gl.businessobject.Transaction;
37 import org.kuali.ole.gl.service.ScrubberReportData;
38 import org.kuali.ole.sys.Message;
39 import org.kuali.rice.krad.util.MessageMap;
40
41
42
43
44
45 public class CollectorReportData {
46 private Map<String, String> emailSendingStatus;
47
48 private Set<String> unparsableFileNames;
49 private Map<String, List<Message>> validationErrorsForBatchName;
50 private Map<String, CollectorBatch> addedBatches;
51 private Map<String, Map<CollectorDetail, List<Message>>> detailScrubberErrors;
52 private Map<String, Map<Transaction, List<Message>>> originEntryScrubberErrors;
53 private Map<String, ScrubberReportData> scrubberReportDataForBatchName;
54 private Map<String, DemergerReportData> demergerReportDataForBatchName;
55 private Map<String, Integer> numDetailAccountValuesChangedForBatchName;
56
57 private Map<String, Integer> numDetailDeletedForBatchName;
58 private Map<String, Map<DocumentGroupData, OriginEntryTotals>> totalsOnInputOriginEntriesAssociatedWithErrorGroupForBatchName;
59 private Map<String, Integer> numInputDetailsForBatchName;
60 private Map<String, Integer> numSavedDetailsForBatchName;
61 private Map<String, Boolean> validationStatuses;
62 private SortedMap<String, MessageMap> messageMapForFileName;
63
64 private LedgerSummaryReport ledgerSummaryReport;
65 private PreScrubberReportData preScrubberReportData;
66
67 private int numPersistedBatches;
68 private int numNotPersistedBatches;
69 private int numNotPersistedOriginEntryRecords;
70 private int numNotPersistedCollectorDetailRecords;
71 private Collection<String> loadedfileNames;
72
73 public CollectorReportData() {
74 emailSendingStatus = new HashMap<String, String>();
75 unparsableFileNames = new TreeSet<String>();
76 validationErrorsForBatchName = new HashMap<String, List<Message>>();
77 addedBatches = new LinkedHashMap<String, CollectorBatch>();
78 detailScrubberErrors = new HashMap<String, Map<CollectorDetail, List<Message>>>();
79 originEntryScrubberErrors = new HashMap<String, Map<Transaction, List<Message>>>();
80 scrubberReportDataForBatchName = new HashMap<String, ScrubberReportData>();
81 demergerReportDataForBatchName = new HashMap<String, DemergerReportData>();
82 numDetailAccountValuesChangedForBatchName = new HashMap<String, Integer>();
83 numDetailDeletedForBatchName = new HashMap<String, Integer>();
84 totalsOnInputOriginEntriesAssociatedWithErrorGroupForBatchName = new HashMap<String, Map<DocumentGroupData, OriginEntryTotals>>();
85 numInputDetailsForBatchName = new HashMap<String, Integer>();
86 numSavedDetailsForBatchName = new HashMap<String, Integer>();
87 validationStatuses = new HashMap<String, Boolean>();
88 ledgerSummaryReport = new LedgerSummaryReport();
89 preScrubberReportData = new PreScrubberReportData(0, 0, new TreeSet<String>(), new TreeSet<String>());
90 messageMapForFileName = new TreeMap<String, MessageMap>();
91 numPersistedBatches = 0;
92 numNotPersistedBatches = 0;
93 numNotPersistedOriginEntryRecords = 0;
94 loadedfileNames = new ArrayList<String>();
95 }
96
97
98
99
100
101
102
103 public void addBatch(CollectorBatch batch) {
104 if (isBatchAdded(batch)) {
105 throw new RuntimeException("Can't add a batch twice");
106 }
107 addedBatches.put(batch.getBatchName(), batch);
108 }
109
110
111
112
113
114
115
116 public boolean isBatchAdded(CollectorBatch batch) {
117 return addedBatches.containsKey(batch.getBatchName());
118 }
119
120
121
122
123
124
125 public int getNumberOfAddedBatches() {
126 return addedBatches.size();
127 }
128
129
130
131
132
133
134 protected void throwExceptionIfBatchNotAdded(CollectorBatch batch) {
135 if (!isBatchAdded(batch)) {
136 throw new RuntimeException("Batch must be added first");
137 }
138 }
139
140
141
142
143
144
145
146
147 public void setBatchDetailScrubberErrors(CollectorBatch batch, Map<CollectorDetail, List<Message>> errorsMap) {
148 throwExceptionIfBatchNotAdded(batch);
149
150 detailScrubberErrors.put(batch.getBatchName(), errorsMap);
151 }
152
153
154
155
156
157
158
159
160 public void setBatchOriginEntryScrubberErrors(CollectorBatch batch, Map<Transaction, List<Message>> errorsMap) {
161 throwExceptionIfBatchNotAdded(batch);
162
163 originEntryScrubberErrors.put(batch.getBatchName(), errorsMap);
164 }
165
166
167
168
169
170
171
172 public Map<Transaction, List<Message>> getBatchOriginEntryScrubberErrors(CollectorBatch batch) {
173 throwExceptionIfBatchNotAdded(batch);
174
175 return originEntryScrubberErrors.get(batch.getBatchName());
176 }
177
178 public void setScrubberReportData(CollectorBatch batch, ScrubberReportData scrubberReportData) {
179 throwExceptionIfBatchNotAdded(batch);
180
181 scrubberReportDataForBatchName.put(batch.getBatchName(), scrubberReportData);
182 }
183
184 public ScrubberReportData getScrubberReportData(CollectorBatch batch) {
185 throwExceptionIfBatchNotAdded(batch);
186
187 return scrubberReportDataForBatchName.get(batch.getBatchName());
188 }
189
190 public void setDemergerReportData(CollectorBatch batch, DemergerReportData demergerReportData) {
191 throwExceptionIfBatchNotAdded(batch);
192
193 demergerReportDataForBatchName.put(batch.getBatchName(), demergerReportData);
194 }
195
196 public DemergerReportData getDemergerReportData(CollectorBatch batch) {
197 throwExceptionIfBatchNotAdded(batch);
198
199 return demergerReportDataForBatchName.get(batch.getBatchName());
200 }
201
202 public void markUnparsableFileNames(String fileName) {
203 unparsableFileNames.add(fileName);
204 }
205
206 public Set<String> getAllUnparsableFileNames() {
207 return Collections.unmodifiableSet(unparsableFileNames);
208 }
209
210 public void setEmailSendingStatusForParsedBatch(CollectorBatch batch, String emailStatus) {
211 throwExceptionIfBatchNotAdded(batch);
212
213 emailSendingStatus.put(batch.getBatchName(), emailStatus);
214 }
215
216 public Iterator<CollectorBatch> getAddedBatches() {
217 return addedBatches.values().iterator();
218 }
219
220 public Map<String, String> getEmailSendingStatus() {
221 return emailSendingStatus;
222 }
223
224
225
226
227
228
229 public void setNumDetailAccountValuesChanged(CollectorBatch batch, Integer numDetailAccountValuesChanged) {
230 throwExceptionIfBatchNotAdded(batch);
231
232 numDetailAccountValuesChangedForBatchName.put(batch.getBatchName(), numDetailAccountValuesChanged);
233 }
234
235 public Integer getNumDetailAccountValuesChanged(CollectorBatch batch) {
236 throwExceptionIfBatchNotAdded(batch);
237
238 return numDetailAccountValuesChangedForBatchName.get(batch.getBatchName());
239 }
240
241 public void setNumDetailDeleted(CollectorBatch batch, Integer numDetailDeleted) {
242 throwExceptionIfBatchNotAdded(batch);
243
244 numDetailDeletedForBatchName.put(batch.getBatchName(), numDetailDeleted);
245 }
246
247 public Integer getNumDetailDeleted(CollectorBatch batch) {
248 throwExceptionIfBatchNotAdded(batch);
249
250 return numDetailDeletedForBatchName.get(batch.getBatchName());
251 }
252
253
254
255
256
257
258
259
260
261 public void setTotalsOnInputOriginEntriesAssociatedWithErrorGroup(CollectorBatch batch, Map<DocumentGroupData, OriginEntryTotals> totals) {
262 throwExceptionIfBatchNotAdded(batch);
263
264 totalsOnInputOriginEntriesAssociatedWithErrorGroupForBatchName.put(batch.getBatchName(), totals);
265 }
266
267
268
269
270
271
272
273
274 public Map<DocumentGroupData, OriginEntryTotals> getTotalsOnInputOriginEntriesAssociatedWithErrorGroup(CollectorBatch batch) {
275 throwExceptionIfBatchNotAdded(batch);
276
277 return totalsOnInputOriginEntriesAssociatedWithErrorGroupForBatchName.get(batch.getBatchName());
278 }
279
280 public void setNumInputDetails(CollectorBatch batch) {
281 throwExceptionIfBatchNotAdded(batch);
282
283 numInputDetailsForBatchName.put(batch.getBatchName(), batch.getCollectorDetails().size());
284 }
285
286 public Integer getNumInputDetails(CollectorBatch batch) {
287 throwExceptionIfBatchNotAdded(batch);
288
289 return numInputDetailsForBatchName.get(batch.getBatchName());
290 }
291
292 public void setNumSavedDetails(CollectorBatch batch, Integer numSavedDetails) {
293 throwExceptionIfBatchNotAdded(batch);
294
295 numSavedDetailsForBatchName.put(batch.getBatchName(), numSavedDetails);
296 }
297
298 public Integer getNumSavedDetails(CollectorBatch batch) {
299 throwExceptionIfBatchNotAdded(batch);
300
301 return numSavedDetailsForBatchName.get(batch.getBatchName());
302 }
303
304 public void incrementNumPersistedBatches() {
305 numPersistedBatches++;
306 }
307
308
309
310
311
312
313
314 public int getNumPersistedBatches() {
315 return numPersistedBatches;
316 }
317
318 public void incrementNumNonPersistedBatches() {
319 numNotPersistedBatches++;
320 }
321
322
323
324
325
326
327 public int getNumNotPersistedBatches() {
328 return numNotPersistedBatches;
329 }
330
331 public void incrementNumNotPersistedOriginEntryRecords(int records) {
332 numNotPersistedOriginEntryRecords += records;
333 }
334
335 public int getNumNotPersistedOriginEntryRecords() {
336 return numNotPersistedOriginEntryRecords;
337 }
338
339 public void incrementNumNotPersistedCollectorDetailRecords(int records) {
340 numNotPersistedCollectorDetailRecords += records;
341 }
342
343 public int getNumNotPersistedCollectorDetailRecords() {
344 return numNotPersistedCollectorDetailRecords;
345 }
346
347
348
349
350
351
352
353 public void markValidationStatus(CollectorBatch batch, boolean validStatus) {
354 throwExceptionIfBatchNotAdded(batch);
355
356 validationStatuses.put(batch.getBatchName(), Boolean.valueOf(validStatus));
357 }
358
359
360
361
362
363
364
365 public boolean isBatchValid(CollectorBatch batch) {
366 throwExceptionIfBatchNotAdded(batch);
367
368 return (Boolean) validationStatuses.get(batch.getBatchName()).booleanValue();
369 }
370
371
372
373
374
375 public LedgerSummaryReport getLedgerSummaryReport() {
376 return ledgerSummaryReport;
377 }
378
379 public PreScrubberReportData getPreScrubberReportData() {
380 return preScrubberReportData;
381 }
382
383 public MessageMap getMessageMapForFileName(String fileName) {
384 MessageMap messageMap = messageMapForFileName.get(fileName);
385 if (messageMap == null) {
386 messageMap = new MessageMap();
387 messageMapForFileName.put(fileName, messageMap);
388 }
389 return messageMap;
390 }
391
392 public Collection<String> getLoadedfileNames() {
393 return loadedfileNames;
394 }
395 }