001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.gl.service.impl;
017:
018: import org.kuali.core.service.DateTimeService;
019: import org.kuali.core.service.DocumentTypeService;
020: import org.kuali.core.service.KualiConfigurationService;
021: import org.kuali.core.service.PersistenceService;
022: import org.kuali.kfs.context.SpringContext;
023: import org.kuali.module.chart.service.ObjectCodeService;
024: import org.kuali.module.chart.service.OffsetDefinitionService;
025: import org.kuali.module.financial.service.FlexibleOffsetAccountService;
026: import org.kuali.module.gl.batch.collector.CollectorBatch;
027: import org.kuali.module.gl.bo.OriginEntryGroup;
028: import org.kuali.module.gl.dao.UniversityDateDao;
029: import org.kuali.module.gl.service.OriginEntryGroupService;
030: import org.kuali.module.gl.service.OriginEntryLiteService;
031: import org.kuali.module.gl.service.OriginEntryLookupService;
032: import org.kuali.module.gl.service.OriginEntryService;
033: import org.kuali.module.gl.service.ReportService;
034: import org.kuali.module.gl.service.RunDateService;
035: import org.kuali.module.gl.service.ScrubberProcessObjectCodeOverride;
036: import org.kuali.module.gl.service.ScrubberService;
037: import org.kuali.module.gl.service.ScrubberValidator;
038: import org.kuali.module.gl.util.CollectorReportData;
039: import org.kuali.module.gl.util.ScrubberStatus;
040: import org.springframework.transaction.annotation.Transactional;
041:
042: /**
043: * The default implementation of ScrubberService
044: */
045: @Transactional
046: public class ScrubberServiceImpl implements ScrubberService {
047: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
048: .getLogger(ScrubberServiceImpl.class);
049:
050: private FlexibleOffsetAccountService flexibleOffsetAccountService;
051: private DocumentTypeService documentTypeService;
052: private OriginEntryService originEntryService;
053: private OriginEntryGroupService originEntryGroupService;
054: private DateTimeService dateTimeService;
055: private OffsetDefinitionService offsetDefinitionService;
056: private ObjectCodeService objectCodeService;
057: private KualiConfigurationService kualiConfigurationService;
058: private UniversityDateDao universityDateDao;
059: private PersistenceService persistenceService;
060: private ReportService reportService;
061: private ScrubberValidator scrubberValidator;
062: private ScrubberProcessObjectCodeOverride scrubberProcessObjectCodeOverride;
063: private RunDateService runDateService;
064: private OriginEntryLiteService originEntryLiteService;
065:
066: /**
067: * This process will call the scrubber in a read only mode. It will scrub a single group, won't create any output in origin
068: * entry. It will create a the scrubber report
069: * @param group the origin entry group to scrub for report
070: * @param documentNumber the id of documents which generated origin entries that should be scrubbed
071: * @see org.kuali.module.gl.service.ScrubberService#scrubGroupReportOnly(org.kuali.module.gl.bo.OriginEntryGroup)
072: */
073: public void scrubGroupReportOnly(OriginEntryGroup group,
074: String documentNumber) {
075: LOG.debug("scrubGroupReportOnly() started");
076:
077: // The logic for this was moved into another object because the process was written using
078: // many instance variables which shouldn't be used for Spring services
079:
080: ScrubberProcess sp = new ScrubberProcess(
081: flexibleOffsetAccountService, documentTypeService,
082: originEntryService, originEntryGroupService,
083: dateTimeService, offsetDefinitionService,
084: objectCodeService, kualiConfigurationService,
085: universityDateDao, persistenceService, reportService,
086: scrubberValidator, scrubberProcessObjectCodeOverride,
087: runDateService, originEntryLiteService);
088: sp.setReferenceLookup(SpringContext
089: .getBean(OriginEntryLookupService.class));
090: sp.scrubGroupReportOnly(group, documentNumber);
091: sp.setReferenceLookup(null);
092: }
093:
094: /**
095: * Scrubs all of the entries in all origin entry groups that are up for scrubbing
096: * @see org.kuali.module.gl.service.ScrubberService#scrubEntries()
097: */
098: public void scrubEntries() {
099: LOG.debug("scrubEntries() started");
100:
101: // The logic for this was moved into another object because the process was written using
102: // many instance variables which shouldn't be used for Spring services
103:
104: ScrubberProcess sp = new ScrubberProcess(
105: flexibleOffsetAccountService, documentTypeService,
106: originEntryService, originEntryGroupService,
107: dateTimeService, offsetDefinitionService,
108: objectCodeService, kualiConfigurationService,
109: universityDateDao, persistenceService, reportService,
110: scrubberValidator, scrubberProcessObjectCodeOverride,
111: runDateService, originEntryLiteService);
112: sp.setReferenceLookup(SpringContext
113: .getBean(OriginEntryLookupService.class));
114: sp.scrubEntries();
115: sp.setReferenceLookup(null);
116: }
117:
118: /**
119: * Scrubs data read in by the Collector
120: *
121: * @param batch the data read by the Collector
122: * @param collectorReportData statistics about
123: * @param overrideOriginEntryService the implementation of origin entry service to use for this specific Collector scrub
124: * @param overrideOriginEntryGroupService the implementation of origin entry group service to use for this specific Collector scrub
125: * @return the status returned by the Scrubber
126: * @see org.kuali.module.gl.service.ScrubberService#scrubCollectorBatch(org.kuali.module.gl.batch.collector.CollectorBatch, org.kuali.module.gl.util.CollectorReportData, org.kuali.module.gl.service.OriginEntryService, org.kuali.module.gl.service.OriginEntryGroupService)
127: */
128: public ScrubberStatus scrubCollectorBatch(CollectorBatch batch,
129: CollectorReportData collectorReportData,
130: OriginEntryService overrideOriginEntryService,
131: OriginEntryGroupService overrideOriginEntryGroupService) {
132: if (overrideOriginEntryService == null
133: && overrideOriginEntryGroupService == null) {
134: throw new NullPointerException(
135: "for scrubCollectorBatch, the OriginEntryService and OriginEntryGroupService services must be specified in the parameters");
136: }
137:
138: // this service is especially developed to support collector scrubbing, demerger, and report generation
139: ScrubberProcess sp = new ScrubberProcess(
140: flexibleOffsetAccountService, documentTypeService,
141: overrideOriginEntryService,
142: overrideOriginEntryGroupService, dateTimeService,
143: offsetDefinitionService, objectCodeService,
144: kualiConfigurationService, universityDateDao,
145: persistenceService, reportService, scrubberValidator,
146: scrubberProcessObjectCodeOverride, runDateService,
147: originEntryLiteService);
148: sp.setReferenceLookup(SpringContext
149: .getBean(OriginEntryLookupService.class));
150: ScrubberStatus result = sp.scrubCollectorBatch(batch,
151: collectorReportData);
152: sp.setReferenceLookup(null);
153: return result;
154: }
155:
156: /**
157: * Sets the flexibleOffsetAccountService attribute value.
158: *
159: * @param flexibleOffsetAccountService The flexibleOffsetAccountService to set.
160: */
161: public void setFlexibleOffsetAccountService(
162: FlexibleOffsetAccountService flexibleOffsetAccountService) {
163: this .flexibleOffsetAccountService = flexibleOffsetAccountService;
164: }
165:
166: /**
167: * Sets the documentTypeService attribute value.
168: *
169: * @param documentTypeService The documentTypeService to set.
170: */
171: public void setDocumentTypeService(
172: DocumentTypeService documentTypeService) {
173: this .documentTypeService = documentTypeService;
174: }
175:
176: /**
177: * Sets the scrubberValidator attribute value.
178: *
179: * @param sv The scrubberValidator to set.
180: */
181: public void setScrubberValidator(ScrubberValidator sv) {
182: scrubberValidator = sv;
183: }
184:
185: /**
186: * Sets the scrubberProcessObjectCodeOverride attribute value.
187: *
188: * @param scrubberProcessObjectCodeOverride The scrubberProcessObjectCodeOverride to set.
189: */
190: public void setScrubberProcessObjectCodeOverride(
191: ScrubberProcessObjectCodeOverride scrubberProcessObjectCodeOverride) {
192: this .scrubberProcessObjectCodeOverride = scrubberProcessObjectCodeOverride;
193: }
194:
195: /**
196: * Sets the originEntryService attribute value.
197: *
198: * @param oes The OriginEntryService to set.
199: */
200: public void setOriginEntryService(OriginEntryService oes) {
201: this .originEntryService = oes;
202: }
203:
204: /**
205: * Sets the originEntryGroupService attribute value.
206: *
207: * @param groupService The originEntryGroupService to set.
208: */
209: public void setOriginEntryGroupService(
210: OriginEntryGroupService groupService) {
211: this .originEntryGroupService = groupService;
212: }
213:
214: /**
215: * Sets the dateTimeService attribute value.
216: *
217: * @param dts The dateTimeService to set.
218: */
219: public void setDateTimeService(DateTimeService dts) {
220: this .dateTimeService = dts;
221: }
222:
223: /**
224: * Sets the universityDateDao attribute value.
225: *
226: * @param universityDateDao The universityDateDao to set.
227: */
228: public void setUniversityDateDao(UniversityDateDao universityDateDao) {
229: this .universityDateDao = universityDateDao;
230: }
231:
232: /**
233: * Sets the persistenceService attribute value.
234: *
235: * @param ps The persistenceService to set.
236: */
237: public void setPersistenceService(PersistenceService ps) {
238: persistenceService = ps;
239: }
240:
241: /**
242: * Sets the offsetDefinitionService attribute value.
243: *
244: * @param offsetDefinitionService The offsetDefinitionService to set.
245: */
246: public void setOffsetDefinitionService(
247: OffsetDefinitionService offsetDefinitionService) {
248: this .offsetDefinitionService = offsetDefinitionService;
249: }
250:
251: /**
252: * Sets the objectCodeService attribute value.
253: *
254: * @param objectCodeService The objectCodeService to set.
255: */
256: public void setObjectCodeService(ObjectCodeService objectCodeService) {
257: this .objectCodeService = objectCodeService;
258: }
259:
260: /**
261: * Sets the kualiConfigurationService attribute value.
262: *
263: * @param kualiConfigurationService The kualiConfigurationService to set.
264: */
265: public void setKualiConfigurationService(
266: KualiConfigurationService kualiConfigurationService) {
267: this .kualiConfigurationService = kualiConfigurationService;
268: }
269:
270: /**
271: * Sets the reportService attribute value.
272: *
273: * @param reportService The reportService to set.
274: */
275: public void setReportService(ReportService reportService) {
276: this .reportService = reportService;
277: }
278:
279: /**
280: * Sets the runDateService attribute value.
281: *
282: * @param runDateService The runDateService to set.
283: */
284: public RunDateService getRunDateService() {
285: return runDateService;
286: }
287:
288: /**
289: * Sets the runDateService attribute value.
290: *
291: * @param runDateService The runDateService to set.
292: */
293: public void setRunDateService(RunDateService runDateService) {
294: this .runDateService = runDateService;
295: }
296:
297: /**
298: * Sets the originEntryLiteService attribute value.
299: *
300: * @param originEntryLiteService The originEntryLiteService to set.
301: */
302: public void setOriginEntryLiteService(
303: OriginEntryLiteService originEntryLiteService) {
304: this.originEntryLiteService = originEntryLiteService;
305: }
306:
307: }
|