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 NominalActivityClosingStep extends AbstractWrappedBatchStep {
36 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(NominalActivityClosingStep.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 public boolean execute() {
54 StopWatch stopWatch = new StopWatch();
55 stopWatch.start("NominalActivityClosingStep");
56
57 Date varTransactionDate;
58 try {
59 DateFormat transactionDateFormat = new SimpleDateFormat(TRANSACTION_DATE_FORMAT_STRING);
60 varTransactionDate = new Date(transactionDateFormat.parse(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_TRANSACTION_DATE_PARM)).getTime());
61 }
62 catch (ParseException e) {
63 LOG.error("forwardBalances() Unable to parse transaction date", e);
64 throw new IllegalArgumentException("Unable to parse transaction date");
65 }
66 Integer varFiscalYear = new Integer(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
67 String nominalClosingFileName = GeneralLedgerConstants.BatchFileSystem.CLOSE_NOMINAL_ACTIVITY_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
68
69 Map nominalClosingJobParameters = new HashMap();
70 nominalClosingJobParameters.put(GeneralLedgerConstants.ColumnNames.UNIV_DT, varTransactionDate);
71 nominalClosingJobParameters.put(GeneralLedgerConstants.ColumnNames.UNIVERSITY_FISCAL_YEAR, varFiscalYear);
72 Map<String, Integer> nominalActivityClosingCounts = new HashMap<String, Integer>();
73
74 yearEndService.closeNominalActivity(nominalClosingFileName, nominalClosingJobParameters);
75 stopWatch.stop();
76 LOG.info("NominalActivityClosingStep took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
77
78 return true;
79 }
80 };
81 }
82
83
84
85
86
87
88
89 public void setYearEndService(YearEndService yearEndService) {
90 this.yearEndService = yearEndService;
91 }
92
93
94
95
96
97
98
99 public YearEndService getYearEndService() {
100 return yearEndService;
101 }
102 }