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 9, 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:
033: /**
034: * @author delyea
035: * @hibernate.class table="PDP.PDP_ACH_ACCT_NBR_T"
036: */
037:
038: public class AchAccountNumber implements Serializable,
039: PersistenceBrokerAware {
040:
041: private Integer id; // PMT_GRP_ID Primary Key
042: private String achBankAccountNbr; // ACH_BNK_ACCT_NBR
043: private Integer version; // VER_NBR
044: private Timestamp lastUpdate;
045:
046: public AchAccountNumber() {
047: super ();
048: }
049:
050: /**
051: * returns a partial string of the account number if the account number is zero chars it returns empty string if the account
052: * number is 1-4 chars it returns everything masked if the account number is 5-8 chars it returns the last 2 numbers non masked
053: * if the account number is > 8 chars it returns the last 4 numbers non masked
054: *
055: * @return
056: * @hibernate.property column="ACH_BNK_ACCT_NBR" length="17"
057: */
058: public String getPartialMaskAchBankAccountNbr() {
059: String partialAccountNumber = "";
060: String numbers = "";
061: int accountLength = achBankAccountNbr.length();
062: if (accountLength == 0) {
063: return "";
064: } else if ((accountLength == 3) || (accountLength == 4)) {
065: numbers = achBankAccountNbr.substring(accountLength - 1);
066: } else if ((accountLength < 8) && (accountLength > 4)) {
067: numbers = achBankAccountNbr.substring(accountLength - 3);
068: } else if (accountLength >= 8) {
069: numbers = achBankAccountNbr.substring(accountLength - 4);
070: }
071: for (int i = 0; i < (accountLength - numbers.length()); i++) {
072: partialAccountNumber = partialAccountNumber + "*";
073: }
074: return partialAccountNumber + numbers;
075: }
076:
077: /**
078: * @return
079: * @hibernate.property column="ACH_BNK_ACCT_NBR" length="17"
080: */
081: public String getAchBankAccountNbr() {
082: return achBankAccountNbr;
083: }
084:
085: /**
086: * @return
087: * @hibernate.id column="PMT_GRP_ID" generator-class="assigned"
088: */
089: public Integer getId() {
090: return id;
091: }
092:
093: /**
094: * @return
095: * @hibernate.version column="VER_NBR" not-null="true"
096: */
097: public Integer getVersion() {
098: return version;
099: }
100:
101: /**
102: * @param integer
103: */
104: public void setAchBankAccountNbr(String s) {
105: achBankAccountNbr = s;
106: }
107:
108: /**
109: * @param integer
110: */
111: public void setId(Integer integer) {
112: id = integer;
113: }
114:
115: /**
116: * @param integer
117: */
118: public void setVersion(Integer integer) {
119: version = integer;
120: }
121:
122: public boolean equals(Object obj) {
123: if (!(obj instanceof AchAccountNumber)) {
124: return false;
125: }
126: AchAccountNumber o = (AchAccountNumber) obj;
127: return new EqualsBuilder().append(id, o.getId()).isEquals();
128: }
129:
130: public int hashCode() {
131: return new HashCodeBuilder(67, 79).append(id).toHashCode();
132: }
133:
134: public String toString() {
135: return new ToStringBuilder(this ).append("id", this .id)
136: .toString();
137: }
138:
139: /**
140: * @return Returns the lastUpdate.
141: */
142: public Timestamp getLastUpdate() {
143: return lastUpdate;
144: }
145:
146: /**
147: * @param lastUpdate The lastUpdate to set.
148: */
149: public void setLastUpdate(Timestamp lastUpdate) {
150: this .lastUpdate = lastUpdate;
151: }
152:
153: public void beforeInsert(PersistenceBroker broker)
154: throws PersistenceBrokerException {
155: lastUpdate = new Timestamp((new Date()).getTime());
156: }
157:
158: public void afterInsert(PersistenceBroker broker)
159: throws PersistenceBrokerException {
160:
161: }
162:
163: public void beforeUpdate(PersistenceBroker broker)
164: throws PersistenceBrokerException {
165: lastUpdate = new Timestamp((new Date()).getTime());
166: }
167:
168: public void afterUpdate(PersistenceBroker broker)
169: throws PersistenceBrokerException {
170:
171: }
172:
173: public void beforeDelete(PersistenceBroker broker)
174: throws PersistenceBrokerException {
175:
176: }
177:
178: public void afterDelete(PersistenceBroker broker)
179: throws PersistenceBrokerException {
180:
181: }
182:
183: public void afterLookup(PersistenceBroker broker)
184: throws PersistenceBrokerException {
185:
186: }
187: }
|