1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.pdp.service.impl;
17
18 import java.io.BufferedReader;
19 import java.io.FileNotFoundException;
20 import java.io.FileReader;
21 import java.io.IOException;
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.kuali.ole.pdp.PdpPropertyConstants;
27 import org.kuali.ole.pdp.businessobject.ACHBank;
28 import org.kuali.ole.pdp.service.AchBankService;
29 import org.kuali.rice.krad.service.BusinessObjectService;
30 import org.springframework.transaction.annotation.Transactional;
31
32 @Transactional
33 public class AchBankServiceImpl implements AchBankService {
34 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AchBankServiceImpl.class);
35
36 private BusinessObjectService businessObjectService;
37
38
39
40
41 public ACHBank getByPrimaryId(String bankRoutingNumber) {
42 Map<String, String> fieldKeys = new HashMap<String, String>();
43 fieldKeys.put(PdpPropertyConstants.BANK_ROUTING_NUMBER, bankRoutingNumber);
44
45 return (ACHBank) businessObjectService.findByPrimaryKey(ACHBank.class, fieldKeys);
46 }
47
48
49
50
51 public boolean reloadTable(String filename) {
52 LOG.debug("reloadTable() started");
53
54
55 businessObjectService.deleteMatching(ACHBank.class, new HashMap());
56
57 BufferedReader inputStream = null;
58 try {
59 inputStream = new BufferedReader(new FileReader(filename));
60
61 String str = null;
62 while ((str = inputStream.readLine()) != null) {
63 if (StringUtils.isNotBlank(str)) {
64 ACHBank ab = new ACHBank(str);
65 this.businessObjectService.save(ab);
66 }
67 }
68 }
69 catch (FileNotFoundException fnfe) {
70 LOG.error("reloadTable() File Not Found: " + filename, fnfe);
71 return false;
72 }
73 catch (IOException ie) {
74 LOG.error("reloadTable() Problem reading file: " + filename, ie);
75 return false;
76 }
77 finally {
78 if (inputStream != null) {
79 try {
80 inputStream.close();
81 }
82 catch (IOException ie) {
83
84 }
85 }
86 }
87
88 return true;
89 }
90
91
92
93
94
95
96 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
97 this.businessObjectService = businessObjectService;
98 }
99
100 }