1 package com.instantbank.collections.ach;
2
3 import java.sql.PreparedStatement;
4 import java.sql.ResultSet;
5 import java.sql.SQLException;
6 import java.util.List;
7 import javax.naming.NamingException;
8 import java.io.Serializable;
9
10 public class AchPmtDO
11 implements DataObject, Serializable {
12
13 private static final String SEQUENCE_NAME = "ACH_PAYMENTS_SEQ";
14
15 private AchPmt achPmt = null;
16 private long id = -1;
17 private long cmpId = -1;
18 private long agreementId = -1;
19 private long lastChangedBy = -1;
20 private String lastChangedDate = null;
21
22
23 public AchPmtDO() {
24 super();
25 }
26
27
28 public AchPmtDO(long primaryKey) {
29 setId(primaryKey);
30 }
31
32
33 public AchPmtDO(AchPmt theAchPmt, long theId, long theCmpId,
34 long theAgreementId, long theLastChangedBy,
35 String theLastChangedDate) {
36
37 setAchPmt(theAchPmt);
38 setId(theId);
39 setCmpId(theCmpId);
40 setAgreementId(theAgreementId);
41 setLastChangedBy(theLastChangedBy);
42 setLastChangedDate(theLastChangedDate);
43 }
44
45
46 public AchPmt getAchPmt() {
47 return achPmt;
48 }
49
50
51 public long getId() {
52 return id;
53 }
54
55
56 public long getCmpId() {
57 return cmpId;
58 }
59
60
61 public long getAgreementId() {
62 return agreementId;
63 }
64
65
66 public long getLastChangedBy() {
67 return lastChangedBy;
68 }
69
70
71 public String getLastChangedDate() {
72 return lastChangedDate;
73 }
74
75
76 public String getFindByPrimaryKeySQL() {
77 return FIND_BY_PK;
78 }
79
80
81 public String getSequenceObjectName() {
82 return SEQUENCE_NAME;
83 }
84
85
86 public String getCreateSQL() {
87 return CREATE_SQL;
88 }
89
90
91 public String getUpdateSQL() {
92 return UPDATE_SQL;
93 }
94
95
96 public String getRemoveSQL() {
97 return REMOVE_SQL;
98 }
99
100
101 public void setAchPmt(AchPmt arg) {
102 achPmt = arg;
103 }
104
105
106 public void setId(long l) {
107 id = l;
108 }
109
110
111 public void setCmpId(long l) {
112 cmpId = l;
113 }
114
115
116 public void setAgreementId(long l) {
117 agreementId = l;
118 }
119
120
121 public void setLastChangedBy(long l) {
122 lastChangedBy = l;
123 }
124
125
126 public void setLastChangedDate(String s) {
127 lastChangedDate = s;
128 }
129
130
131
139 public static List getPrimaryKeys(long agreementId) throws SQLException, NamingException {
140 return AchDAO.getPrimaryKeys(
141 "select ACHP_ID from ACH_PAYMENTS where ACHP_AGRM_ID="
142 + agreementId);
143 }
144
145
146 private static final String FIND_BY_PK =
147 "SELECT ACHP_CMP_ID, ACHP_AGRM_ID, ACHP_PAYMENT_AMT, ACHP_FEE_AMT, " +
148 "ACHP_ABA_NUMBER, ACHP_ACCT_NUMBER, ACHP_STATUS, " +
149 "ACHP_NAME_ON_ACCOUNT, ACHP_TYPE_OF_ACCOUNT, " +
150 "ACHP_LAST_CHANGED_BY, ACHP_LAST_CHANGED_DATE " +
151 "FROM ACH_PAYMENTS " +
152 "WHERE ACHP_ID = ?";
153
154
155 public void populate(ResultSet rs) throws SQLException {
156 if(rs == null) {
157 return;
158 }
159 setAchPmt(new AchPmt(rs.getBigDecimal(3), rs.getBigDecimal(4),
160 rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8), rs.getString(9)));
161 setCmpId(rs.getLong(1));
162 setAgreementId(rs.getLong(2));
163 setLastChangedBy(rs.getLong(10));
164 setLastChangedDate(rs.getString(11));
165 }
166
167
168
169 private static final String CREATE_SQL =
170 "insert into ACH_PAYMENTS " +
171 "(ACHP_ID, ACHP_CMP_ID, ACHP_AGRM_ID, ACHP_PAYMENT_AMT, ACHP_FEE_AMT, " +
172 "ACHP_ABA_NUMBER, ACHP_ACCT_NUMBER, ACHP_STATUS, ACHP_NAME_ON_ACCOUNT, ACHP_TYPE_OF_ACCOUNT, ACHP_LAST_CHANGED_BY, " +
173 "ACHP_LAST_CHANGED_DATE) " +
174 "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)";
175
176
177 public void prepareCreateStatement(PreparedStatement ps) throws SQLException {
178 if(ps == null) {
179 return;
180 }
181 ps.setLong(1, this.getId());
182 ps.setLong(2, this.getCmpId());
183 ps.setLong(3, this.getAgreementId());
184 ps.setBigDecimal(4, this.getAchPmt().getPmtAmt());
185 ps.setBigDecimal(5, this.getAchPmt().getFeeAmt());
186 ps.setString(6, this.getAchPmt().getAbaNumber());
187 ps.setString(7, this.getAchPmt().getAcctNumber());
188 ps.setString(8, this.getAchPmt().getPmtStatus());
189 ps.setString(9, this.getAchPmt().getNameOnAcct());
190 ps.setString(10, this.getAchPmt().getTypeOfAcct());
191 ps.setLong(11, this.getLastChangedBy());
192 }
193
194
195
196 private static final String UPDATE_SQL =
197 "update ACH_PAYMENTS " +
198 "set ACHP_CMP_ID= ?, ACHP_AGRM_ID= ?, ACHP_PAYMENT_AMT= ?, ACHP_FEE_AMT= ?, " +
199 "ACHP_ABA_NUMBER= ?, ACHP_ACCT_NUMBER= ?, ACHP_STATUS= ?, ACHP_NAME_ON_ACCOUNT= ?, " +
200 "ACHP_TYPE_OF_ACCOUNT, ACHP_LAST_CHANGED_BY= ? ," +
201 "ACHP_LAST_CHANGED_DATE= sysdate " +
202 "where ACHP_ID= ? ";
203
204
205 public void prepareUpdateStatement(PreparedStatement ps) throws SQLException {
206 if(ps == null) {
207 return;
208 }
209 ps.setLong(1, this.getCmpId());
210 ps.setLong(2, this.getAgreementId());
211 ps.setBigDecimal(3, this.getAchPmt().getPmtAmt());
212 ps.setBigDecimal(4, this.getAchPmt().getFeeAmt());
213 ps.setString(5, this.getAchPmt().getAbaNumber());
214 ps.setString(6, this.getAchPmt().getAcctNumber());
215 ps.setString(7, this.getAchPmt().getPmtStatus());
216 ps.setString(8, this.getAchPmt().getNameOnAcct());
217 ps.setString(9, this.getAchPmt().getTypeOfAcct());
218 ps.setLong(10, this.getLastChangedBy());
219 ps.setLong(11, this.getId());
220 }
221
222
223 private static final String REMOVE_SQL =
224 "delete from ACH_PAYMENTS " +
225 "where ACHP_ID= ? ";
226
227
228 public void prepareRemoveStatement(PreparedStatement ps) throws SQLException {
229 if(ps == null) {
230 return;
231 }
232 ps.setLong(1, this.getId());
233 }
234
235
236 public String toString() {
237 return "[" + id + '|' + achPmt == null ? "" : achPmt.toString() + '|' + cmpId + '|' + agreementId
238 + '|' + lastChangedBy + '|' + lastChangedDate + "]";
239 }
240 }
241