001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.module.ld.service.impl; 017 018 import java.io.BufferedReader; 019 import java.io.File; 020 import java.io.FileNotFoundException; 021 import java.io.FileReader; 022 import java.io.IOException; 023 import java.util.ArrayList; 024 import java.util.Collection; 025 import java.util.HashMap; 026 import java.util.Iterator; 027 import java.util.List; 028 import java.util.Map; 029 030 import org.kuali.kfs.gl.GeneralLedgerConstants; 031 import org.kuali.kfs.gl.businessobject.OriginEntryStatistics; 032 import org.kuali.kfs.gl.service.OriginEntryGroupService; 033 import org.kuali.kfs.gl.service.impl.OriginEntryServiceImpl; 034 import org.kuali.kfs.module.ld.businessobject.LaborOriginEntry; 035 import org.kuali.kfs.module.ld.service.LaborOriginEntryService; 036 import org.kuali.kfs.module.ld.util.LaborOriginEntryFileIterator; 037 import org.kuali.kfs.sys.KFSConstants; 038 import org.kuali.kfs.sys.Message; 039 import org.kuali.rice.kns.service.DateTimeService; 040 import org.kuali.rice.kns.util.KualiDecimal; 041 import org.springframework.transaction.annotation.Transactional; 042 043 /** 044 * Service implementation of LaborOriginEntryService. 045 */ 046 @Transactional 047 public class LaborOriginEntryServiceImpl implements LaborOriginEntryService { 048 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OriginEntryServiceImpl.class); 049 050 private OriginEntryGroupService originEntryGroupService; 051 private DateTimeService dateTimeService; 052 053 private String batchFileDirectoryName; 054 055 public OriginEntryStatistics getStatistics(String fileName) { 056 LOG.debug("getStatistics() started"); 057 OriginEntryStatistics oes = new OriginEntryStatistics(); 058 KualiDecimal totalCredit = KualiDecimal.ZERO; 059 KualiDecimal totalDebit = KualiDecimal.ZERO; 060 Integer rowCount = 0; 061 FileReader INPUT_FILE = null; 062 BufferedReader INPUT_FILE_br; 063 try { 064 INPUT_FILE = new FileReader(fileName); 065 } 066 catch (FileNotFoundException e) { 067 throw new RuntimeException(e); 068 } 069 Collection<LaborOriginEntry> entryCollection = new ArrayList(); 070 INPUT_FILE_br = new BufferedReader(INPUT_FILE); 071 072 try { 073 String currentLine = INPUT_FILE_br.readLine(); 074 while (currentLine != null) { 075 KualiDecimal amount = KualiDecimal.ZERO; 076 if (!currentLine.substring(109, 126).trim().equals(GeneralLedgerConstants.EMPTY_CODE)) { 077 try { 078 amount = new KualiDecimal(currentLine.substring(109, 126).trim()); 079 080 // TODO:- Check with FIS (Row count should be all rows?) 081 rowCount++; 082 } 083 catch (NumberFormatException e) { 084 } 085 } 086 else { 087 amount = KualiDecimal.ZERO; 088 } 089 String debitOrCreditCode = currentLine.substring(126, 127); 090 091 if (debitOrCreditCode.equals(KFSConstants.GL_CREDIT_CODE)) { 092 totalCredit.add(amount); 093 } 094 else if (debitOrCreditCode.equals(KFSConstants.GL_DEBIT_CODE)) { 095 totalDebit.add(amount); 096 } 097 currentLine = INPUT_FILE_br.readLine(); 098 } 099 INPUT_FILE_br.close(); 100 } 101 catch (IOException e) { 102 // FIXME: do whatever should be done here 103 throw new RuntimeException(e); 104 } 105 106 oes.setCreditTotalAmount(totalCredit); 107 oes.setDebitTotalAmount(totalDebit); 108 oes.setRowCount(rowCount); 109 110 return oes; 111 112 } 113 114 /** 115 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#copyEntries(java.sql.Date, java.lang.String, boolean, boolean, 116 * boolean, java.util.Iterator) 117 */ 118 // public OriginEntryGroup copyEntries(Date date, String sourceCode, boolean valid, boolean process, boolean scrub, Iterator<LaborOriginEntry> entries) { 119 // LOG.debug("copyEntries() started"); 120 // 121 // OriginEntryGroup newOriginEntryGroup = originEntryGroupService.createGroup(date, sourceCode, valid, process, scrub); 122 // 123 // // Create new Entries with newOriginEntryGroup 124 // while (entries.hasNext()) { 125 // LaborOriginEntry oe = entries.next(); 126 // oe.setEntryGroupId(newOriginEntryGroup.getId()); 127 // createEntry(oe, newOriginEntryGroup); 128 // } 129 // 130 // return newOriginEntryGroup; 131 // } 132 133 /** 134 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#delete(org.kuali.kfs.module.ld.businessobject.LaborOriginEntry) 135 */ 136 // public void delete(LaborOriginEntry loe) { 137 // LOG.debug("deleteEntry() started"); 138 // 139 // originEntryDao.deleteEntry(loe); 140 // } 141 142 /** 143 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getDocumentsByGroup(org.kuali.module.gl.bo.originentrygroup) 144 */ 145 // public Collection<LaborOriginEntry> getDocumentsByGroup(OriginEntryGroup oeg) { 146 // LOG.debug("getDocumentsByGroup() started"); 147 // 148 // Collection<LaborOriginEntry> results = new ArrayList<LaborOriginEntry>(); 149 // Iterator i = originEntryDao.getDocumentsByGroup(oeg); 150 // while (i.hasNext()) { 151 // Object[] data = (Object[]) i.next(); 152 // LaborOriginEntry oe = new LaborOriginEntry(); 153 // oe.setDocumentNumber((String) data[0]); 154 // oe.setFinancialDocumentTypeCode((String) data[1]); 155 // oe.setFinancialSystemOriginationCode((String) data[2]); 156 // results.add(oe); 157 // } 158 // 159 // return results; 160 // } 161 162 /** 163 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getBadBalanceEntries(org.kuali.module.gl.bo.originentrygroup) 164 */ 165 // public Iterator<LaborOriginEntry> getBadBalanceEntries(Collection groups) { 166 // LOG.debug("getBadBalanceEntries() started"); 167 // Iterator returnVal = laborOriginEntryDao.getBadBalanceEntries(groups); 168 // 169 // return returnVal; 170 // } 171 172 /** 173 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getEntriesByGroupAccountOrder(org.kuali.module.gl.bo.originentrygroup) 174 */ 175 // public Iterator<LaborOriginEntry> getEntriesByGroupAccountOrder(OriginEntryGroup oeg) { 176 // LOG.debug("getEntriesByGroupAccountOrder() started"); 177 // Iterator returnVal = laborOriginEntryDao.getEntriesByGroup(oeg, OriginEntryDao.SORT_ACCOUNT); 178 // 179 // return returnVal; 180 // } 181 182 /** 183 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getEntriesByGroupReportOrder(org.kuali.module.gl.bo.originentrygroup) 184 */ 185 // public Iterator<LaborOriginEntry> getEntriesByGroupReportOrder(OriginEntryGroup oeg) { 186 // LOG.debug("getEntriesByGroupAccountOrder() started"); 187 // Iterator returnVal = laborOriginEntryDao.getEntriesByGroup(oeg, OriginEntryDao.SORT_REPORT); 188 // 189 // return returnVal; 190 // } 191 192 /** 193 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getEntriesByGroupListingReportOrder(org.kuali.module.gl.bo.originentrygroup) 194 */ 195 // public Iterator<LaborOriginEntry> getEntriesByGroupListingReportOrder(OriginEntryGroup oeg) { 196 // LOG.debug("getEntriesByGroupAccountOrder() started"); 197 // 198 // Iterator returnVal = laborOriginEntryDao.getEntriesByGroup(oeg, OriginEntryDao.SORT_LISTING_REPORT); 199 // return returnVal; 200 // } 201 202 /** 203 * @see org.kuali.module.labor.service.LaborLaborOriginEntryService#getEntriesByDocument(org.kuali.module.labor.bo.LaborOriginEntryGroup, 204 * java.lang.String, java.lang.String, java.lang.String) 205 */ 206 // public Collection<LaborOriginEntry> getEntriesByDocument(OriginEntryGroup originEntryGroup, String documentNumber, String documentTypeCode, String originCode) { 207 // LOG.debug("getEntriesByGroup() started"); 208 // 209 // Map criteria = new HashMap(); 210 // criteria.put(KFSPropertyConstants.ENTRY_GROUP_ID, originEntryGroup.getId()); 211 // criteria.put(KFSPropertyConstants.DOCUMENT_NUMBER, documentNumber); 212 // criteria.put(KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, documentTypeCode); 213 // criteria.put(KFSPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE, originCode); 214 // 215 // return laborOriginEntryDao.getMatchingEntriesByCollection(criteria); 216 // } 217 218 /** 219 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#createEntry(org.kuali.module.labor.bo.Transaction, 220 * org.kuali.module.gl.bo.originentrygroup) 221 */ 222 // public void createEntry(LaborTransaction laborTransaction, OriginEntryGroup originEntryGroup) { 223 // LOG.debug("createEntry() started"); 224 // 225 // LaborOriginEntry e = new LaborOriginEntry(laborTransaction); 226 // e.setGroup(originEntryGroup); 227 // 228 // laborOriginEntryDao.saveOriginEntry(e); 229 // } 230 231 /** 232 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#save(org.kuali.kfs.module.ld.businessobject.LaborOriginEntry) 233 */ 234 // public void save(LaborOriginEntry entry) { 235 // LOG.debug("save() started"); 236 // 237 // laborOriginEntryDao.saveOriginEntry(entry); 238 // } 239 240 /** 241 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#exportFlatFile(java.lang.String, java.lang.Integer) 242 */ 243 // public void exportFlatFile(String filename, Integer groupId) { 244 // LOG.debug("exportFlatFile() started"); 245 // 246 // BufferedWriter out = null; 247 // try { 248 // out = new BufferedWriter(new FileWriter(filename)); 249 // 250 // OriginEntryGroup oeg = new OriginEntryGroup(); 251 // oeg.setId(groupId); 252 // Iterator i = getEntriesByGroup(oeg); 253 // while (i.hasNext()) { 254 // LaborOriginEntry e = (LaborOriginEntry) i.next(); 255 // out.write(e.getLine() + "\n"); 256 // } 257 // } 258 // catch (IOException e) { 259 // LOG.error("exportFlatFile() Error writing to file", e); 260 // } 261 // finally { 262 // if (out != null) { 263 // try { 264 // out.close(); 265 // } 266 // catch (IOException ie) { 267 // LOG.error("exportFlatFile() Error closing file", ie); 268 // } 269 // } 270 // } 271 // } 272 273 /** 274 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#loadFlatFile(java.lang.String, java.lang.String, boolean, 275 * boolean, boolean) 276 */ 277 // public void loadFlatFile(String filename, String groupSourceCode, boolean isValid, boolean isProcessed, boolean isScrub) { 278 // LOG.debug("loadFlatFile() started"); 279 // 280 // java.sql.Date groupDate = new java.sql.Date(dateTimeService.getCurrentDate().getTime()); 281 // OriginEntryGroup newGroup = originEntryGroupService.createGroup(groupDate, groupSourceCode, isValid, isProcessed, isScrub); 282 // 283 // BufferedReader input = null; 284 // try { 285 // input = new BufferedReader(new FileReader(filename)); 286 // String line = null; 287 // while ((line = input.readLine()) != null) { 288 // LaborOriginEntry entry = new LaborOriginEntry(line); 289 // createEntry(entry, newGroup); 290 // } 291 // } 292 // catch (Exception ex) { 293 // LOG.error("performStep() Error reading file", ex); 294 // throw new IllegalArgumentException("Error reading file"); 295 // } 296 // finally { 297 // try { 298 // if (input != null) { 299 // input.close(); 300 // } 301 // } 302 // catch (IOException ex) { 303 // LOG.error("loadFlatFile() error closing file.", ex); 304 // } 305 // } 306 // } 307 308 /** 309 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getMatchingEntriesByList(java.util.Map) 310 */ 311 // public List<LaborOriginEntry> getEntriesByGroupId(Integer groupId) { 312 // if (groupId == null) { 313 // throw new IllegalArgumentException("Group ID is null"); 314 // } 315 // Map<String, Object> searchCriteria = new HashMap<String, Object>(); 316 // searchCriteria.put("entryGroupId", groupId); 317 // Collection<LaborOriginEntry> searchResultAsCollection = getMatchingEntriesByCollection(searchCriteria); 318 // if (searchResultAsCollection instanceof List) { 319 // return (List<LaborOriginEntry>) searchResultAsCollection; 320 // } 321 // else { 322 // return new ArrayList<LaborOriginEntry>(searchResultAsCollection); 323 // } 324 // } 325 326 public Map getEntriesByGroupIdWithPath(String fileNameWithPath, List<LaborOriginEntry> originEntryList) { 327 328 FileReader INPUT_GLE_FILE = null; 329 BufferedReader INPUT_GLE_FILE_br; 330 try { 331 INPUT_GLE_FILE = new FileReader(fileNameWithPath); 332 } catch (FileNotFoundException e) { 333 throw new RuntimeException(e); 334 } 335 INPUT_GLE_FILE_br = new BufferedReader(INPUT_GLE_FILE); 336 337 boolean loadError = false; 338 //returnErrorList is list of List<Message> 339 Map returnErrorMap = getEntriesByBufferedReader(INPUT_GLE_FILE_br, originEntryList); 340 341 try{ 342 INPUT_GLE_FILE_br.close(); 343 INPUT_GLE_FILE.close(); 344 } catch (IOException e) { 345 throw new RuntimeException(e); 346 } 347 348 349 return returnErrorMap; 350 } 351 352 public Map getEntriesByBufferedReader(BufferedReader inputBufferedReader, List<LaborOriginEntry> originEntryList) { 353 String line; 354 int lineNumber = 0; 355 Map returnErrorMap = new HashMap(); 356 try { 357 List<Message> tmperrors = new ArrayList(); 358 while ((line = inputBufferedReader.readLine()) != null) { 359 lineNumber++; 360 LaborOriginEntry laborOriginEntry = new LaborOriginEntry(); 361 tmperrors = laborOriginEntry.setFromTextFileForBatch(line, lineNumber); 362 laborOriginEntry.setEntryId(lineNumber); 363 if (tmperrors.size() > 0){ 364 returnErrorMap.put(new Integer(lineNumber), tmperrors); 365 } else { 366 originEntryList.add(laborOriginEntry); 367 } 368 } 369 } catch (IOException e) { 370 throw new RuntimeException(e); 371 } 372 373 return returnErrorMap; 374 } 375 376 377 378 // public LedgerEntryHolder getSummaryByGroupId(Collection groupIdList) { 379 // LOG.debug("getSummaryByGroupId() started"); 380 // 381 // LedgerEntryHolder ledgerEntryHolder = new LedgerEntryHolder(); 382 // 383 // if (groupIdList.size() == 0) { 384 // return ledgerEntryHolder; 385 // } 386 // 387 // Iterator entrySummaryIterator = laborOriginEntryDao.getSummaryByGroupId(groupIdList); 388 // while (entrySummaryIterator.hasNext()) { 389 // Object[] entrySummary = (Object[]) entrySummaryIterator.next(); 390 // LedgerEntry ledgerEntry = LedgerEntry.buildLedgerEntry(entrySummary); 391 // ledgerEntryHolder.insertLedgerEntry(ledgerEntry, true); 392 // } 393 // return ledgerEntryHolder; 394 // } 395 396 /** 397 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#flatFile(java.lang.Integer, java.io.BufferedOutputStream) 398 */ 399 // public void flatFile(Integer groupId, BufferedOutputStream bw) { 400 // LOG.debug("flatFile() started"); 401 // 402 // try { 403 // OriginEntryGroup oeg = new OriginEntryGroup(); 404 // oeg.setId(groupId); 405 // Iterator i = getEntriesByGroup(oeg); 406 // while (i.hasNext()) { 407 // LaborOriginEntry e = (LaborOriginEntry) i.next(); 408 // bw.write((e.getLine() + "\n").getBytes()); 409 // } 410 // } 411 // catch (IOException e) { 412 // LOG.error("flatFile() Error writing to file", e); 413 // throw new RuntimeException("Error writing to file: " + e.getMessage()); 414 // } 415 // } 416 417 /** 418 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getMatchingEntriesByCollection(java.util.Map) 419 */ 420 // public Collection getMatchingEntriesByCollection(Map searchCriteria) { 421 // LOG.debug("getMatchingEntriesByCollection() started"); 422 // 423 // return laborOriginEntryDao.getMatchingEntriesByCollection(searchCriteria); 424 // } 425 426 /** 427 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getExactMatchingEntry(java.lang.Integer) 428 */ 429 // public LaborOriginEntry getExactMatchingEntry(Integer entryId) { 430 // LOG.debug("getExactMatchingEntry() started"); 431 // 432 // return (LaborOriginEntry) originEntryDao.getExactMatchingEntry(entryId); 433 // } 434 435 /** 436 * @see org.kuali.module.labor.service.LaborLaborOriginEntryService#getEntriesByGroup(org.kuali.kfs.gl.businessobject.OriginEntryGroup) 437 */ 438 // public Iterator<LaborOriginEntry> getEntriesByGroup(OriginEntryGroup group) { 439 // return laborOriginEntryDao.getLaborEntriesByGroup(group, LaborOriginEntryDao.SORT_DOCUMENT); 440 // } 441 442 /** 443 * @see org.kuali.module.labor.service.LaborLaborOriginEntryService#getEntriesByGroups(java.util.Collection) 444 */ 445 // public Iterator<LaborOriginEntry> getEntriesByGroups(Collection<OriginEntryGroup> groups) { 446 // return laborOriginEntryDao.getEntriesByGroups(groups); 447 // } 448 449 /** 450 * @see org.kuali.module.labor.service.LaborLaborOriginEntryService#getEntriesByGroup(org.kuali.kfs.gl.businessobject.OriginEntryGroup, 451 * boolean) 452 */ 453 // public Iterator<LaborOriginEntry> getEntriesByGroup(OriginEntryGroup group, boolean isConsolidated) { 454 // if (!isConsolidated) { 455 // return this.getEntriesByGroup(group); 456 // } 457 // return this.getConsolidatedEntryCollectionByGroup(group).iterator(); 458 // } 459 460 /** 461 * @see org.kuali.module.labor.service.LaborLaborOriginEntryService#getConsolidatedEntryCollectionByGroup(org.kuali.kfs.gl.businessobject.OriginEntryGroup, 462 * boolean) 463 */ 464 // public Collection<LaborOriginEntry> getConsolidatedEntryCollectionByGroup(OriginEntryGroup group) { 465 // Collection<LaborOriginEntry> entryCollection = new ArrayList<LaborOriginEntry>(); 466 // LaborLedgerUnitOfWork laborLedgerUnitOfWork = new LaborLedgerUnitOfWork(); 467 // 468 // // the following iterator has been sorted 469 // Iterator<Object[]> consolidatedEntries = laborOriginEntryDao.getConsolidatedEntriesByGroup(group); 470 // 471 // while (consolidatedEntries.hasNext()) { 472 // LaborOriginEntry laborOriginEntry = new LaborOriginEntry(); 473 // Object[] oneEntry = consolidatedEntries.next(); 474 // ObjectUtil.buildObject(laborOriginEntry, oneEntry, LaborConstants.consolidationAttributesOfOriginEntry()); 475 // 476 // if (laborLedgerUnitOfWork.canContain(laborOriginEntry)) { 477 // laborLedgerUnitOfWork.addEntryIntoUnit(laborOriginEntry); 478 // } 479 // else { 480 // laborLedgerUnitOfWork.resetLaborLedgerUnitOfWork(laborOriginEntry); 481 // entryCollection.add(laborLedgerUnitOfWork.getWorkingEntry()); 482 // } 483 // } 484 // return entryCollection; 485 // } 486 487 /** 488 * @see org.kuali.module.labor.service.LaborLaborOriginEntryService#getSummariedEntriesByGroups(java.util.Collection) 489 */ 490 // public LedgerEntryHolder getSummariedEntriesByGroups(Collection<OriginEntryGroup> groups) { 491 // LedgerEntryHolder ledgerEntryHolder = new LedgerEntryHolder(); 492 // 493 // if (groups.size() > 0) { 494 // Iterator entrySummaryIterator = laborOriginEntryDao.getSummaryByGroupId(groups); 495 // while (entrySummaryIterator.hasNext()) { 496 // Object[] entrySummary = (Object[]) entrySummaryIterator.next(); 497 // ledgerEntryHolder.insertLedgerEntry(LedgerEntry.buildLedgerEntry(entrySummary), true); 498 // } 499 // } 500 // return ledgerEntryHolder; 501 // } 502 503 /** 504 * @see org.kuali.module.labor.service.LaborLaborOriginEntryService#getPosterOutputSummaryByGroups(java.util.Collection) 505 */ 506 // public Map<String, PosterOutputSummaryEntry> getPosterOutputSummaryByGroups(Collection<OriginEntryGroup> groups) { 507 // Map<String, PosterOutputSummaryEntry> outputSummary = new HashMap<String, PosterOutputSummaryEntry>(); 508 // 509 // if (groups.size() > 0) { 510 // Iterator entrySummaryIterator = laborOriginEntryDao.getPosterOutputSummaryByGroupId(groups); 511 // while (entrySummaryIterator.hasNext()) { 512 // Object[] entrySummary = (Object[]) entrySummaryIterator.next(); 513 // PosterOutputSummaryEntry posterOutputSummaryEntry = PosterOutputSummaryEntry.buildPosterOutputSummaryEntry(entrySummary); 514 // 515 // if (outputSummary.containsKey(posterOutputSummaryEntry.getKey())) { 516 // PosterOutputSummaryEntry tempEntry = outputSummary.get(posterOutputSummaryEntry.getKey()); 517 // tempEntry.add(posterOutputSummaryEntry); 518 // } 519 // else { 520 // outputSummary.put(posterOutputSummaryEntry.getKey(), posterOutputSummaryEntry); 521 // } 522 // } 523 // } 524 // return outputSummary; 525 // } 526 527 /** 528 * @see org.kuali.module.labor.service.LaborLaborOriginEntryService#getSizeOfEntriesInGroups(java.util.Collection) 529 */ 530 // public int getCountOfEntriesInGroups(Collection<OriginEntryGroup> groups) { 531 // return laborOriginEntryDao.getCountOfEntriesInGroups(groups); 532 // } 533 534 /** 535 * @see org.kuali.module.labor.service.LaborLaborOriginEntryService#getCountOfEntriesInSingleGroup(org.kuali.kfs.gl.businessobject.OriginEntryGroup) 536 */ 537 // public int getCountOfEntriesInSingleGroup(OriginEntryGroup group) { 538 // List<OriginEntryGroup> groups = new ArrayList<OriginEntryGroup>(); 539 // groups.add(group); 540 // 541 // return this.getCountOfEntriesInGroups(groups); 542 // } 543 544 /** 545 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getEntryCollectionByGroup(org.kuali.kfs.gl.businessobject.OriginEntryGroup) 546 */ 547 // public Collection<LaborOriginEntry> getEntryCollectionByGroup(OriginEntryGroup group) { 548 // return laborOriginEntryDao.getEntryCollectionByGroup(group); 549 // } 550 551 /** 552 * Returns all labor origin entry groups created on the given date to back them up 553 * 554 * @param backupDate the date to find labor origin entry groups created on 555 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getLaborBackupGroups(java.sql.Date) 556 * @see org.kuali.kfs.module.ld.dataaccess.LaborOriginEntryDao#getLaborBackupGroups(java.sql.Date) 557 */ 558 // public Collection getLaborBackupGroups(Date backupDate) { 559 // LOG.debug("getBackupGroups() started"); 560 // 561 // return laborOriginEntryDao.getLaborBackupGroups(backupDate); 562 // } 563 564 /** 565 * @see org.kuali.kfs.module.ld.service.LaborOriginEntryService#getGroupCount(java.lang.Integer) 566 */ 567 // public Integer getGroupCount(Integer groupId) { 568 // return laborOriginEntryDao.getGroupCount(groupId); 569 // } 570 571 public Integer getGroupCount(String fileNameWithPath){ 572 File file = new File(fileNameWithPath); 573 Iterator<LaborOriginEntry> fileIterator = new LaborOriginEntryFileIterator(file); 574 int count = 0; 575 576 while(fileIterator.hasNext()){ 577 count++; 578 fileIterator.next(); 579 } 580 return count; 581 } 582 583 /** 584 * Sets the dateTimeService attribute value. 585 * 586 * @param dateTimeService The dateTimeService to set. 587 */ 588 public void setDateTimeService(DateTimeService dateTimeService) { 589 this.dateTimeService = dateTimeService; 590 } 591 592 /** 593 * Sets the originEntryGroupService attribute value. 594 * 595 * @param originEntryGroupService The originEntryGroupService to set. 596 */ 597 public void setOriginEntryGroupService(OriginEntryGroupService originEntryGroupService) { 598 this.originEntryGroupService = originEntryGroupService; 599 } 600 601 public void setBatchFileDirectoryName(String batchFileDirectoryName) { 602 this.batchFileDirectoryName = batchFileDirectoryName; 603 } 604 }