001package org.kuali.ole.select.document.service.impl; 002 003import org.kuali.ole.OLEConstants; 004import org.kuali.ole.deliver.service.DateFormatHelper; 005import org.kuali.ole.gl.GeneralLedgerConstants; 006import org.kuali.ole.gl.batch.service.RunDateService; 007import org.kuali.ole.gl.businessobject.Entry; 008import org.kuali.ole.gl.businessobject.OriginEntryFull; 009import org.kuali.ole.select.document.service.OLEReEncumberRecurringOrdersJobService; 010import org.kuali.ole.sys.context.SpringContext; 011import org.kuali.ole.sys.service.impl.OleParameterConstants; 012import org.kuali.rice.core.api.config.property.ConfigContext; 013import org.kuali.rice.core.api.datetime.DateTimeService; 014import org.kuali.rice.core.api.util.jaxb.KualiDecimalAdapter; 015import org.kuali.rice.core.api.util.type.KualiDecimal; 016import org.kuali.rice.core.framework.persistence.jdbc.dao.PlatformAwareDaoBaseJdbc; 017import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator; 018import org.kuali.rice.coreservice.api.parameter.Parameter; 019import org.kuali.rice.coreservice.api.parameter.ParameterKey; 020import org.kuali.rice.coreservice.framework.parameter.ParameterService; 021 022import java.io.BufferedWriter; 023import java.io.File; 024import java.io.FileWriter; 025import java.math.BigDecimal; 026import java.sql.Timestamp; 027import java.text.SimpleDateFormat; 028import java.util.ArrayList; 029import java.util.Date; 030import java.util.List; 031import java.util.Map; 032 033/** 034 * Created by arunag on 12/3/14. 035 */ 036public class OLEReEncumberRecurringOrdersJobServiceImpl extends PlatformAwareDaoBaseJdbc implements OLEReEncumberRecurringOrdersJobService { 037 038 protected DateTimeService dateTimeService; 039 protected RunDateService runDateService; 040 protected ParameterService parameterService; 041 042 @Override 043 public void retrieveReEncumberRecuringOrders() { 044 045 String paramaterValue = getParameter(OLEConstants.REENCUMBER_RECURRING_ORDERS); 046 String fromDate = getParameter(OLEConstants.FROM_DATE); 047 String toDate = getParameter(OLEConstants.TO_DATE); 048 java.sql.Date today = new java.sql.Date(getDateTimeService().getCurrentTimestamp().getTime()); 049 String dbVendor = ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.DB_VENDOR); 050 String[] value = paramaterValue.split(","); 051 List<String> entriesList = new ArrayList<>(); 052 List<Map<String, Object>> poItemData = new ArrayList<Map<String, Object>>(); 053 Integer fiscalYear = new Integer(getParameterService().getParameterValueAsString(OleParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM)); 054 if (value.length > 0 && value[0].equalsIgnoreCase(OLEConstants.PO)) { 055 if (dbVendor.equals(OLEConstants.MYSQL) && fromDate != null && toDate != null) { 056 String formattedFromDateForMySQL = formatDateForMySQL(fromDate); 057 String formattedToDateForMySQL = formatDateForMySQL(toDate); 058 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+"')))"; 059 poItemData = getSimpleJdbcTemplate().queryForList(query); 060 } else { 061 String formattedFromDateForOracle = formatDateForOracle(fromDate); 062 String formattedToDateForOracle = formatDateForOracle(toDate); 063 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+"')))"; 064 poItemData = getSimpleJdbcTemplate().queryForList(query); 065 } 066 067 if (poItemData.size() > 0) { 068 try { 069 entriesList.clear(); 070 for (Map<String, Object> poDataMap : poItemData) { 071 072 Entry entry = new Entry(); 073 entry.setUniversityFiscalYear(fiscalYear+1); 074 entry.setChartOfAccountsCode(poDataMap.get(OLEConstants.GL_CHART_CD).toString()); 075 entry.setAccountNumber(poDataMap.get(OLEConstants.GL_ACCOUNT_NBR).toString()); 076 entry.setSubAccountNumber(poDataMap.get(OLEConstants.GL_SUB_ACCT_NBR).toString()); 077 entry.setFinancialObjectCode(poDataMap.get(OLEConstants.GL_OBJ_CD).toString()); 078 entry.setFinancialSubObjectCode(poDataMap.get(OLEConstants.GL_SUB_OBJ_CD).toString()); 079 entry.setFinancialBalanceTypeCode(poDataMap.get(OLEConstants.GL_BAL_TYP_CD).toString()); 080 entry.setFinancialObjectTypeCode(poDataMap.get(OLEConstants.GL_OBJ_TYP_CD).toString()); 081 entry.setUniversityFiscalPeriodCode(poDataMap.get(OLEConstants.GL_UNIV_FISC_PERIOD_CD).toString()); 082 entry.setFinancialDocumentTypeCode(poDataMap.get(OLEConstants.GL_FIN_DOC_TYP_CD).toString()); 083 entry.setFinancialSystemOriginationCode(poDataMap.get(OLEConstants.GL_FIN_SYS_ORG_CD).toString()); 084 entry.setDocumentNumber(poDataMap.get(OLEConstants.GL_DOC_NBR).toString()); 085 entry.setTransactionLedgerEntrySequenceNumber(Integer.parseInt(poDataMap.get(OLEConstants.TRANS_LED_SEQ_NO).toString())); 086 entry.setTransactionLedgerEntryDescription(poDataMap.get(OLEConstants.GL_TRANS_LED_ENTRY_DESC).toString()); 087 entry.setProjectCode(poDataMap.get(OLEConstants.PROJECT_CODE).toString()); 088 entry.setReferenceFinancialDocumentTypeCode(poDataMap.get(OLEConstants.REF_DOC_TYP_CD).toString()); 089 entry.setReferenceFinancialSystemOriginationCode(poDataMap.get(OLEConstants.REF_ORG_CD).toString()); 090 entry.setTransactionEncumbranceUpdateCode(OLEConstants.ENCUM_UPDT_CD); 091 entry.setReferenceFinancialDocumentNumber(poDataMap.get(OLEConstants.FDOC_REF_NBR).toString()); 092 KualiDecimal transactionLedgerEntryAmount = new KualiDecimal((BigDecimal) poDataMap.get(OLEConstants.GL_TRANS_LED_ENTRY_AMT)); 093 if (paramaterValue.contains("+")) { 094 String amount = paramaterValue.replaceAll("[^0-9]", ""); 095 KualiDecimalAdapter kualiDecimalAdapter = new KualiDecimalAdapter(); 096 KualiDecimal dollar = kualiDecimalAdapter.unmarshal(amount); 097 if (paramaterValue.contains("$")) { 098 transactionLedgerEntryAmount = transactionLedgerEntryAmount.add(dollar); 099 } 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(invoiceDataMap.get(OLEConstants.GL_UNIV_FISC_PERIOD_CD).toString()); 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