001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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: /*
017: * Created on Jul 7, 2004
018: *
019: */
020: package org.kuali.module.pdp.bo;
021:
022: import java.io.Serializable;
023: import java.sql.Timestamp;
024: import java.util.Date;
025:
026: import org.apache.commons.lang.builder.EqualsBuilder;
027: import org.apache.commons.lang.builder.HashCodeBuilder;
028: import org.apache.commons.lang.builder.ToStringBuilder;
029: import org.apache.ojb.broker.PersistenceBroker;
030: import org.apache.ojb.broker.PersistenceBrokerAware;
031: import org.apache.ojb.broker.PersistenceBrokerException;
032: import org.kuali.core.bo.user.UniversalUser;
033: import org.kuali.core.exceptions.UserNotFoundException;
034: import org.kuali.core.service.UniversalUserService;
035:
036: /**
037: * @author jsissom
038: * @hibernate.class table="PDP.PDP_CUST_BNK_T"
039: */
040: public class CustomerBank implements UserRequired, Serializable,
041: PersistenceBrokerAware {
042: private Integer id; // CUST_BNK_ID
043: private Integer version;
044:
045: private Integer customerId;
046: private CustomerProfile customerProfile; // CUST_ID
047:
048: private Integer bankId;
049: private Bank bank; // BNK_ID
050:
051: private String disbursementTypeCode;
052: private DisbursementType disbursementType; // DISB_TYP_CD
053:
054: private Timestamp lastUpdate; // LST_UPDT_TS
055: private PdpUser lastUpdateUser;
056: private String lastUpdateUserId; // LST_UPDT_USR_ID
057:
058: /**
059: *
060: */
061: public CustomerBank() {
062: super ();
063: }
064:
065: public PdpUser getLastUpdateUser() {
066: return lastUpdateUser;
067: }
068:
069: public void setLastUpdateUser(PdpUser s) {
070: if (s != null) {
071: this .lastUpdateUserId = s.getUniversalUser()
072: .getPersonUniversalIdentifier();
073: } else {
074: this .lastUpdateUserId = null;
075: }
076: this .lastUpdateUser = s;
077: }
078:
079: public String getLastUpdateUserId() {
080: return lastUpdateUserId;
081: }
082:
083: public void setLastUpdateUserId(String lastUpdateUserId) {
084: this .lastUpdateUserId = lastUpdateUserId;
085: }
086:
087: public void updateUser(UniversalUserService userService)
088: throws UserNotFoundException {
089: UniversalUser u = userService
090: .getUniversalUser(lastUpdateUserId);
091: if (u == null) {
092: setLastUpdateUser(null);
093: } else {
094: setLastUpdateUser(new PdpUser(u));
095: }
096: }
097:
098: /**
099: * @hibernate.many-to-one column="CUST_ID" class="edu.iu.uis.pdp.bo.CustomerProfile" not-null="true"
100: * @return Returns the customerId.
101: */
102: public CustomerProfile getCustomerProfile() {
103: return customerProfile;
104: }
105:
106: /**
107: * @param customerId The customerId to set.
108: */
109: public void setCustomerProfile(CustomerProfile customer) {
110: this .customerProfile = customer;
111: }
112:
113: /**
114: * @hibernate.many-to-one column="BNK_ID" class="edu.iu.uis.pdp.bo.Bank" not-null="true"
115: * @return Returns the bankId.
116: */
117: public Bank getBank() {
118: return bank;
119: }
120:
121: /**
122: * @param bankId The bankId to set.
123: */
124: public void setBank(Bank bank) {
125: this .bank = bank;
126: }
127:
128: /**
129: * @hibernate.many-to-one column="DISB_TYP_CD" class="edu.iu.uis.pdp.bo.DisbursementType" not-null="true"
130: * @return Returns the disbursementType.
131: */
132: public DisbursementType getDisbursementType() {
133: return disbursementType;
134: }
135:
136: /**
137: * @param disbursementType The disbursementType to set.
138: */
139: public void setDisbursementType(DisbursementType disbursementType) {
140: this .disbursementType = disbursementType;
141: }
142:
143: /**
144: * @hibernate.id column="CUST_BNK_ID" generator-class="sequence"
145: * @hibernate.generator-param name="sequence" value="PDP.PDP_CUST_BNK_ID_SEQ"
146: * @return Returns the id.
147: */
148: public Integer getId() {
149: return id;
150: }
151:
152: /**
153: * @param id The id to set.
154: */
155: public void setId(Integer id) {
156: this .id = id;
157: }
158:
159: /**
160: * @hibernate.version column="VER_NBR"
161: * @return Returns the version.
162: */
163: public Integer getVersion() {
164: return version;
165: }
166:
167: /**
168: * @param ojbVerNbr The ojbVerNbr to set.
169: */
170: public void setVersion(Integer ver) {
171: this .version = ver;
172: }
173:
174: /**
175: * @hibernate.property column="LST_UPDT_TS" not-null="true"
176: * @return Returns the lastUpdate.
177: */
178: public Timestamp getLastUpdate() {
179: return lastUpdate;
180: }
181:
182: /**
183: * @param timestamp
184: */
185: public void setLastUpdate(Timestamp timestamp) {
186: lastUpdate = timestamp;
187: }
188:
189: public boolean equals(Object obj) {
190: if (!(obj instanceof CustomerBank)) {
191: return false;
192: }
193: CustomerBank o = (CustomerBank) obj;
194: return new EqualsBuilder().append(id, o.getId()).isEquals();
195: }
196:
197: public int hashCode() {
198: return new HashCodeBuilder(83, 37).append(id).toHashCode();
199: }
200:
201: public String toString() {
202: return new ToStringBuilder(this ).append("id", this .id)
203: .toString();
204: }
205:
206: public void beforeInsert(PersistenceBroker broker)
207: throws PersistenceBrokerException {
208: lastUpdate = new Timestamp((new Date()).getTime());
209: }
210:
211: public void afterInsert(PersistenceBroker broker)
212: throws PersistenceBrokerException {
213:
214: }
215:
216: public void beforeUpdate(PersistenceBroker broker)
217: throws PersistenceBrokerException {
218: lastUpdate = new Timestamp((new Date()).getTime());
219: }
220:
221: public void afterUpdate(PersistenceBroker broker)
222: throws PersistenceBrokerException {
223:
224: }
225:
226: public void beforeDelete(PersistenceBroker broker)
227: throws PersistenceBrokerException {
228:
229: }
230:
231: public void afterDelete(PersistenceBroker broker)
232: throws PersistenceBrokerException {
233:
234: }
235:
236: public void afterLookup(PersistenceBroker broker)
237: throws PersistenceBrokerException {
238:
239: }
240: }
|