View Javadoc
1   package org.kuali.ole.select.document.service.impl;
2   
3   import org.kuali.ole.OLEConstants;
4   import org.kuali.ole.deliver.service.DateFormatHelper;
5   import org.kuali.ole.gl.GeneralLedgerConstants;
6   import org.kuali.ole.gl.batch.service.RunDateService;
7   import org.kuali.ole.gl.businessobject.Entry;
8   import org.kuali.ole.gl.businessobject.OriginEntryFull;
9   import org.kuali.ole.select.document.service.OLEReEncumberRecurringOrdersJobService;
10  import org.kuali.ole.sys.context.SpringContext;
11  import org.kuali.ole.sys.service.impl.OleParameterConstants;
12  import org.kuali.rice.core.api.config.property.ConfigContext;
13  import org.kuali.rice.core.api.datetime.DateTimeService;
14  import org.kuali.rice.core.api.util.jaxb.KualiDecimalAdapter;
15  import org.kuali.rice.core.api.util.type.KualiDecimal;
16  import org.kuali.rice.core.framework.persistence.jdbc.dao.PlatformAwareDaoBaseJdbc;
17  import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
18  import org.kuali.rice.coreservice.api.parameter.Parameter;
19  import org.kuali.rice.coreservice.api.parameter.ParameterKey;
20  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
21  
22  import java.io.BufferedWriter;
23  import java.io.File;
24  import java.io.FileWriter;
25  import java.math.BigDecimal;
26  import java.sql.Timestamp;
27  import java.text.SimpleDateFormat;
28  import java.util.ArrayList;
29  import java.util.Date;
30  import java.util.List;
31  import java.util.Map;
32  
33  /**
34   * Created by arunag on 12/3/14.
35   */
36  public class OLEReEncumberRecurringOrdersJobServiceImpl extends PlatformAwareDaoBaseJdbc implements OLEReEncumberRecurringOrdersJobService {
37  
38      protected DateTimeService dateTimeService;
39      protected RunDateService runDateService;
40      protected ParameterService parameterService;
41  
42      @Override
43      public void retrieveReEncumberRecuringOrders() {
44  
45          String paramaterValue = getParameter(OLEConstants.REENCUMBER_RECURRING_ORDERS);
46          String fromDate =  getParameter(OLEConstants.FROM_DATE);
47          String toDate =  getParameter(OLEConstants.TO_DATE);
48          java.sql.Date today = new java.sql.Date(getDateTimeService().getCurrentTimestamp().getTime());
49          String dbVendor = ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.DB_VENDOR);
50          String[] value = paramaterValue.split(",");
51          List<String> entriesList = new ArrayList<>();
52          List<Map<String, Object>> poItemData = new ArrayList<Map<String, Object>>();
53          Integer fiscalYear =  new Integer(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
54          if (value.length > 0 && value[0].equalsIgnoreCase(OLEConstants.PO)) {
55              if (dbVendor.equals(OLEConstants.MYSQL) && fromDate != null && toDate != null) {
56                  String formattedFromDateForMySQL = formatDateForMySQL(fromDate);
57                  String formattedToDateForMySQL = formatDateForMySQL(toDate);
58                  String query = "select * from GL_ENTRY_T where  FIN_BALANCE_TYP_CD='EX' and 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+"')))";
59                  poItemData = getSimpleJdbcTemplate().queryForList(query);
60              } else {
61                  String formattedFromDateForOracle = formatDateForOracle(fromDate);
62                  String formattedToDateForOracle = formatDateForOracle(toDate);
63                  String query = "select * from GL_ENTRY_T where  FIN_BALANCE_TYP_CD='EX' and 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+"')))";
64                  poItemData = getSimpleJdbcTemplate().queryForList(query);
65              }
66  
67              if (poItemData.size() > 0) {
68                  try {
69                      entriesList.clear();
70                      for (Map<String, Object> poDataMap : poItemData) {
71  
72                          Entry entry = new Entry();
73                          entry.setUniversityFiscalYear(fiscalYear+1);
74                          entry.setChartOfAccountsCode(poDataMap.get(OLEConstants.GL_CHART_CD).toString());
75                          entry.setAccountNumber(poDataMap.get(OLEConstants.GL_ACCOUNT_NBR).toString());
76                          entry.setSubAccountNumber(poDataMap.get(OLEConstants.GL_SUB_ACCT_NBR).toString());
77                          entry.setFinancialObjectCode(poDataMap.get(OLEConstants.GL_OBJ_CD).toString());
78                          entry.setFinancialSubObjectCode(poDataMap.get(OLEConstants.GL_SUB_OBJ_CD).toString());
79                          entry.setFinancialBalanceTypeCode(poDataMap.get(OLEConstants.GL_BAL_TYP_CD).toString());
80                          entry.setFinancialObjectTypeCode(poDataMap.get(OLEConstants.GL_OBJ_TYP_CD).toString());
81                          entry.setUniversityFiscalPeriodCode(org.kuali.ole.sys.OLEConstants.PERIOD_CODE_BEGINNING_BALANCE);
82                          entry.setFinancialDocumentTypeCode(poDataMap.get(OLEConstants.GL_FIN_DOC_TYP_CD).toString());
83                          entry.setFinancialSystemOriginationCode(poDataMap.get(OLEConstants.GL_FIN_SYS_ORG_CD).toString());
84                          entry.setDocumentNumber(poDataMap.get(OLEConstants.GL_DOC_NBR).toString());
85                          entry.setTransactionLedgerEntrySequenceNumber(Integer.parseInt(poDataMap.get(OLEConstants.TRANS_LED_SEQ_NO).toString()));
86                          entry.setTransactionLedgerEntryDescription(poDataMap.get(OLEConstants.GL_TRANS_LED_ENTRY_DESC).toString());
87                          entry.setProjectCode(poDataMap.get(OLEConstants.PROJECT_CODE).toString());
88                          entry.setReferenceFinancialDocumentTypeCode(poDataMap.get(OLEConstants.REF_DOC_TYP_CD).toString());
89                          entry.setReferenceFinancialSystemOriginationCode(poDataMap.get(OLEConstants.REF_ORG_CD).toString());
90                          entry.setTransactionEncumbranceUpdateCode(OLEConstants.ENCUM_UPDT_CD);
91                          entry.setReferenceFinancialDocumentNumber(poDataMap.get(OLEConstants.FDOC_REF_NBR).toString());
92                          KualiDecimal transactionLedgerEntryAmount = new KualiDecimal((BigDecimal) poDataMap.get(OLEConstants.GL_TRANS_LED_ENTRY_AMT));
93                          if (paramaterValue.contains("+")) {
94                              String amount = paramaterValue.replaceAll("[^0-9]", "");
95                              KualiDecimalAdapter kualiDecimalAdapter = new KualiDecimalAdapter();
96                              KualiDecimal dollar = kualiDecimalAdapter.unmarshal(amount);
97                              if (paramaterValue.contains("$")) {
98                                  transactionLedgerEntryAmount = transactionLedgerEntryAmount.add(dollar);
99                              } else {
100                                 transactionLedgerEntryAmount = transactionLedgerEntryAmount.add((transactionLedgerEntryAmount.multiply(dollar)).divide(new KualiDecimal(100)));
101                             }
102                         } else {
103                             String amount = paramaterValue.replaceAll("[^0-9]", "");
104                             KualiDecimalAdapter kualiDecimalAdapter = new KualiDecimalAdapter();
105                             KualiDecimal dollar = kualiDecimalAdapter.unmarshal(amount);
106                             if (paramaterValue.contains("$")) {
107                                 transactionLedgerEntryAmount = transactionLedgerEntryAmount.subtract(dollar);
108                             } else {
109                                 transactionLedgerEntryAmount = transactionLedgerEntryAmount.subtract((transactionLedgerEntryAmount.multiply(dollar)).divide(new KualiDecimal(100)));
110                             }
111                         }
112                         entry.setTransactionLedgerEntryAmount(transactionLedgerEntryAmount);
113                         entry.setTransactionDebitCreditCode(poDataMap.get(OLEConstants.GL_TRANS_DEB_CRE_CD).toString());
114                         entry.setTransactionDate(today);
115                         OriginEntryFull originEntryFullentry = new OriginEntryFull(entry);
116                         entriesList.add(originEntryFullentry.getLine());
117                     }
118                     String fileDirectory = ConfigContext.getCurrentContextConfig().getProperty(org.kuali.ole.OLEConstants.STAGING_DIRECTORY) + OLEConstants.REENCUMBER_FILE_DIRECTORY;
119                     new File(fileDirectory).mkdir();
120                     Date runDate = calculateRunDate(getDateTimeService().getCurrentDate());
121                     String filePath = fileDirectory +OLEConstants.REENCUMBER_FILE_PATH+runDate+ GeneralLedgerConstants.BatchFileSystem.EXTENSION;
122                     File file = new File(filePath);
123                     file.createNewFile();
124                     BufferedWriter bwr = new BufferedWriter(new FileWriter(file));
125                     if (entriesList != null && entriesList.size() > 0) {
126                         for (String entry : entriesList) {
127                             bwr.write(entry);
128                             bwr.write("\n");
129                         }
130                     }
131                     bwr.flush();
132                     bwr.close();
133                 } catch (Exception e) {
134                     e.printStackTrace();
135                 }
136             }
137 
138         } else if (value.length > 0 && value[0].equalsIgnoreCase(OLEConstants.INVOICE)) {
139             List<Map<String, Object>> invoiceItemData = new ArrayList<Map<String, Object>>();
140             //The below query bring the the sum transaction amount from the payment request record of gl_entry_t table and rest of the fields from the PO record of the gl_entry_t table
141             if (dbVendor.equals(OLEConstants.MYSQL) && fromDate != null && toDate != null) {
142                 String formattedFromDateForMySQL = formatDateForMySQL(fromDate);
143                 String formattedToDateForMySQL = formatDateForMySQL(toDate);
144             String query = "SELECT \n" +
145                     "GE1.FDOC_REF_NBR,GE1.UNIV_FISCAL_YR,GE1.FDOC_NBR,GE1.FIN_COA_CD,GE1.ACCOUNT_NBR,GE1.SUB_ACCT_NBR,GE1.FIN_OBJECT_CD,GE1.FIN_SUB_OBJ_CD,\n" +
146                     "GE1.FIN_BALANCE_TYP_CD,GE1.FIN_OBJ_TYP_CD,GE1.UNIV_FISCAL_PRD_CD,GE1.FDOC_TYP_CD,GE1.FS_ORIGIN_CD,GE1.TRN_ENTR_SEQ_NBR,GE1.TRN_LDGR_ENTR_DESC,\n" +
147                     "GE1.TRN_DEBIT_CRDT_CD,GE1.PROJECT_CD,GE1.FDOC_REF_TYP_CD,GE1.FS_REF_ORIGIN_CD,GE1.TRN_ENCUM_UPDT_CD,SUM(GE2.AMT) AS AMT \n" +
148                     "FROM \n" +
149                     "GL_ENTRY_T GE1,\n" +
150                     "(SELECT \n" +
151                     "(SELECT DISTINCT(FDOC_NBR) FROM GL_ENTRY_T GE3 WHERE GE3.FDOC_REF_NBR=GE.FDOC_REF_NBR AND FDOC_TYP_CD='OLE_PO' AND TRN_DEBIT_CRDT_CD='D') AS GEFDOC_REF_NBR,\n" +
152                     "  SUM(TRN_LDGR_ENTR_AMT) AS AMT,GE.ACCOUNT_NBR AS ACCNBR,GE.SUB_ACCT_NBR AS SUBACCNBR,GE.FIN_OBJECT_CD AS OBJCD \n" +
153                     "  FROM GL_ENTRY_T GE,AP_PMT_RQST_T PREQ,PUR_PO_T PO\n" +
154                     "  WHERE GE.FIN_BALANCE_TYP_CD='AC' AND GE.TRN_DEBIT_CRDT_CD='D' \n" +
155                     "  AND GE.FDOC_NBR=PREQ.FDOC_NBR AND PO.PO_ID=PREQ.PO_ID AND PO.RECUR_PMT_TYP_CD IS NOT NULL AND  PO_CRTE_DT BETWEEN '"+formattedFromDateForMySQL+"' AND '" +formattedToDateForMySQL+"'\n" +
156                     "  AND PO.FDOC_NBR=(SELECT DISTINCT(FDOC_NBR) FROM GL_ENTRY_T GE4 WHERE PO.PO_ID=GE4.FDOC_REF_NBR AND FDOC_TYP_CD='OLE_PO' AND TRN_DEBIT_CRDT_CD='D')\n" +
157                     "  GROUP BY PREQ.PO_ID,GE.FDOC_REF_NBR,GE.ACCOUNT_NBR,GE.SUB_ACCT_NBR,GE.FIN_OBJECT_CD) GE2 \n" +
158                     "WHERE \n" +
159                     "GE1.FDOC_NBR=GE2.GEFDOC_REF_NBR AND GE1.ACCOUNT_NBR=GE2.ACCNBR \n" +
160                     "GROUP BY\n" +
161                     "GE1.FDOC_REF_NBR,GE1.UNIV_FISCAL_YR,GE1.FDOC_NBR,GE1.FIN_COA_CD,GE1.ACCOUNT_NBR,GE1.SUB_ACCT_NBR,GE1.FIN_OBJECT_CD,GE1.FIN_SUB_OBJ_CD,GE1.FIN_BALANCE_TYP_CD,\n" +
162                     "GE1.FIN_OBJ_TYP_CD,GE1.UNIV_FISCAL_PRD_CD,GE1.FDOC_TYP_CD,GE1.FS_ORIGIN_CD,GE1.TRN_ENTR_SEQ_NBR,GE1.TRN_LDGR_ENTR_DESC,GE1.TRN_DEBIT_CRDT_CD,GE1.PROJECT_CD,GE1.FDOC_REF_TYP_CD,GE1.FS_REF_ORIGIN_CD,GE1.TRN_ENCUM_UPDT_CD \n" +
163                     "ORDER BY GE1.FDOC_REF_NBR,GE1.ACCOUNT_NBR,GE1.SUB_ACCT_NBR,GE1.FIN_OBJECT_CD";
164 
165                     invoiceItemData = getSimpleJdbcTemplate().queryForList(query);
166             }else {
167                 String formattedFromDateForOracle = formatDateForOracle(fromDate);
168                 String formattedToDateForOracle = formatDateForOracle(toDate);
169                 String query = "SELECT \n" +
170                         "GE1.FDOC_REF_NBR,GE1.UNIV_FISCAL_YR,GE1.FDOC_NBR,GE1.FIN_COA_CD,GE1.ACCOUNT_NBR,GE1.SUB_ACCT_NBR,GE1.FIN_OBJECT_CD,GE1.FIN_SUB_OBJ_CD,\n" +
171                         "GE1.FIN_BALANCE_TYP_CD,GE1.FIN_OBJ_TYP_CD,GE1.UNIV_FISCAL_PRD_CD,GE1.FDOC_TYP_CD,GE1.FS_ORIGIN_CD,GE1.TRN_ENTR_SEQ_NBR,GE1.TRN_LDGR_ENTR_DESC,\n" +
172                         "GE1.TRN_DEBIT_CRDT_CD,GE1.PROJECT_CD,GE1.FDOC_REF_TYP_CD,GE1.FS_REF_ORIGIN_CD,GE1.TRN_ENCUM_UPDT_CD,SUM(GE2.AMT) AS AMT \n" +
173                         "FROM \n" +
174                         "GL_ENTRY_T GE1,\n" +
175                         "(SELECT \n" +
176                         "(SELECT DISTINCT(FDOC_NBR) FROM GL_ENTRY_T GE3 WHERE GE3.FDOC_REF_NBR=GE.FDOC_REF_NBR AND FDOC_TYP_CD='OLE_PO' AND TRN_DEBIT_CRDT_CD='D') AS GEFDOC_REF_NBR,\n" +
177                         "  SUM(TRN_LDGR_ENTR_AMT) AS AMT,GE.ACCOUNT_NBR AS ACCNBR,GE.SUB_ACCT_NBR AS SUBACCNBR,GE.FIN_OBJECT_CD AS OBJCD \n" +
178                         "  FROM GL_ENTRY_T GE,AP_PMT_RQST_T PREQ,PUR_PO_T PO\n" +
179                         "  WHERE GE.FIN_BALANCE_TYP_CD='AC' AND GE.TRN_DEBIT_CRDT_CD='D' \n" +
180                         "  AND GE.FDOC_NBR=PREQ.FDOC_NBR AND PO.PO_ID=PREQ.PO_ID AND PO.RECUR_PMT_TYP_CD IS NOT NULL AND  PO_CRTE_DT BETWEEN '"+formattedFromDateForOracle+"' AND '" +formattedToDateForOracle+"'\n" +
181                         "  AND PO.FDOC_NBR=(SELECT DISTINCT(FDOC_NBR) FROM GL_ENTRY_T GE4 WHERE PO.PO_ID=GE4.FDOC_REF_NBR AND FDOC_TYP_CD='OLE_PO' AND TRN_DEBIT_CRDT_CD='D')\n" +
182                         "  GROUP BY PREQ.PO_ID,GE.FDOC_REF_NBR,GE.ACCOUNT_NBR,GE.SUB_ACCT_NBR,GE.FIN_OBJECT_CD) GE2 \n" +
183                         "WHERE \n" +
184                         "GE1.FDOC_NBR=GE2.GEFDOC_REF_NBR AND GE1.ACCOUNT_NBR=GE2.ACCNBR \n" +
185                         "GROUP BY\n" +
186                         "GE1.FDOC_REF_NBR,GE1.UNIV_FISCAL_YR,GE1.FDOC_NBR,GE1.FIN_COA_CD,GE1.ACCOUNT_NBR,GE1.SUB_ACCT_NBR,GE1.FIN_OBJECT_CD,GE1.FIN_SUB_OBJ_CD,GE1.FIN_BALANCE_TYP_CD,\n" +
187                         "GE1.FIN_OBJ_TYP_CD,GE1.UNIV_FISCAL_PRD_CD,GE1.FDOC_TYP_CD,GE1.FS_ORIGIN_CD,GE1.TRN_ENTR_SEQ_NBR,GE1.TRN_LDGR_ENTR_DESC,GE1.TRN_DEBIT_CRDT_CD,GE1.PROJECT_CD,GE1.FDOC_REF_TYP_CD,GE1.FS_REF_ORIGIN_CD,GE1.TRN_ENCUM_UPDT_CD \n" +
188                         "ORDER BY GE1.FDOC_REF_NBR,GE1.ACCOUNT_NBR,GE1.SUB_ACCT_NBR,GE1.FIN_OBJECT_CD";
189 
190                         invoiceItemData = getSimpleJdbcTemplate().queryForList(query);
191             }
192             if (invoiceItemData.size() > 0) {
193                 try {
194                     entriesList.clear();
195                     for (Map<String, Object> invoiceDataMap : invoiceItemData) {
196                         Entry entry = new Entry();
197                         entry.setUniversityFiscalYear(fiscalYear+1);
198                         entry.setChartOfAccountsCode(invoiceDataMap.get(OLEConstants.GL_CHART_CD).toString());
199                         entry.setAccountNumber(invoiceDataMap.get(OLEConstants.GL_ACCOUNT_NBR).toString());
200                         entry.setSubAccountNumber(invoiceDataMap.get(OLEConstants.GL_SUB_ACCT_NBR).toString());
201                         entry.setFinancialObjectCode(invoiceDataMap.get(OLEConstants.GL_OBJ_CD).toString());
202                         entry.setFinancialSubObjectCode(invoiceDataMap.get(OLEConstants.GL_SUB_OBJ_CD).toString());
203                         entry.setFinancialBalanceTypeCode(invoiceDataMap.get(OLEConstants.GL_BAL_TYP_CD).toString());
204                         entry.setFinancialObjectTypeCode(invoiceDataMap.get(OLEConstants.GL_OBJ_TYP_CD).toString());
205                         entry.setUniversityFiscalPeriodCode(org.kuali.ole.sys.OLEConstants.PERIOD_CODE_BEGINNING_BALANCE);
206                         entry.setFinancialDocumentTypeCode(invoiceDataMap.get(OLEConstants.GL_FIN_DOC_TYP_CD).toString());
207                         entry.setFinancialSystemOriginationCode(invoiceDataMap.get(OLEConstants.GL_FIN_SYS_ORG_CD).toString());
208                         entry.setDocumentNumber(invoiceDataMap.get(OLEConstants.GL_DOC_NBR).toString());
209                         entry.setTransactionLedgerEntrySequenceNumber(Integer.parseInt(invoiceDataMap.get(OLEConstants.TRANS_LED_SEQ_NO).toString()));
210                         entry.setTransactionLedgerEntryDescription(invoiceDataMap.get(OLEConstants.GL_TRANS_LED_ENTRY_DESC).toString());
211                         KualiDecimal transactionLedgerEntryAmount = new KualiDecimal((BigDecimal) invoiceDataMap.get(OLEConstants.GL_TOTAL_INV_AMT));
212                         if (paramaterValue.contains("+")) {
213                             String amount = paramaterValue.replaceAll("[^0-9]", "");
214                             KualiDecimalAdapter kualiDecimalAdapter = new KualiDecimalAdapter();
215                             KualiDecimal dollar = kualiDecimalAdapter.unmarshal(amount);
216                             if (paramaterValue.contains("$")) {
217                                 transactionLedgerEntryAmount = transactionLedgerEntryAmount.add(dollar);
218                             } else {
219                                 transactionLedgerEntryAmount = transactionLedgerEntryAmount.add((transactionLedgerEntryAmount.multiply(dollar)).divide(new KualiDecimal(100)));
220                             }
221                         } else {
222                             String amount = paramaterValue.replaceAll("[^0-9]", "");
223                             KualiDecimalAdapter kualiDecimalAdapter = new KualiDecimalAdapter();
224                             KualiDecimal dollar = kualiDecimalAdapter.unmarshal(amount);
225                             if (paramaterValue.contains("$")) {
226                                 transactionLedgerEntryAmount = transactionLedgerEntryAmount.subtract(dollar);
227                             } else {
228                                 transactionLedgerEntryAmount = transactionLedgerEntryAmount.subtract((transactionLedgerEntryAmount.multiply(dollar)).divide(new KualiDecimal(100)));
229                             }
230                         }
231 
232                         entry.setTransactionLedgerEntryAmount(transactionLedgerEntryAmount);
233                         entry.setTransactionDebitCreditCode(invoiceDataMap.get(OLEConstants.GL_TRANS_DEB_CRE_CD).toString());
234                         entry.setProjectCode(invoiceDataMap.get(OLEConstants.PROJECT_CODE).toString());
235                         entry.setReferenceFinancialDocumentTypeCode(invoiceDataMap.get(OLEConstants.REF_DOC_TYP_CD).toString());
236                         entry.setReferenceFinancialSystemOriginationCode(invoiceDataMap.get(OLEConstants.REF_ORG_CD).toString());
237                         entry.setTransactionEncumbranceUpdateCode(OLEConstants.ENCUM_UPDT_CD);
238                         entry.setReferenceFinancialDocumentNumber(invoiceDataMap.get(OLEConstants.FDOC_REF_NBR).toString());
239                         entry.setTransactionDate(today);
240                        // entry.setTransactionDate(new java.sql.Date(((Timestamp) invoiceDataMap.get(OLEConstants.GL_TRANS_DT)).getTime()));
241                         OriginEntryFull originEntryFullentry = new OriginEntryFull(entry);
242                         entriesList.add(originEntryFullentry.getLine());
243                     }
244                     String fileDirectory = ConfigContext.getCurrentContextConfig().getProperty(org.kuali.ole.OLEConstants.STAGING_DIRECTORY) + OLEConstants.REENCUMBER_FILE_DIRECTORY;
245                     new File(fileDirectory).mkdir();
246                     Date runDate = calculateRunDate(getDateTimeService().getCurrentDate());
247                     String filePath = fileDirectory + OLEConstants.REENCUMBER_FILE_PATH + runDate + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
248                     File file = new File(filePath);
249                     file.createNewFile();
250                     BufferedWriter bwr = new BufferedWriter(new FileWriter(file));
251                     if (entriesList != null && entriesList.size() > 0) {
252                         for (String entry : entriesList) {
253                             bwr.write(entry);
254                             bwr.write("\n");
255                         }
256                     }
257                     bwr.flush();
258                     bwr.close();
259                 } catch (Exception e) {
260                     e.printStackTrace();
261                 }
262             }
263 
264         }
265 
266     }
267 
268 
269     public String getParameter(String name) {
270         ParameterKey parameterKey = ParameterKey.create(OLEConstants.APPL_ID_OLE, org.kuali.ole.OLEConstants.SELECT_NMSPC, org.kuali.ole.OLEConstants.SELECT_CMPNT, name);
271         Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
272         return parameter != null ? parameter.getValue() : null;
273     }
274 
275     public DateTimeService getDateTimeService() {
276         if(dateTimeService == null) {
277             return SpringContext.getBean(DateTimeService.class);
278         }
279         return dateTimeService;
280     }
281 
282 
283     public RunDateService getRunDateService() {
284         if(runDateService == null) {
285             return SpringContext.getBean(RunDateService.class);
286         }
287         return runDateService;
288     }
289 
290     public java.sql.Date calculateRunDate(java.util.Date currentDate) {
291         return new java.sql.Date(getRunDateService().calculateRunDate(currentDate).getTime());
292     }
293 
294     public ParameterService getParameterService() {
295         if(parameterService == null) {
296             parameterService = SpringContext.getBean(ParameterService.class);
297         }
298         return parameterService;
299     }
300 
301     private String formatDateForOracle(String date) {
302         String forOracle = DateFormatHelper.getInstance().generateDateStringsForOracle(date);
303         return forOracle;
304     }
305 
306     private String formatDateForMySQL(String date) {
307         java.util.Date  ss1=new Date(date);
308         SimpleDateFormat formatter=new SimpleDateFormat(OLEConstants.RENCUM_DATE_FORMAT);
309         String forMysql = formatter.format(ss1);
310         return forMysql;
311     }
312 
313 }
314