View Javadoc
1   /*
2    * Copyright 2005-2006 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  package org.kuali.ole.coa.businessobject;
17  
18  import java.io.Serializable;
19  import java.util.LinkedHashMap;
20  import javax.persistence.CascadeType;
21  import javax.persistence.Column;
22  import javax.persistence.Convert;
23  import javax.persistence.Entity;
24  import javax.persistence.FetchType;
25  import javax.persistence.Id;
26  import javax.persistence.IdClass;
27  import javax.persistence.JoinColumn;
28  import javax.persistence.JoinColumns;
29  import javax.persistence.ManyToOne;
30  import javax.persistence.OneToOne;
31  import javax.persistence.PrimaryKeyJoinColumn;
32  import javax.persistence.PrimaryKeyJoinColumns;
33  import javax.persistence.Table;
34  import javax.persistence.Transient;
35  import org.apache.commons.lang.builder.CompareToBuilder;
36  import org.apache.commons.lang.builder.EqualsBuilder;
37  import org.apache.commons.lang.builder.HashCodeBuilder;
38  import org.apache.commons.lang.builder.ToStringBuilder;
39  import org.kuali.ole.coa.businessobject.A21SubAccount;
40  import org.kuali.ole.coa.businessobject.Account;
41  import org.kuali.ole.coa.businessobject.Chart;
42  import org.kuali.ole.coa.businessobject.Organization;
43  import org.kuali.ole.coa.businessobject.ReportingCode;
44  import org.kuali.ole.sys.OLEConstants;
45  import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
46  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
47  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
48  
49  /**
50   * 
51   */
52  @Entity
53  @Table(name = "CA_SUB_ACCT_T")
54  @IdClass(SubAccount.SubAccountId.class)
55  public class SubAccount extends PersistableBusinessObjectBase implements MutableInactivatable {
56  
57      private static final long serialVersionUID = 6853259976912014273L;
58  
59      public static final String CACHE_NAME = OLEConstants.APPLICATION_NAMESPACE_CODE + "/" + "SubAccount";
60  
61      @Id
62      @Column(name = "FIN_COA_CD")
63      private String chartOfAccountsCode;
64  
65      @Id
66      @Column(name = "ACCOUNT_NBR")
67      private String accountNumber;
68  
69      @Id
70      @Column(name = "SUB_ACCT_NBR")
71      private String subAccountNumber;
72  
73      @Column(name = "SUB_ACCT_NM")
74      private String subAccountName;
75  
76      @Column(name = "SUB_ACCT_ACTV_CD")
77      @Convert(converter = BooleanYNConverter.class)
78      private boolean active;
79  
80      @Column(name = "FIN_RPT_CHRT_CD")
81      private String financialReportChartCode;
82  
83      @Column(name = "FIN_RPT_ORG_CD")
84      private String finReportOrganizationCode;
85  
86      @Column(name = "FIN_RPT_CD")
87      private String financialReportingCode;
88  
89      /*
90  FIXME: JPA_CONVERSION
91  For one-to-one bidirectional relationships, the owning side corresponds to the side that contains the corresponding foreign key.
92  Even in the absence of a foreign key, one side must be the owning side.
93  If this is not the owning side, the required annotation should be:
94  @OneToOne(mappedBy="costShareSourceSubAccount")
95  */
96      @OneToOne(targetEntity = A21SubAccount.class, fetch = FetchType.LAZY, orphanRemoval = true, cascade = { CascadeType.REFRESH, CascadeType.REMOVE, CascadeType.PERSIST })
97      /*
98  FIXME: JPA_CONVERSION
99  For compound primary keys, make sure the join columns are in the correct order.
100 */
101     @PrimaryKeyJoinColumns({ @PrimaryKeyJoinColumn(name = "FIN_COA_CD", referencedColumnName = "FIN_COA_CD"), @PrimaryKeyJoinColumn(name = "ACCOUNT_NBR", referencedColumnName = "ACCOUNT_NBR"), @PrimaryKeyJoinColumn(name = "SUB_ACCT_NBR", referencedColumnName = "SUB_ACCT_NBR") })
102     private A21SubAccount a21SubAccount;
103 
104     @ManyToOne(targetEntity = Account.class, fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
105     /*
106 FIXME: JPA_CONVERSION
107 For compound primary keys, make sure the join columns are in the correct order.
108 */
109     @JoinColumns({ @JoinColumn(name = "FIN_COA_CD", referencedColumnName = "FIN_COA_CD", insertable = false, updatable = false), @JoinColumn(name = "ACCOUNT_NBR", referencedColumnName = "ACCOUNT_NBR", insertable = false, updatable = false) })
110     private Account account;
111 
112     @ManyToOne(targetEntity = ReportingCode.class, fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
113     /*
114 FIXME: JPA_CONVERSION
115 For compound primary keys, make sure the join columns are in the correct order.
116 */
117     @JoinColumns({ @JoinColumn(name = "FIN_RPT_CHRT_CD", referencedColumnName = "FIN_RPT_CHRT_CD", insertable = false, updatable = false), @JoinColumn(name = "FIN_RPT_ORG_CD", referencedColumnName = "FIN_RPT_ORG_CD", insertable = false, updatable = false), @JoinColumn(name = "FIN_RPT_CD", referencedColumnName = "FIN_RPT_CD", insertable = false, updatable = false) })
118     private ReportingCode reportingCode;
119 
120     @ManyToOne(targetEntity = Chart.class, fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
121     @JoinColumn(name = "FIN_COA_CD", referencedColumnName = "FIN_COA_CD", insertable = false, updatable = false)
122     private Chart chart;
123 
124     @ManyToOne(targetEntity = Organization.class, fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
125     /*
126 FIXME: JPA_CONVERSION
127 For compound primary keys, make sure the join columns are in the correct order.
128 */
129     @JoinColumns({ @JoinColumn(name = "FIN_RPT_CHRT_CD", referencedColumnName = "FIN_COA_CD", insertable = false, updatable = false), @JoinColumn(name = "FIN_RPT_ORG_CD", referencedColumnName = "ORG_CD", insertable = false, updatable = false) })
130     private Organization org;
131 
132     @ManyToOne(targetEntity = Chart.class, fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
133     @JoinColumn(name = "FIN_RPT_CHRT_CD", referencedColumnName = "FIN_COA_CD", insertable = false, updatable = false)
134     private Chart financialReportChart;
135 
136     // Several kinds of Dummy Attributes for dividing sections on Inquiry page
137     @Transient
138     private String financialReportingCodeSectionBlank;
139 
140     @Transient
141     private String financialReportingCodeSection;
142 
143     @Transient
144     private String cgCostSharingSectionBlank;
145 
146     @Transient
147     private String cgCostSharingSection;
148 
149     @Transient
150     private String cgICRSectionBlank;
151 
152     @Transient
153     private String cgICRSection;
154 
155     /**
156      * Default no-arg constructor.
157      */
158     public SubAccount() {
159     }
160 
161     /**
162      * Gets the accountNumber attribute.
163      * 
164      * @return Returns the accountNumber.
165      */
166     public String getAccountNumber() {
167         return accountNumber;
168     }
169 
170     /**
171      * Sets the accountNumber attribute value.
172      */
173     public void setAccountNumber(String accountNumber) {
174         this.accountNumber = accountNumber;
175     }
176 
177     /**
178      * Gets the chartOfAccountsCode attribute.
179      * 
180      * @return Returns the chartOfAccountsCode.
181      */
182     public String getChartOfAccountsCode() {
183         return chartOfAccountsCode;
184     }
185 
186     /**
187      * Sets the chartOfAccountsCode attribute value.
188      * 
189      * @param chartOfAccountsCode The chartOfAccountsCode to set.
190      */
191     public void setChartOfAccountsCode(String chartOfAccountsCode) {
192         this.chartOfAccountsCode = chartOfAccountsCode;
193     }
194 
195     /**
196      * Sets the financialReporting attribute value.
197      * 
198      * @param reportingCode The financialReporting to set.
199      * @deprecated
200      */
201     public void setReportingCode(ReportingCode reportingCode) {
202         this.reportingCode = reportingCode;
203     }
204 
205     /**
206      * Gets the subAccountName attribute.
207      * 
208      * @return Returns the subAccountName
209      */
210     public String getSubAccountName() {
211         return subAccountName;
212     }
213 
214     /**
215      * Sets the subAccountName attribute.
216      * 
217      * @param subAccountName The subAccountName to set.
218      */
219     public void setSubAccountName(String subAccountName) {
220         this.subAccountName = subAccountName;
221     }
222 
223     /**
224      * Gets the active attribute.
225      * 
226      * @return Returns the active
227      */
228     public boolean isActive() {
229         return active;
230     }
231 
232     /**
233      * Sets the active attribute.
234      * 
235      * @param active The active to set.
236      */
237     public void setActive(boolean active) {
238         this.active = active;
239     }
240 
241     /**
242      * Gets the account attribute.
243      * 
244      * @return Returns the account
245      */
246     public Account getAccount() {
247         return account;
248     }
249 
250     /**
251      * Sets the account attribute.
252      * 
253      * @param account The account to set.
254      */
255     public void setAccount(Account account) {
256         this.account = account;
257     }
258 
259     /**
260      * Gets the subAccount attribute.
261      * 
262      * @return Returns the subAccount
263      */
264     public String getSubAccountNumber() {
265         return subAccountNumber;
266     }
267 
268     /**
269      * Sets the subAccount attribute.
270      * 
271      * @param subAccount The subAccount to set.
272      */
273     public void setSubAccountNumber(String subAccountNumber) {
274         this.subAccountNumber = subAccountNumber;
275     }
276 
277     /**
278      * Gets the financialReporting attribute.
279      * 
280      * @return Returns the financialReporting
281      */
282     public ReportingCode getReportingCode() {
283         return reportingCode;
284     }
285 
286 
287     /**
288      * @return Returns the financialReportChartCode.
289      */
290     public String getFinancialReportChartCode() {
291         return financialReportChartCode;
292     }
293 
294     /**
295      * @param financialReportChartCode The financialReportChartCode to set.
296      */
297     public void setFinancialReportChartCode(String financialReportChartCode) {
298         this.financialReportChartCode = financialReportChartCode;
299     }
300 
301     /**
302      * @return Returns the financialReportingCode.
303      */
304     public String getFinancialReportingCode() {
305         return financialReportingCode;
306     }
307 
308     /**
309      * @param financialReportingCode The financialReportingCode to set.
310      */
311     public void setFinancialReportingCode(String financialReportingCode) {
312         this.financialReportingCode = financialReportingCode;
313     }
314 
315     /**
316      * @return Returns the finReportOrganizationCode.
317      */
318     public String getFinReportOrganizationCode() {
319         return finReportOrganizationCode;
320     }
321 
322     /**
323      * @param finReportOrganizationCode The finReportOrganizationCode to set.
324      */
325     public void setFinReportOrganizationCode(String finReportOrganizationCode) {
326         this.finReportOrganizationCode = finReportOrganizationCode;
327     }
328 
329     /**
330      * Gets the a21SubAccount attribute.
331      * 
332      * @return Returns the a21SubAccount.
333      */
334     public A21SubAccount getA21SubAccount() {
335         return a21SubAccount;
336     }
337 
338     /**
339      * Sets the a21SubAccount attribute value.
340      * 
341      * @param subAccount The a21SubAccount to set.
342      */
343     public void setA21SubAccount(A21SubAccount subAccount) {
344         a21SubAccount = subAccount;
345     }
346 
347     /**
348      * @return Returns the chart.
349      */
350     public Chart getChart() {
351         return chart;
352     }
353 
354     /**
355      * @param chart The chart to set.
356      * @deprecated
357      */
358     public void setChart(Chart chart) {
359         this.chart = chart;
360     }
361 
362     /**
363      * @return Returns the financialReportChart.
364      */
365     public Chart getFinancialReportChart() {
366         return financialReportChart;
367     }
368 
369     /**
370      * @param financialReportChart The financialReportChart to set.
371      * @deprecated
372      */
373     public void setFinancialReportChart(Chart financialReportChart) {
374         this.financialReportChart = financialReportChart;
375     }
376 
377     /**
378      * @return Returns the org.
379      */
380     public Organization getOrg() {
381         return org;
382     }
383 
384     /**
385      * @param org The org to set.
386      * @deprecated
387      */
388     public void setOrg(Organization org) {
389         this.org = org;
390     }
391 
392     /**
393      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
394      */
395     protected LinkedHashMap toStringMapper() {
396         LinkedHashMap m = new LinkedHashMap();
397         m.put("chartCode", this.chartOfAccountsCode);
398         m.put("account", this.accountNumber);
399         m.put("subAccountNumber", this.subAccountNumber);
400         return m;
401     }
402 
403     /**
404      * Gets the cGCostSharingSectionBlank attribute.
405      * 
406      * @return Returns the cGCostSharingSectionBlank.
407      */
408     public String getCgCostSharingSectionBlank() {
409         return cgCostSharingSectionBlank;
410     }
411 
412     /**
413      * Gets the cGICRSectionBlank attribute.
414      * 
415      * @return Returns the cGICRSectionBlank.
416      */
417     public String getCgICRSectionBlank() {
418         return cgICRSectionBlank;
419     }
420 
421     /**
422      * Gets the financialReportingCodeSectionBlank attribute.
423      * 
424      * @return Returns the financialReportingCodeSectionBlank.
425      */
426     public String getFinancialReportingCodeSectionBlank() {
427         return financialReportingCodeSectionBlank;
428     }
429 
430     /**
431      * Gets the cGCostSharingSection attribute.
432      * 
433      * @return Returns the cGCostSharingSection.
434      */
435     public String getCgCostSharingSection() {
436         return cgCostSharingSection;
437     }
438 
439     /**
440      * Gets the cGICRSection attribute.
441      * 
442      * @return Returns the cGICRSection.
443      */
444     public String getCgICRSection() {
445         return cgICRSection;
446     }
447 
448     /**
449      * Gets the financialReportingCodeSection attribute.
450      * 
451      * @return Returns the financialReportingCodeSection.
452      */
453     public String getFinancialReportingCodeSection() {
454         return financialReportingCodeSection;
455     }
456 
457     public static final class SubAccountId implements Serializable, Comparable<SubAccountId> {
458 
459         private String chartOfAccountsCode;
460 
461         private String accountNumber;
462 
463         private String subAccountNumber;
464 
465         public String getChartOfAccountsCode() {
466             return this.chartOfAccountsCode;
467         }
468 
469         public void setChartOfAccountsCode(String chartOfAccountsCode) {
470             this.chartOfAccountsCode = chartOfAccountsCode;
471         }
472 
473         public String getAccountNumber() {
474             return this.accountNumber;
475         }
476 
477         public void setAccountNumber(String accountNumber) {
478             this.accountNumber = accountNumber;
479         }
480 
481         public String getSubAccountNumber() {
482             return this.subAccountNumber;
483         }
484 
485         public void setSubAccountNumber(String subAccountNumber) {
486             this.subAccountNumber = subAccountNumber;
487         }
488 
489         @Override
490         public String toString() {
491             return new ToStringBuilder(this).append("chartOfAccountsCode", this.chartOfAccountsCode).append("accountNumber", this.accountNumber).append("subAccountNumber", this.subAccountNumber).toString();
492         }
493 
494         @Override
495         public boolean equals(Object other) {
496             if (other == null)
497                 return false;
498             if (other == this)
499                 return true;
500             if (other.getClass() != this.getClass())
501                 return false;
502             final SubAccountId rhs = (SubAccountId) other;
503             return new EqualsBuilder().append(this.chartOfAccountsCode, rhs.chartOfAccountsCode).append(this.accountNumber, rhs.accountNumber).append(this.subAccountNumber, rhs.subAccountNumber).isEquals();
504         }
505 
506         @Override
507         public int hashCode() {
508             return new HashCodeBuilder(17, 37).append(this.chartOfAccountsCode).append(this.accountNumber).append(this.subAccountNumber).toHashCode();
509         }
510 
511         @Override
512         public int compareTo(SubAccountId other) {
513             return new CompareToBuilder().append(this.chartOfAccountsCode, other.chartOfAccountsCode).append(this.accountNumber, other.accountNumber).append(this.subAccountNumber, other.subAccountNumber).toComparison();
514         }
515     }
516 }