View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /*
17   * Created on Jul 7, 2004
18   *
19   */
20  package org.kuali.ole.pdp.businessobject;
21  
22  import java.io.Serializable;
23  import java.util.LinkedHashMap;
24  import javax.persistence.*;
25  
26  import org.apache.commons.lang.builder.CompareToBuilder;
27  import org.apache.commons.lang.builder.EqualsBuilder;
28  import org.apache.commons.lang.builder.HashCodeBuilder;
29  import org.apache.commons.lang.builder.ToStringBuilder;
30  import org.kuali.ole.pdp.PdpPropertyConstants;
31  import org.kuali.ole.pdp.businessobject.CustomerProfile;
32  import org.kuali.ole.pdp.businessobject.DisbursementType;
33  import org.kuali.ole.sys.OLEPropertyConstants;
34  import org.kuali.ole.sys.businessobject.Bank;
35  import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
36  import org.kuali.rice.core.api.util.type.KualiInteger;
37  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
38  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
39  
40  @Entity
41  @Table(name = "PDP_CUST_BNK_T")
42  @IdClass(CustomerBank.CustomerBankId.class)
43  public class CustomerBank extends PersistableBusinessObjectBase implements MutableInactivatable {
44  
45      @Id
46      @Column(name = "CUST_ID")
47      private KualiInteger customerId;
48  
49  
50      @Column(name = "UNIV_FISCAL_YR")
51      protected Integer universityFiscalYear;
52  
53      @Column(name = "BNK_CD")
54      private String bankCode;
55  
56      @Id
57      @Column(name = "DISB_TYP_CD")
58      private String disbursementTypeCode;
59      
60      @ManyToOne(targetEntity = CustomerProfile.class, fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
61      @JoinColumn(name = "CUST_ID", referencedColumnName = "CUST_ID", insertable = false, updatable = false)
62      private CustomerProfile customerProfile;
63  
64      @ManyToOne(targetEntity = Bank.class, fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
65      @JoinColumn(name = "BNK_CD", referencedColumnName = "BNK_CD", insertable = false, updatable = false)
66      private Bank bank;
67  
68      @ManyToOne(targetEntity = DisbursementType.class, fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
69      @JoinColumn(name = "DISB_TYP_CD", referencedColumnName = "DISB_TYP_CD", insertable = false, updatable = false)
70      private DisbursementType disbursementType;
71      
72      @Column(name = "ACTV_IND")
73      @Convert(converter = BooleanYNConverter.class)
74      private boolean active;
75  
76      public CustomerBank() {
77          super();
78      }
79  
80      /**
81       * Gets the customerId attribute.
82       * 
83       * @return Returns the customerId.
84       */
85      public KualiInteger getCustomerId() {
86          return customerId;
87      }
88  
89      /**
90       * Sets the customerId attribute value.
91       * 
92       * @param customerId The customerId to set.
93       */
94      public void setCustomerId(KualiInteger customerId) {
95          this.customerId = customerId;
96      }
97  
98      /**
99       * Gets the customerProfile attribute.
100      * 
101      * @return Returns the customerProfile.
102      */
103     public CustomerProfile getCustomerProfile() {
104         return customerProfile;
105     }
106 
107     /**
108      * Sets the customerProfile attribute value.
109      * 
110      * @param customerProfile The customerProfile to set.
111      */
112     public void setCustomerProfile(CustomerProfile customerProfile) {
113         this.customerProfile = customerProfile;
114     }
115 
116     /**
117      * Gets the bankCode attribute.
118      * 
119      * @return Returns the bankCode.
120      */
121     public String getBankCode() {
122         return bankCode;
123     }
124 
125     /**
126      * Sets the bankCode attribute value.
127      * 
128      * @param bankCode The bankCode to set.
129      */
130     public void setBankCode(String bankCode) {
131         this.bankCode = bankCode;
132     }
133 
134     /**
135      * Gets the bank attribute.
136      * 
137      * @return Returns the bank.
138      */
139     public Bank getBank() {
140         return bank;
141     }
142 
143     /**
144      * Sets the bank attribute value.
145      * 
146      * @param bank The bank to set.
147      */
148     public void setBank(Bank bank) {
149         this.bank = bank;
150     }
151 
152     /**
153      * Gets the disbursementTypeCode attribute.
154      * 
155      * @return Returns the disbursementTypeCode.
156      */
157     public String getDisbursementTypeCode() {
158         return disbursementTypeCode;
159     }
160 
161     /**
162      * Sets the disbursementTypeCode attribute value.
163      * 
164      * @param disbursementTypeCode The disbursementTypeCode to set.
165      */
166     public void setDisbursementTypeCode(String disbursementTypeCode) {
167         this.disbursementTypeCode = disbursementTypeCode;
168     }
169 
170     /**
171      * Gets the disbursementType attribute.
172      * 
173      * @return Returns the disbursementType.
174      */
175     public DisbursementType getDisbursementType() {
176         return disbursementType;
177     }
178 
179     /**
180      * Sets the disbursementType attribute value.
181      * 
182      * @param disbursementType The disbursementType to set.
183      */
184     public void setDisbursementType(DisbursementType disbursementType) {
185         this.disbursementType = disbursementType;
186     }
187 
188     /**
189      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
190      */
191 
192     protected LinkedHashMap toStringMapper() {
193         LinkedHashMap m = new LinkedHashMap();
194         m.put(PdpPropertyConstants.CUSTOMER_ID, this.customerId);
195         m.put(PdpPropertyConstants.DISBURSEMENT_TYPE_CODE, this.disbursementTypeCode);
196         m.put(OLEPropertyConstants.BANK_CODE, this.bankCode);
197 
198         return m;
199     }
200 
201     /**
202      * 
203      * @see org.kuali.rice.core.api.mo.common.active.MutableInactivatable#isActive()
204      */
205     public boolean isActive() {
206         return active;
207     }
208     
209     /**
210      * 
211      * @see org.kuali.rice.core.api.mo.common.active.MutableInactivatable#setActive(boolean)
212      */
213     public void setActive(boolean active) {
214         this.active = active;
215     }
216 
217     public static final class CustomerBankId implements Serializable, Comparable<CustomerBankId> {
218 
219         private KualiInteger customerId;
220 
221         private String disbursementTypeCode;
222 
223         public KualiInteger getCustomerId() {
224             return this.customerId;
225         }
226 
227         public void setCustomerId(KualiInteger customerId) {
228             this.customerId = customerId;
229         }
230 
231         public String getDisbursementTypeCode() {
232             return this.disbursementTypeCode;
233         }
234 
235         public void setDisbursementTypeCode(String disbursementTypeCode) {
236             this.disbursementTypeCode = disbursementTypeCode;
237         }
238 
239         @Override
240         public String toString() {
241             return new ToStringBuilder(this).append("customerId", this.customerId).append("disbursementTypeCode", this.disbursementTypeCode).toString();
242         }
243 
244         @Override
245         public boolean equals(Object other) {
246             if (other == null)
247                 return false;
248             if (other == this)
249                 return true;
250             if (other.getClass() != this.getClass())
251                 return false;
252             final CustomerBankId rhs = (CustomerBankId) other;
253             return new EqualsBuilder().append(this.customerId, rhs.customerId).append(this.disbursementTypeCode, rhs.disbursementTypeCode).isEquals();
254         }
255 
256         @Override
257         public int hashCode() {
258             return new HashCodeBuilder(17, 37).append(this.customerId).append(this.disbursementTypeCode).toHashCode();
259         }
260 
261         @Override
262         public int compareTo(CustomerBankId other) {
263             return new CompareToBuilder().append(this.customerId, other.customerId).append(this.disbursementTypeCode, other.disbursementTypeCode).toComparison();
264         }
265     }
266 
267     public Integer getUniversityFiscalYear() {
268         return universityFiscalYear;
269     }
270 
271     public void setUniversityFiscalYear(Integer universityFiscalYear) {
272         this.universityFiscalYear = universityFiscalYear;
273     }
274 }