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