1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.batch;
17
18 import java.sql.Date;
19 import java.text.DateFormat;
20 import java.text.ParseException;
21 import java.text.SimpleDateFormat;
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import org.kuali.ole.gl.GeneralLedgerConstants;
26 import org.kuali.ole.gl.batch.service.YearEndService;
27 import org.kuali.ole.sys.batch.AbstractWrappedBatchStep;
28 import org.kuali.ole.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor;
29 import org.kuali.ole.sys.service.impl.OleParameterConstants;
30 import org.springframework.util.StopWatch;
31
32
33
34
35 public class EncumbranceForwardStep extends AbstractWrappedBatchStep {
36 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(EncumbranceForwardStep.class);
37 private YearEndService yearEndService;
38
39 public static final String TRANSACTION_DATE_FORMAT_STRING = "yyyy-MM-dd";
40
41
42
43
44 @Override
45 protected CustomBatchExecutor getCustomBatchExecutor() {
46 return new CustomBatchExecutor() {
47
48
49
50
51
52
53
54 public boolean execute() {
55 StopWatch stopWatch = new StopWatch();
56 stopWatch.start("EncumbranceForwardStep");
57
58 Map jobParameters = new HashMap();
59 Integer varFiscalYear = null;
60 Date varTransactionDate = null;
61
62 String FIELD_FISCAL_YEAR = GeneralLedgerConstants.ColumnNames.UNIVERSITY_FISCAL_YEAR;
63 String FIELD_TRANSACTION_DATE = GeneralLedgerConstants.ColumnNames.TRANSACTION_DT;
64
65
66 varFiscalYear = new Integer(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
67
68
69 try {
70 DateFormat transactionDateFormat = new SimpleDateFormat(TRANSACTION_DATE_FORMAT_STRING);
71 varTransactionDate = new Date(transactionDateFormat.parse(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_TRANSACTION_DATE_PARM)).getTime());
72 }
73 catch (ParseException pe) {
74 LOG.error("Failed to parse TRANSACTION_DT from kualiConfigurationService");
75 throw new RuntimeException("Unable to get transaction date from kualiConfigurationService", pe);
76 }
77
78 jobParameters.put(GeneralLedgerConstants.ColumnNames.UNIVERSITY_FISCAL_YEAR, varFiscalYear);
79 jobParameters.put(GeneralLedgerConstants.ColumnNames.UNIV_DT, varTransactionDate);
80
81 String encumbranceForwardFileName = GeneralLedgerConstants.BatchFileSystem.ENCUMBRANCE_FORWARD_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
82 Map<String, Integer> forwardEncumbranceCounts = new HashMap<String, Integer>();
83
84 yearEndService.forwardEncumbrances(encumbranceForwardFileName, jobParameters, forwardEncumbranceCounts);
85
86 stopWatch.stop();
87 LOG.info("EncumbranceForwardStep took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
88
89 return true;
90 }
91 };
92 }
93
94
95
96
97
98
99
100 public void setYearEndService(YearEndService yearEndService) {
101 this.yearEndService = yearEndService;
102 }
103 }