1 package org.kuali.ole.select.document.service.impl;
2
3 import org.apache.commons.lang.ArrayUtils;
4 import org.apache.commons.lang.StringUtils;
5 import org.kuali.ole.OLEConstants;
6 import org.kuali.ole.coa.businessobject.ObjectCode;
7 import org.kuali.ole.coa.businessobject.OffsetDefinition;
8 import org.kuali.ole.deliver.service.DateFormatHelper;
9 import org.kuali.ole.gl.Constant;
10 import org.kuali.ole.gl.GeneralLedgerConstants;
11 import org.kuali.ole.gl.OJBUtility;
12 import org.kuali.ole.gl.batch.service.AccountBalanceCalculator;
13 import org.kuali.ole.gl.batch.service.RunDateService;
14 import org.kuali.ole.gl.businessobject.AccountBalance;
15 import org.kuali.ole.gl.businessobject.Entry;
16 import org.kuali.ole.gl.businessobject.OriginEntryFull;
17 import org.kuali.ole.gl.businessobject.TransientBalanceInquiryAttributes;
18 import org.kuali.ole.gl.businessobject.lookup.BusinessObjectFieldConverter;
19 import org.kuali.ole.gl.service.AccountBalanceService;
20 import org.kuali.ole.select.businessobject.OleFundLookup;
21 import org.kuali.ole.select.document.service.OLEReEncumberRecurringOrdersJobService;
22 import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry;
23 import org.kuali.ole.sys.businessobject.SystemOptions;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.ole.sys.service.GeneralLedgerPendingEntryService;
26 import org.kuali.ole.sys.service.OptionsService;
27 import org.kuali.ole.sys.service.impl.OleParameterConstants;
28 import org.kuali.rice.core.api.config.property.ConfigContext;
29 import org.kuali.rice.core.api.datetime.DateTimeService;
30 import org.kuali.rice.core.api.util.jaxb.KualiDecimalAdapter;
31 import org.kuali.rice.core.api.util.type.KualiDecimal;
32 import org.kuali.rice.core.framework.persistence.jdbc.dao.PlatformAwareDaoBaseJdbc;
33 import org.kuali.rice.core.impl.datetime.DateTimeServiceImpl;
34 import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
35 import org.kuali.rice.coreservice.api.parameter.Parameter;
36 import org.kuali.rice.coreservice.api.parameter.ParameterKey;
37 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
38 import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
39 import org.kuali.rice.kns.service.KNSServiceLocator;
40 import org.kuali.rice.krad.lookup.CollectionIncomplete;
41 import org.kuali.rice.krad.service.KRADServiceLocator;
42 import org.kuali.rice.krad.util.BeanPropertyComparator;
43 import org.kuali.rice.krad.util.ObjectUtils;
44
45 import java.io.BufferedWriter;
46 import java.io.File;
47 import java.io.FileWriter;
48 import java.io.IOException;
49 import java.math.BigDecimal;
50 import java.text.SimpleDateFormat;
51 import java.util.*;
52
53
54
55
56 public class OLEReEncumberRecurringOrdersJobServiceImpl extends PlatformAwareDaoBaseJdbc implements OLEReEncumberRecurringOrdersJobService {
57
58 protected DateTimeService dateTimeService;
59 protected RunDateService runDateService;
60 protected ParameterService parameterService;
61
62 Map<String, String> preqAccountMap;
63 Map<String, String> cmAccountMap;
64 java.sql.Date date = new java.sql.Date(getDateTimeService().getCurrentTimestamp().getTime());
65 List<String> entriesList = new ArrayList<>();
66 Integer fiscalYear;
67 String fromDate = getParameter(OLEConstants.FROM_DATE);
68 String toDate = getParameter(OLEConstants.TO_DATE);
69
70
71 @Override
72 public void retrieveReEncumberRecuringOrders() {
73
74 String paramaterValue = getParameter(OLEConstants.REENCUMBER_RECURRING_ORDERS);
75 String[] value = paramaterValue.split(",");
76 List<String> entriesList = new ArrayList<>();
77 List<Map<String, Object>> poItemData = new ArrayList<Map<String, Object>>();
78 if (value.length > 0 && value[0].equalsIgnoreCase(OLEConstants.PO)) {
79 poItemData = executeQueryForPoOption();
80 processReencumbranceForPoOption(poItemData);
81
82 } else if (value.length > 0 && value[0].equalsIgnoreCase(OLEConstants.INVOICE)) {
83 List<Map<String, Object>> invoiceItemData = new ArrayList<Map<String, Object>>();
84 invoiceItemData = executeQueryForInvoiceOption();
85 processReencumbranceForInvoiceOption(invoiceItemData);
86 }
87
88 }
89
90 public List<Map<String, Object>> executeQueryForPoOption() {
91
92 fromDate = getParameter(OLEConstants.FROM_DATE);
93 toDate = getParameter(OLEConstants.TO_DATE);
94 String dbVendor = ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.DB_VENDOR);
95 if (dbVendor.equals(OLEConstants.MYSQL) && fromDate != null && toDate != null) {
96 String formattedFromDateForMySQL = formatDateForMySQL(fromDate);
97 String formattedToDateForMySQL = formatDateForMySQL(toDate);
98 String query = "select * from GL_ENTRY_T where FDOC_NBR in (select FDOC_NBR from PUR_PO_T where PO_ID in(select PO_ID from AP_PMT_RQST_T where PO_ID in (select PO_ID from PUR_PO_T where RECUR_PMT_TYP_CD is not null and PO_CRTE_DT between '" + formattedFromDateForMySQL + "' AND '" + formattedToDateForMySQL + "'and FDOC_NBR in (select DOC_HDR_ID from KREW_DOC_HDR_T where DOC_TYP_ID in (select DOC_TYP_ID from KREW_DOC_TYP_T where DOC_TYP_NM in('OLE_PO','OLE_POA')) and APP_DOC_STAT='Open')))) and FIN_BALANCE_TYP_CD='EX' and FDOC_TYP_CD in('OLE_PO','OLE_POA')";
99
100 return getSimpleJdbcTemplate().queryForList(query);
101 } else {
102 String formattedFromDateForOracle = formatDateForOracle(fromDate);
103 String formattedToDateForOracle = formatDateForOracle(toDate);
104 String query = "select * from GL_ENTRY_T where FDOC_NBR in (select FDOC_NBR from PUR_PO_T where PO_ID in(select PO_ID from AP_PMT_RQST_T where PO_ID in (select PO_ID from PUR_PO_T where RECUR_PMT_TYP_CD is not null and PO_CRTE_DT between '" + formattedFromDateForOracle + "' AND '" + formattedToDateForOracle + "'and FDOC_NBR in (select DOC_HDR_ID from KREW_DOC_HDR_T where DOC_TYP_ID in (select DOC_TYP_ID from KREW_DOC_TYP_T where DOC_TYP_NM in('OLE_PO','OLE_POA')) and APP_DOC_STAT='Open')))) and FIN_BALANCE_TYP_CD='EX' and FDOC_TYP_CD in('OLE_PO','OLE_POA')";
105
106 return getSimpleJdbcTemplate().queryForList(query);
107 }
108
109 }
110
111 public List<Map<String, Object>> executeQueryForInvoiceOption() {
112
113 String dbVendor = ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.DB_VENDOR);
114 if (dbVendor.equals(OLEConstants.MYSQL) && fromDate != null && toDate != null) {
115 String formattedFromDateForMySQL = formatDateForMySQL(fromDate);
116 String formattedToDateForMySQL = formatDateForMySQL(toDate);
117 String query = "select * from GL_ENTRY_T where FDOC_NBR in (select DOC_HDR_ID from KREW_DOC_HDR_T where DOC_HDR_ID in (select FDOC_NBR from PUR_PO_T where PO_ID in(select PO_ID from AP_PMT_RQST_T where PO_ID in (select PO_ID from PUR_PO_T where RECUR_PMT_TYP_CD is not null and PO_CRTE_DT between '" + formattedFromDateForMySQL + "' AND '" + formattedToDateForMySQL + "'))) and DOC_TYP_ID in (select DOC_TYP_ID from KREW_DOC_TYP_T where DOC_TYP_NM in('OLE_PO','OLE_POA')) and APP_DOC_STAT='Open') Order by FDOC_NBR and FIN_OBJECT_CD";
118 return getSimpleJdbcTemplate().queryForList(query);
119 } else {
120 String formattedFromDateForOracle = formatDateForOracle(fromDate);
121 String formattedToDateForOracle = formatDateForOracle(toDate);
122 String query = "select * from GL_ENTRY_T where FDOC_NBR in (select DOC_HDR_ID from KREW_DOC_HDR_T where DOC_HDR_ID in (select FDOC_NBR from PUR_PO_T where PO_ID in(select PO_ID from AP_PMT_RQST_T where PO_ID in (select PO_ID from PUR_PO_T where RECUR_PMT_TYP_CD is not null and PO_CRTE_DT between '" + formattedFromDateForOracle + "' AND '" + formattedToDateForOracle + "'))) and DOC_TYP_ID in (select DOC_TYP_ID from KREW_DOC_TYP_T where DOC_TYP_NM in('OLE_PO','OLE_POA')) and APP_DOC_STAT='Open')";
123 return getSimpleJdbcTemplate().queryForList(query);
124 }
125 }
126
127
128 public void processReencumbranceForPoOption(List<Map<String, Object>> poItemData) {
129
130 if (poItemData.size() > 0) {
131 try {
132 entriesList.clear();
133 for (Map<String, Object> poDataMap : poItemData) {
134 Entry entry = new Entry();
135 fiscalYear = new Integer(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
136 entry.setUniversityFiscalYear(fiscalYear + 1);
137 entry.setChartOfAccountsCode(poDataMap.get(OLEConstants.GL_CHART_CD).toString());
138 entry.setAccountNumber(poDataMap.get(OLEConstants.GL_ACCOUNT_NBR).toString());
139 entry.setSubAccountNumber(poDataMap.get(OLEConstants.GL_SUB_ACCT_NBR).toString());
140 entry.setFinancialObjectCode(poDataMap.get(OLEConstants.GL_OBJ_CD).toString());
141 entry.setFinancialSubObjectCode(poDataMap.get(OLEConstants.GL_SUB_OBJ_CD).toString());
142 entry.setFinancialBalanceTypeCode(poDataMap.get(OLEConstants.GL_BAL_TYP_CD).toString());
143 entry.setFinancialObjectTypeCode(poDataMap.get(OLEConstants.GL_OBJ_TYP_CD).toString());
144 entry.setUniversityFiscalPeriodCode(org.kuali.ole.sys.OLEConstants.PERIOD_CODE_BEGINNING_BALANCE);
145 entry.setFinancialDocumentTypeCode(poDataMap.get(OLEConstants.GL_FIN_DOC_TYP_CD).toString());
146 entry.setFinancialSystemOriginationCode(poDataMap.get(OLEConstants.GL_FIN_SYS_ORG_CD).toString());
147 entry.setDocumentNumber(poDataMap.get(OLEConstants.GL_DOC_NBR).toString());
148 entry.setTransactionLedgerEntrySequenceNumber(Integer.parseInt(poDataMap.get(OLEConstants.TRANS_LED_SEQ_NO).toString()));
149 entry.setTransactionLedgerEntryDescription(poDataMap.get(OLEConstants.GL_TRANS_LED_ENTRY_DESC).toString());
150 entry.setProjectCode(poDataMap.get(OLEConstants.PROJECT_CODE).toString());
151 entry.setReferenceFinancialDocumentTypeCode(poDataMap.get(OLEConstants.REF_DOC_TYP_CD).toString());
152 entry.setReferenceFinancialSystemOriginationCode(poDataMap.get(OLEConstants.REF_ORG_CD).toString());
153 entry.setTransactionEncumbranceUpdateCode(OLEConstants.ENCUM_UPDT_CD);
154 entry.setReferenceFinancialDocumentNumber(poDataMap.get(OLEConstants.FDOC_REF_NBR).toString());
155 KualiDecimal transactionLedgerEntryAmount = new KualiDecimal((BigDecimal) poDataMap.get(OLEConstants.GL_TRANS_LED_ENTRY_AMT));
156 transactionLedgerEntryAmount = calculateTransactionAmount(transactionLedgerEntryAmount);
157 entry.setTransactionLedgerEntryAmount(transactionLedgerEntryAmount);
158 entry.setTransactionDebitCreditCode(poDataMap.get(OLEConstants.GL_TRANS_DEB_CRE_CD).toString());
159 entry.setTransactionDate(date);
160 OriginEntryFull originEntryFullentry = new OriginEntryFull(entry);
161 entriesList.add(originEntryFullentry.getLine());
162 }
163 writeOuputFile();
164 } catch (Exception e) {
165 e.printStackTrace();
166 }
167 }
168 }
169
170
171 public void processReencumbranceForInvoiceOption(List<Map<String, Object>> invoiceItemData) {
172
173 if (invoiceItemData.size() > 0) {
174 try {
175 entriesList.clear();
176 KualiDecimal transactionLedgerEntryAmount = KualiDecimal.ZERO;
177 for (Map<String, Object> invoiceDataMap : invoiceItemData) {
178 Entry entry = new Entry();
179 fiscalYear = new Integer(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
180 entry.setUniversityFiscalYear(fiscalYear + 1);
181 entry.setChartOfAccountsCode(invoiceDataMap.get(OLEConstants.GL_CHART_CD).toString());
182 entry.setAccountNumber(invoiceDataMap.get(OLEConstants.GL_ACCOUNT_NBR).toString());
183 entry.setSubAccountNumber(invoiceDataMap.get(OLEConstants.GL_SUB_ACCT_NBR).toString());
184 entry.setFinancialObjectCode(invoiceDataMap.get(OLEConstants.GL_OBJ_CD).toString());
185 entry.setFinancialSubObjectCode(invoiceDataMap.get(OLEConstants.GL_SUB_OBJ_CD).toString());
186 entry.setFinancialBalanceTypeCode(invoiceDataMap.get(OLEConstants.GL_BAL_TYP_CD).toString());
187 entry.setFinancialObjectTypeCode(invoiceDataMap.get(OLEConstants.GL_OBJ_TYP_CD).toString());
188 entry.setUniversityFiscalPeriodCode(org.kuali.ole.sys.OLEConstants.PERIOD_CODE_BEGINNING_BALANCE);
189 entry.setFinancialDocumentTypeCode(invoiceDataMap.get(OLEConstants.GL_FIN_DOC_TYP_CD).toString());
190 entry.setFinancialSystemOriginationCode(invoiceDataMap.get(OLEConstants.GL_FIN_SYS_ORG_CD).toString());
191 entry.setDocumentNumber(invoiceDataMap.get(OLEConstants.GL_DOC_NBR).toString());
192 entry.setTransactionLedgerEntrySequenceNumber(Integer.parseInt(invoiceDataMap.get(OLEConstants.TRANS_LED_SEQ_NO).toString()));
193 entry.setTransactionLedgerEntryDescription(invoiceDataMap.get(OLEConstants.GL_TRANS_LED_ENTRY_DESC).toString());
194 transactionLedgerEntryAmount = getTotalInvoicedAmount(invoiceDataMap.get(OLEConstants.FDOC_REF_NBR).toString(), invoiceDataMap.get(OLEConstants.GL_CHART_CD).toString(), invoiceDataMap.get(OLEConstants.GL_ACCOUNT_NBR).toString(), invoiceDataMap.get(OLEConstants.GL_OBJ_CD).toString());
195 transactionLedgerEntryAmount = transactionLedgerEntryAmount.subtract(getTotalCreditMemoAmount(invoiceDataMap.get(OLEConstants.FDOC_REF_NBR).toString(),invoiceDataMap.get(OLEConstants.GL_CHART_CD).toString(),invoiceDataMap.get(OLEConstants.GL_ACCOUNT_NBR).toString(),invoiceDataMap.get(OLEConstants.GL_OBJ_CD).toString()));
196 transactionLedgerEntryAmount = calculateTransactionAmount(transactionLedgerEntryAmount);
197 entry.setTransactionLedgerEntryAmount(transactionLedgerEntryAmount);
198 entry.setTransactionDebitCreditCode(invoiceDataMap.get(OLEConstants.GL_TRANS_DEB_CRE_CD).toString());
199 entry.setProjectCode(invoiceDataMap.get(OLEConstants.PROJECT_CODE).toString());
200 entry.setReferenceFinancialDocumentTypeCode(invoiceDataMap.get(OLEConstants.REF_DOC_TYP_CD).toString());
201 entry.setReferenceFinancialSystemOriginationCode(invoiceDataMap.get(OLEConstants.REF_ORG_CD).toString());
202 entry.setTransactionEncumbranceUpdateCode(OLEConstants.ENCUM_UPDT_CD);
203 entry.setReferenceFinancialDocumentNumber(invoiceDataMap.get(OLEConstants.FDOC_REF_NBR).toString());
204 entry.setTransactionDate(date);
205 OriginEntryFull originEntryFullentry = new OriginEntryFull(entry);
206 entriesList.add(originEntryFullentry.getLine());
207 }
208 writeOuputFile();
209
210 } catch (Exception e) {
211 e.printStackTrace();
212 }
213 }
214 }
215
216 public KualiDecimal getTotalInvoicedAmount(String poId,String chartCode,String accountNumber,String objectCode) {
217 String query = "SELECT FIN_COA_CD,ACCOUNT_NBR,FIN_OBJECT_CD,sum(ITM_ACCT_TOT_AMT) as AMT FROM AP_PMT_RQST_ACCT_T where PMT_RQST_ITM_ID in(select PMT_RQST_ITM_ID from AP_PMT_RQST_ITM_T where PMT_RQST_ID in (select PMT_RQST_ID from AP_PMT_RQST_T where PO_ID =" + poId + ")) and FIN_COA_CD='" + chartCode + "' and ACCOUNT_NBR='" + accountNumber +"' GROUP BY ITM_ACCT_TOT_AMT,FIN_COA_CD,ACCOUNT_NBR,FIN_OBJECT_CD";
218 List<Map<String, Object>> preqData = getSimpleJdbcTemplate().queryForList(query);
219 KualiDecimal totalInvoicedAmount = KualiDecimal.ZERO;
220 if (preqData.size() > 0) {
221 for (Map<String, Object> dataMap : preqData) {
222 if (dataMap.get(OLEConstants.GL_CHART_CD).equals(chartCode) && dataMap.get(OLEConstants.GL_ACCOUNT_NBR).equals(accountNumber)) {
223 totalInvoicedAmount= totalInvoicedAmount.add(new KualiDecimal(dataMap.get(OLEConstants.GL_TOTAL_INV_AMT).toString()));
224 }
225 }
226 return totalInvoicedAmount;
227 }
228 return KualiDecimal.ZERO;
229 }
230
231 public KualiDecimal getTotalCreditMemoAmount(String poId,String chartCode,String accountNumber,String objectCode) {
232 String query = "SELECT FIN_COA_CD,ACCOUNT_NBR,FIN_OBJECT_CD,sum(ITM_ACCT_TOT_AMT) as AMT FROM AP_CRDT_MEMO_ACCT_T where CRDT_MEMO_ITM_ID in(select CRDT_MEMO_ITM_ID from AP_CRDT_MEMO_ITM_T where CRDT_MEMO_ID in (select CRDT_MEMO_ID from AP_CRDT_MEMO_T where PO_ID =" + poId + ")) and FIN_COA_CD='" + chartCode + "' and ACCOUNT_NBR='" + accountNumber +"' GROUP BY ITM_ACCT_TOT_AMT,FIN_COA_CD,ACCOUNT_NBR,FIN_OBJECT_CD";
233 List<Map<String, Object>> cmData = getSimpleJdbcTemplate().queryForList(query);
234 KualiDecimal totalCreditMemoAmount = KualiDecimal.ZERO;
235 if (cmData.size() > 0) {
236 for (Map<String, Object> dataMap : cmData) {
237 if (dataMap.get(OLEConstants.GL_CHART_CD) != null && dataMap.get(OLEConstants.GL_CHART_CD).equals(chartCode) && dataMap.get(OLEConstants.GL_ACCOUNT_NBR) != null && dataMap.get(OLEConstants.GL_ACCOUNT_NBR).equals(accountNumber)) {
238 totalCreditMemoAmount = totalCreditMemoAmount.add(new KualiDecimal(dataMap.get(OLEConstants.GL_TOTAL_INV_AMT).toString()));
239 }
240 }
241 return totalCreditMemoAmount;
242 }
243 return KualiDecimal.ZERO;
244 }
245
246 public KualiDecimal calculateTransactionAmount(KualiDecimal transactionLedgerEntryAmount) {
247 String paramaterValue = getParameter(OLEConstants.REENCUMBER_RECURRING_ORDERS);
248 if (paramaterValue.contains("+")) {
249 String amount = paramaterValue.replaceAll("[^0-9]", "");
250 KualiDecimalAdapter kualiDecimalAdapter = new KualiDecimalAdapter();
251 KualiDecimal dollar = null;
252 try {
253 dollar = kualiDecimalAdapter.unmarshal(amount);
254 } catch (Exception e) {
255 e.printStackTrace();
256 }
257 if (paramaterValue.contains("$")) {
258 transactionLedgerEntryAmount = transactionLedgerEntryAmount.add(dollar);
259 } else {
260 transactionLedgerEntryAmount = transactionLedgerEntryAmount.add((transactionLedgerEntryAmount.multiply(dollar)).divide(new KualiDecimal(100)));
261 }
262 } else {
263 String amount = paramaterValue.replaceAll("[^0-9]", "");
264 KualiDecimalAdapter kualiDecimalAdapter = new KualiDecimalAdapter();
265 KualiDecimal dollar = null;
266 try {
267 dollar = kualiDecimalAdapter.unmarshal(amount);
268 } catch (Exception e) {
269 e.printStackTrace();
270 }
271 if (paramaterValue.contains("$")) {
272 transactionLedgerEntryAmount = transactionLedgerEntryAmount.subtract(dollar);
273 } else {
274 transactionLedgerEntryAmount = transactionLedgerEntryAmount.subtract((transactionLedgerEntryAmount.multiply(dollar)).divide(new KualiDecimal(100)));
275 }
276 }
277 return transactionLedgerEntryAmount;
278 }
279
280
281 public String getParameter(String name) {
282 ParameterKey parameterKey = ParameterKey.create(OLEConstants.APPL_ID_OLE, org.kuali.ole.OLEConstants.SELECT_NMSPC, org.kuali.ole.OLEConstants.SELECT_CMPNT, name);
283 Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
284 return parameter != null ? parameter.getValue() : null;
285 }
286
287 public void writeOuputFile() {
288
289 String fileDirectory = ConfigContext.getCurrentContextConfig().getProperty(org.kuali.ole.OLEConstants.STAGING_DIRECTORY) + OLEConstants.REENCUMBER_FILE_DIRECTORY;
290 new File(fileDirectory).mkdir();
291 Date date = new Date();
292 String fileCreationDate = new SimpleDateFormat(OLEConstants.FILE_DATE_FORMAT).format(date);
293 String filePath = fileDirectory + OLEConstants.REENCUMBER_FILE_PATH +"_"+fileCreationDate+ GeneralLedgerConstants.BatchFileSystem.EXTENSION;
294 File file = new File(filePath);
295 BufferedWriter bwr = null;
296 try {
297 file.createNewFile();
298 bwr = new BufferedWriter(new FileWriter(file));
299 if (entriesList != null && entriesList.size() > 0) {
300 for (String entry : entriesList) {
301 bwr.write(entry);
302 bwr.write("\n");
303 }
304 }
305 bwr.flush();
306 bwr.close();
307 } catch (IOException e) {
308 e.printStackTrace();
309 }
310 }
311
312 public DateTimeService getDateTimeService() {
313 if (dateTimeService == null) {
314 return (DateTimeService) SpringContext.getService(OLEConstants.DATE_SERVICE);
315 }
316 return dateTimeService;
317 }
318
319
320 public RunDateService getRunDateService() {
321 if (runDateService == null) {
322 return (RunDateService) SpringContext.getService(OLEConstants.RUN_DATE_SERVICE);
323 }
324 return runDateService;
325 }
326
327 public java.sql.Date calculateRunDate(java.util.Date currentDate) {
328 return new java.sql.Date(getRunDateService().calculateRunDate(currentDate).getTime());
329 }
330
331 public ParameterService getParameterService() {
332 if (parameterService == null) {
333 parameterService = (ParameterService) SpringContext.getService(OLEConstants.PARAMETER_SERVICE);
334 }
335 return parameterService;
336 }
337
338 private String formatDateForOracle(String date) {
339 String forOracle = DateFormatHelper.getInstance().generateDateStringsForOracle(date);
340 return forOracle;
341 }
342
343 private String formatDateForMySQL(String date) {
344 java.util.Date ss1 = new Date(date);
345 SimpleDateFormat formatter = new SimpleDateFormat(OLEConstants.RENCUM_DATE_FORMAT);
346 String forMysql = formatter.format(ss1);
347 return forMysql;
348 }
349
350 }
351