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
23 import org.kuali.ole.gl.GeneralLedgerConstants;
24 import org.kuali.ole.gl.batch.service.YearEndService;
25 import org.kuali.ole.sys.batch.AbstractWrappedBatchStep;
26 import org.kuali.ole.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor;
27 import org.kuali.ole.sys.service.impl.OleParameterConstants;
28 import org.springframework.util.StopWatch;
29
30
31
32
33 public class BalanceForwardStep extends AbstractWrappedBatchStep {
34 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BalanceForwardStep.class);
35
36 private YearEndService yearEndService;
37
38 public static final String TRANSACTION_DATE_FORMAT_STRING = "yyyy-MM-dd";
39
40
41
42
43 @Override
44 protected CustomBatchExecutor getCustomBatchExecutor() {
45 return new CustomBatchExecutor() {
46
47
48
49
50
51
52 public boolean execute() {
53 StopWatch stopWatch = new StopWatch();
54 stopWatch.start("Balance Forward Step");
55
56 Date varTransactionDate;
57 try {
58 DateFormat transactionDateFormat = new SimpleDateFormat(TRANSACTION_DATE_FORMAT_STRING);
59 varTransactionDate = new Date(transactionDateFormat.parse(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_TRANSACTION_DATE_PARM)).getTime());
60 }
61 catch (ParseException e) {
62 LOG.error("forwardBalances() Unable to parse transaction date", e);
63 throw new IllegalArgumentException("Unable to parse transaction date");
64 }
65
66 Integer varFiscalYear = new Integer(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
67
68 yearEndService.logAllMissingPriorYearAccounts(varFiscalYear);
69 yearEndService.logAllMissingSubFundGroups(varFiscalYear);
70
71 String balanceForwardsUnclosedFileName = GeneralLedgerConstants.BatchFileSystem.BALANCE_FORWARDS_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
72 String balanceForwardsclosedFileName = GeneralLedgerConstants.BatchFileSystem.BALANCE_FORWARDS_CLOSED_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
73
74 BalanceForwardRuleHelper balanceForwardRuleHelper = new BalanceForwardRuleHelper(varFiscalYear, varTransactionDate, balanceForwardsclosedFileName, balanceForwardsUnclosedFileName);
75
76 yearEndService.forwardBalances(balanceForwardsUnclosedFileName, balanceForwardsclosedFileName, balanceForwardRuleHelper);
77
78 stopWatch.stop();
79 LOG.info("Balance Forward Step took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
80
81 return true;
82 }
83 };
84 }
85
86
87
88
89
90
91
92 public void setYearEndService(YearEndService yearEndService) {
93 this.yearEndService = yearEndService;
94 }
95 }