1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.batch.service.impl;
17
18 import java.text.ParseException;
19 import java.text.SimpleDateFormat;
20 import java.util.HashMap;
21 import java.util.Map;
22
23 import org.kuali.ole.coa.businessobject.OrganizationReversion;
24 import org.kuali.ole.gl.GeneralLedgerConstants;
25 import org.kuali.ole.gl.batch.service.OrganizationReversionProcess;
26 import org.kuali.ole.gl.batch.service.OrganizationReversionProcessService;
27 import org.kuali.ole.sys.OLEConstants;
28 import org.kuali.ole.sys.OLEKeyConstants;
29 import org.kuali.ole.sys.context.SpringContext;
30 import org.kuali.ole.sys.service.ReportWriterService;
31 import org.kuali.ole.sys.service.impl.OleParameterConstants;
32 import org.kuali.rice.core.api.config.property.ConfigurationService;
33 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
34 import org.springframework.transaction.annotation.Transactional;
35
36
37
38
39 @Transactional
40 public class OrganizationReversionProcessServiceImpl implements OrganizationReversionProcessService {
41 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OrganizationReversionProcessServiceImpl.class);
42
43 private static final String ORGANIZATION_REVERSION_PRIOR_YEAR_ACCOUNT_PROCESS_BEAN_NAME = "glOrganizationReversionPriorYearAccountProcess";
44 private static final String ORGANIZATION_REVERSION_CURRENT_YEAR_ACCOUNT_PROCESS_BEAN_NAME = "glOrganizationReversionCurrentYearAccountProcess";
45
46 private static final String DATE_FORMAT = "yyyy-MM-dd";
47
48 private ReportWriterService organizationReversionReportWriterService;
49 private ParameterService parameterService;
50 private ConfigurationService configurationService;
51
52
53
54
55
56 public ReportWriterService getOrganizationReversionReportWriterService() {
57 return organizationReversionReportWriterService;
58 }
59
60
61
62
63
64 public void setOrganizationReversionReportWriterService(ReportWriterService organizationReversionReportWriterService) {
65 this.organizationReversionReportWriterService = organizationReversionReportWriterService;
66 }
67
68
69
70
71
72
73
74
75
76
77 public void organizationReversionPriorYearAccountProcess(Map jobParameters, Map<String, Integer> organizationReversionCounts) {
78 if (LOG.isDebugEnabled()) {
79 LOG.debug("organizationReversionProcessEndOfYear() started");
80 }
81 OrganizationReversionProcess orp = SpringContext.getBean(OrganizationReversionProcess.class,OrganizationReversionProcessServiceImpl.ORGANIZATION_REVERSION_PRIOR_YEAR_ACCOUNT_PROCESS_BEAN_NAME);
82
83 orp.organizationReversionProcess(jobParameters, organizationReversionCounts);
84
85 writeReports(orp, jobParameters, organizationReversionCounts);
86 }
87
88
89
90
91
92
93
94
95
96 public void organizationReversionCurrentYearAccountProcess(Map jobParameters, Map<String, Integer> organizationReversionCounts) {
97 if (LOG.isDebugEnabled()) {
98 LOG.debug("organizationReversionProcessEndOfYear() started");
99 }
100 OrganizationReversionProcess orp = SpringContext.getBean(OrganizationReversionProcess.class,OrganizationReversionProcessServiceImpl.ORGANIZATION_REVERSION_CURRENT_YEAR_ACCOUNT_PROCESS_BEAN_NAME);
101
102 LOG.info("processing organization reversions for current year accounts");
103 orp.organizationReversionProcess(jobParameters, organizationReversionCounts);
104
105 writeReports(orp, jobParameters, organizationReversionCounts);
106 }
107
108
109
110
111
112
113 public Map getJobParameters() {
114
115 Map jobParameters = new HashMap();
116 String strTransactionDate = getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_TRANSACTION_DATE_PARM);
117 jobParameters.put(OLEConstants.UNALLOC_OBJECT_CD, getParameterService().getParameterValueAsString(OrganizationReversion.class, GeneralLedgerConstants.OrganizationReversionProcess.UNALLOC_OBJECT_CODE_PARM));
118 jobParameters.put(OLEConstants.BEG_BUD_CASH_OBJECT_CD, getParameterService().getParameterValueAsString(OrganizationReversion.class, GeneralLedgerConstants.OrganizationReversionProcess.CARRY_FORWARD_OBJECT_CODE));
119 jobParameters.put(OLEConstants.FUND_BAL_OBJECT_CD, getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FUND_BALANCE_OBJECT_CODE_PARM));
120 String strUniversityFiscalYear = getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM);
121
122 try {
123 SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
124 java.util.Date jud = sdf.parse(strTransactionDate);
125 jobParameters.put(OLEConstants.TRANSACTION_DT, new java.sql.Date(jud.getTime()));
126 }
127 catch (ParseException e) {
128 throw new IllegalArgumentException("TRANSACTION_DT is an invalid date");
129 }
130 try {
131 jobParameters.put(OLEConstants.UNIV_FISCAL_YR, new Integer(strUniversityFiscalYear));
132 }
133 catch (NumberFormatException nfe) {
134 throw new IllegalArgumentException("UNIV_FISCAL_YR is an invalid year");
135 }
136 return jobParameters;
137 }
138
139
140
141
142
143
144
145 public void writeReports(OrganizationReversionProcess organizationReversionProcess, Map jobParameters, Map<String, Integer> counts) {
146
147 for (Object jobParameterKeyAsObject : jobParameters.keySet()) {
148 if (jobParameterKeyAsObject != null) {
149 final String jobParameterKey = jobParameterKeyAsObject.toString();
150 getOrganizationReversionReportWriterService().writeParameterLine("%32s %10s", jobParameterKey, jobParameters.get(jobParameterKey));
151 }
152 }
153
154
155 getOrganizationReversionReportWriterService().writeStatisticLine("NUMBER OF GLBL RECORDS READ....: %10d", counts.get("balancesRead"));
156 getOrganizationReversionReportWriterService().writeStatisticLine("NUMBER OF GLBL RECORDS SELECTED: %10d", counts.get("balancesSelected"));
157 getOrganizationReversionReportWriterService().writeStatisticLine("NUMBER OF SEQ RECORDS WRITTEN..: %10d", counts.get("recordsWritten"));
158 getOrganizationReversionReportWriterService().pageBreak();
159
160
161 getOrganizationReversionReportWriterService().writeSubTitle(getConfigurationService().getPropertyValueAsString(OLEKeyConstants.MESSAGE_REPORT_YEAR_END_ORGANIZATION_REVERSION_LEDGER_TITLE_LINE));
162 organizationReversionProcess.writeLedgerSummaryReport(getOrganizationReversionReportWriterService());
163 }
164
165
166
167
168
169 public void setParameterService(ParameterService parameterService) {
170 this.parameterService = parameterService;
171 }
172
173
174
175
176
177 public void setConfigurationService(ConfigurationService configurationService) {
178 this.configurationService = configurationService;
179 }
180
181
182
183
184
185 public ParameterService getParameterService() {
186 return parameterService;
187 }
188
189
190
191
192
193 public ConfigurationService getConfigurationService() {
194 return configurationService;
195 }
196 }