01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.gl.batch;
17:
18: import java.sql.Date;
19: import java.util.Calendar;
20: import java.util.Collection;
21: import java.util.GregorianCalendar;
22:
23: import org.apache.log4j.Logger;
24: import org.kuali.kfs.batch.AbstractStep;
25: import org.kuali.module.gl.document.CorrectionDocument;
26: import org.kuali.module.gl.service.CorrectionDocumentService;
27:
28: /**
29: * A step to remove old correction document origin entries from the database.
30: */
31: public class PurgeCorrectionProcessFilesStep extends AbstractStep {
32: private static Logger LOG = Logger
33: .getLogger(PurgeCorrectionProcessFilesStep.class);
34: private CorrectionDocumentService correctionDocumentService;
35:
36: /**
37: * Runs the process of purging old correction document origin entries from the database.
38: *
39: * @param jobName the name of the job this step is being run as part of
40: * @return true if the job completed successfully, false if otherwise
41: * @see org.kuali.kfs.batch.Step#performStep()
42: */
43: public boolean execute(String jobName) {
44: int numberOfDaysFinal = Integer.parseInt(getParameterService()
45: .getParameterValue(getClass(), "NUMBER_OF_DAYS_FINAL"));
46: Calendar financialDocumentFinalCalendar = getDateTimeService()
47: .getCurrentCalendar();
48: financialDocumentFinalCalendar.add(
49: GregorianCalendar.DAY_OF_YEAR, -numberOfDaysFinal);
50: Collection<CorrectionDocument> documentsFinalOnDate = correctionDocumentService
51: .getCorrectionDocumentsFinalizedOn(new Date(
52: financialDocumentFinalCalendar
53: .getTimeInMillis()));
54: for (CorrectionDocument document : documentsFinalOnDate) {
55: correctionDocumentService
56: .removePersistedInputOriginEntries(document);
57: correctionDocumentService
58: .removePersistedOutputOriginEntries(document);
59: }
60: return true;
61: }
62:
63: /**
64: * Sets the correctionDocumentService attribute value, allowing the injection of an implementation of that service.
65: *
66: * @param correctionDocumentService The correctionDocumentService to set.
67: * @see org.kuali.module.gl.service.CorrectionDocumentService.
68: */
69: public void setCorrectionDocumentService(
70: CorrectionDocumentService correctionDocumentService) {
71: this.correctionDocumentService = correctionDocumentService;
72: }
73: }
|