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.util.LinkedHashMap;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.kuali.ole.coa.service.ChartService;
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.ole.sys.context.SpringContext;
24  import org.kuali.rice.kim.api.identity.Person;
25  import org.kuali.rice.kim.api.identity.PersonService;
26  import org.kuali.rice.krad.bo.KualiCode;
27  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
28  
29  /**
30   * 
31   */
32  public class Chart extends PersistableBusinessObjectBase implements KualiCode {
33  
34      private static final long serialVersionUID = 4129020803214027609L;
35  
36      public static final String CACHE_NAME = OLEConstants.APPLICATION_NAMESPACE_CODE + "/" + "Chart";
37  
38      protected String finChartOfAccountDescription;
39      protected boolean active;
40      protected String finCoaManagerPrincipalId;
41      protected String reportsToChartOfAccountsCode;
42      protected String chartOfAccountsCode;
43      protected String finAccountsPayableObjectCode;
44      protected String finExternalEncumbranceObjCd;
45      protected String finPreEncumbranceObjectCode;
46      protected String financialCashObjectCode;
47      protected String icrIncomeFinancialObjectCode;
48      protected String finAccountsReceivableObjCode;
49      protected String finInternalEncumbranceObjCd;
50      protected String icrExpenseFinancialObjectCd;
51      protected String incBdgtEliminationsFinObjCd;
52      protected String expBdgtEliminationsFinObjCd;
53      protected String fundBalanceObjectCode;
54  
55      protected ObjectCode incBdgtEliminationsFinObj;
56      protected ObjectCode expBdgtEliminationsFinObj;
57      protected ObjectCode finAccountsPayableObject;
58      protected ObjectCode finExternalEncumbranceObj;
59      protected ObjectCode finPreEncumbranceObject;
60      protected ObjectCode financialCashObject;
61      protected ObjectCode icrIncomeFinancialObject;
62      protected ObjectCode finAccountsReceivableObj;
63      protected ObjectCode finInternalEncumbranceObj;
64      protected ObjectCode icrExpenseFinancialObject;
65      protected ObjectCode fundBalanceObject;
66      protected Person finCoaManager;
67      protected Chart reportsToChartOfAccounts;
68  
69      private static transient ChartService chartService;
70  
71      /**
72       * Gets the finChartOfAccountDescription attribute.
73       * 
74       * @return Returns the finChartOfAccountDescription
75       */
76      public String getFinChartOfAccountDescription() {
77          return finChartOfAccountDescription;
78      }
79  
80      /**
81       * Sets the finChartOfAccountDescription attribute.
82       * 
83       * @param finChartOfAccountDescription The finChartOfAccountDescription to set.
84       */
85      public void setFinChartOfAccountDescription(String finChartOfAccountDescription) {
86          this.finChartOfAccountDescription = finChartOfAccountDescription;
87      }
88  
89      /**
90       * Gets the active attribute.
91       * 
92       * @return Returns the active
93       */
94      public boolean isActive() {
95          return active;
96      }
97  
98      /**
99       * Sets the active attribute.
100      * 
101      * @param active The active to set.
102      */
103     public void setActive(boolean active) {
104         this.active = active;
105     }
106 
107 
108     /**
109      * Gets the finAccountsPayableObject attribute.
110      * 
111      * @return Returns the finAccountsPayableObject
112      */
113     public ObjectCode getFinAccountsPayableObject() {
114         return finAccountsPayableObject;
115     }
116 
117     /**
118      * Sets the finAccountsPayableObject attribute.
119      * 
120      * @param finAccountsPayableObject The finAccountsPayableObject to set.
121      * @deprecated
122      */
123     public void setFinAccountsPayableObject(ObjectCode finAccountsPayableObject) {
124         this.finAccountsPayableObject = finAccountsPayableObject;
125     }
126 
127 
128     /**
129      * Gets the finExternalEncumbranceObj attribute.
130      * 
131      * @return Returns the finExternalEncumbranceObj.
132      */
133     public ObjectCode getFinExternalEncumbranceObj() {
134         return finExternalEncumbranceObj;
135     }
136 
137     /**
138      * Sets the finExternalEncumbranceObj attribute value.
139      * 
140      * @param finExternalEncumbranceObj The finExternalEncumbranceObj to set.
141      * @deprecated
142      */
143     public void setFinExternalEncumbranceObj(ObjectCode finExternalEncumbranceObj) {
144         this.finExternalEncumbranceObj = finExternalEncumbranceObj;
145     }
146 
147     /**
148      * Gets the finPreEncumbranceObject attribute.
149      * 
150      * @return Returns the finPreEncumbranceObject
151      */
152     public ObjectCode getFinPreEncumbranceObject() {
153         return finPreEncumbranceObject;
154     }
155 
156     /**
157      * Sets the finPreEncumbranceObject attribute.
158      * 
159      * @param finPreEncumbranceObject The finPreEncumbranceObject to set.
160      * @deprecated
161      */
162     public void setFinPreEncumbranceObject(ObjectCode finPreEncumbranceObject) {
163         this.finPreEncumbranceObject = finPreEncumbranceObject;
164     }
165 
166     /**
167      * Gets the financialCashObject attribute.
168      * 
169      * @return Returns the financialCashObject
170      */
171     public ObjectCode getFinancialCashObject() {
172         return financialCashObject;
173     }
174 
175     /**
176      * Sets the financialCashObject attribute.
177      * 
178      * @param financialCashObject The financialCashObject to set.
179      * @deprecated
180      */
181     public void setFinancialCashObject(ObjectCode financialCashObject) {
182         this.financialCashObject = financialCashObject;
183     }
184 
185     /**
186      * Gets the icrIncomeFinancialObject attribute.
187      * 
188      * @return Returns the icrIncomeFinancialObject
189      */
190     public ObjectCode getIcrIncomeFinancialObject() {
191         return icrIncomeFinancialObject;
192     }
193 
194     /**
195      * Sets the icrIncomeFinancialObject attribute.
196      * 
197      * @param icrIncomeFinancialObject The icrIncomeFinancialObject to set.
198      * @deprecated
199      */
200     public void setIcrIncomeFinancialObject(ObjectCode icrIncomeFinancialObject) {
201         this.icrIncomeFinancialObject = icrIncomeFinancialObject;
202     }
203 
204     /**
205      * Gets the finAccountsReceivableObj attribute.
206      * 
207      * @return Returns the finAccountsReceivableObj
208      */
209     public ObjectCode getFinAccountsReceivableObj() {
210         return finAccountsReceivableObj;
211     }
212 
213     /**
214      * Sets the finAccountsReceivableObj attribute.
215      * 
216      * @param finAccountsReceivableObj The finAccountsReceivableObj to set.
217      * @deprecated
218      */
219     public void setFinAccountsReceivableObj(ObjectCode finAccountsReceivableObj) {
220         this.finAccountsReceivableObj = finAccountsReceivableObj;
221     }
222 
223     public Person getFinCoaManager() {
224         finCoaManager = SpringContext.getBean(PersonService.class).updatePersonIfNecessary(getFinCoaManagerPrincipalId(), finCoaManager);
225         return finCoaManager;
226     }
227 
228     /**
229      * Sets the finCoaManagerUniversal attribute.
230      * 
231      * @param finCoaManagerUniversal The finCoaManagerUniversal to set.
232      * @deprecated
233      */
234     public void setFinCoaManager(Person finCoaManagerUniversal) {
235         this.finCoaManager = finCoaManagerUniversal;
236     }
237 
238     /**
239      * Gets the reportsToChartOfAccounts attribute.
240      * 
241      * @return Returns the reportsToChartOfAccounts
242      */
243     public Chart getReportsToChartOfAccounts() {
244         return reportsToChartOfAccounts;
245     }
246 
247     /**
248      * Sets the reportsToChartOfAccounts attribute.
249      * 
250      * @param reportsToChartOfAccounts The reportsToChartOfAccounts to set.
251      * @deprecated
252      */
253     public void setReportsToChartOfAccounts(Chart reportsToChartOfAccounts) {
254         this.reportsToChartOfAccounts = reportsToChartOfAccounts;
255     }
256 
257     /**
258      * Gets the finInternalEncumbranceObj attribute.
259      * 
260      * @return Returns the finInternalEncumbranceObj.
261      */
262     public ObjectCode getFinInternalEncumbranceObj() {
263         return finInternalEncumbranceObj;
264     }
265 
266     /**
267      * Sets the finInternalEncumbranceObj attribute value.
268      * 
269      * @param finInternalEncumbranceObj The finInternalEncumbranceObj to set.
270      * @deprecated
271      */
272     public void setFinInternalEncumbranceObj(ObjectCode finInternalEncumbranceObj) {
273         this.finInternalEncumbranceObj = finInternalEncumbranceObj;
274     }
275 
276     /**
277      * Gets the icrExpenseFinancialObject attribute.
278      * 
279      * @return Returns the icrExpenseFinancialObject.
280      */
281     public ObjectCode getIcrExpenseFinancialObject() {
282         return icrExpenseFinancialObject;
283     }
284 
285     /**
286      * Sets the icrExpenseFinancialObject attribute value.
287      * 
288      * @param icrExpenseFinancialObject The icrExpenseFinancialObject to set.
289      * @deprecated
290      */
291     public void setIcrExpenseFinancialObject(ObjectCode icrExpenseFinancialObject) {
292         this.icrExpenseFinancialObject = icrExpenseFinancialObject;
293     }
294 
295     /**
296      * Gets the chartOfAccountsCode attribute.
297      * 
298      * @return Returns the chartOfAccountsCode.
299      */
300     public String getChartOfAccountsCode() {
301         return chartOfAccountsCode;
302     }
303 
304     /**
305      * Sets the chartOfAccountsCode attribute value.
306      * 
307      * @param chartOfAccountsCode The chartOfAccountsCode to set.
308      */
309     public void setChartOfAccountsCode(String chartOfAccountsCode) {
310         this.chartOfAccountsCode = chartOfAccountsCode;
311     }
312 
313     /**
314      * Gets the expBdgtEliminationsFinObj attribute.
315      * 
316      * @return Returns the expBdgtEliminationsFinObj.
317      */
318     public ObjectCode getExpBdgtEliminationsFinObj() {
319         return expBdgtEliminationsFinObj;
320     }
321 
322     /**
323      * Sets the expBdgtEliminationsFinObj attribute value.
324      * 
325      * @param expBdgtEliminationsFinObj The expBdgtEliminationsFinObj to set.
326      * @deprecated
327      */
328     public void setExpBdgtEliminationsFinObj(ObjectCode expBdgtEliminationsFinObj) {
329         this.expBdgtEliminationsFinObj = expBdgtEliminationsFinObj;
330     }
331 
332     /**
333      * Gets the incBdgtEliminationsFinObj attribute.
334      * 
335      * @return Returns the incBdgtEliminationsFinObj.
336      */
337     public ObjectCode getIncBdgtEliminationsFinObj() {
338         return incBdgtEliminationsFinObj;
339     }
340 
341     /**
342      * Sets the incBdgtEliminationsFinObj attribute value.
343      * 
344      * @param incBdgtEliminationsFinObj The incBdgtEliminationsFinObj to set.
345      * @deprecated
346      */
347     public void setIncBdgtEliminationsFinObj(ObjectCode incBdgtEliminationsFinObj) {
348         this.incBdgtEliminationsFinObj = incBdgtEliminationsFinObj;
349     }
350 
351     /**
352      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
353      */
354     @SuppressWarnings("unchecked")
355     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
356         LinkedHashMap m = new LinkedHashMap();
357 
358         m.put("chartOfAccountsCode", this.chartOfAccountsCode);
359 
360         return m;
361     }
362 
363     /**
364      * Gets the finAccountsPayableObjectCode attribute.
365      * 
366      * @return Returns the finAccountsPayableObjectCode.
367      */
368     public String getFinAccountsPayableObjectCode() {
369         return finAccountsPayableObjectCode;
370     }
371 
372     /**
373      * Sets the finAccountsPayableObjectCode attribute value.
374      * 
375      * @param finAccountsPayableObjectCode The finAccountsPayableObjectCode to set.
376      */
377     public void setFinAccountsPayableObjectCode(String finAccountsPayableObjectCode) {
378         this.finAccountsPayableObjectCode = finAccountsPayableObjectCode;
379     }
380 
381     /**
382      * Gets the finAccountsReceivableObjCode attribute.
383      * 
384      * @return Returns the finAccountsReceivableObjCode.
385      */
386     public String getFinAccountsReceivableObjCode() {
387         return finAccountsReceivableObjCode;
388     }
389 
390     /**
391      * Sets the finAccountsReceivableObjCode attribute value.
392      * 
393      * @param finAccountsReceivableObjCode The finAccountsReceivableObjCode to set.
394      */
395     public void setFinAccountsReceivableObjCode(String finAccountsReceivableObjCode) {
396         this.finAccountsReceivableObjCode = finAccountsReceivableObjCode;
397     }
398 
399     /**
400      * Gets the financialCashObjectCode attribute.
401      * 
402      * @return Returns the financialCashObjectCode.
403      */
404     public String getFinancialCashObjectCode() {
405         return financialCashObjectCode;
406     }
407 
408     /**
409      * Sets the financialCashObjectCode attribute value.
410      * 
411      * @param financialCashObjectCode The financialCashObjectCode to set.
412      */
413     public void setFinancialCashObjectCode(String financialCashObjectCode) {
414         this.financialCashObjectCode = financialCashObjectCode;
415     }
416 
417     /**
418      * Gets the finExternalEncumbranceObjCd attribute.
419      * 
420      * @return Returns the finExternalEncumbranceObjCd.
421      */
422     public String getFinExternalEncumbranceObjCd() {
423         return finExternalEncumbranceObjCd;
424     }
425 
426     /**
427      * Sets the finExternalEncumbranceObjCd attribute value.
428      * 
429      * @param finExternalEncumbranceObjCd The finExternalEncumbranceObjCd to set.
430      */
431     public void setFinExternalEncumbranceObjCd(String finExternalEncumbranceObjCd) {
432         this.finExternalEncumbranceObjCd = finExternalEncumbranceObjCd;
433     }
434 
435     /**
436      * Gets the finInternalEncumbranceObjCd attribute.
437      * 
438      * @return Returns the finInternalEncumbranceObjCd.
439      */
440     public String getFinInternalEncumbranceObjCd() {
441         return finInternalEncumbranceObjCd;
442     }
443 
444     /**
445      * Sets the finInternalEncumbranceObjCd attribute value.
446      * 
447      * @param finInternalEncumbranceObjCd The finInternalEncumbranceObjCd to set.
448      */
449     public void setFinInternalEncumbranceObjCd(String finInternalEncumbranceObjCd) {
450         this.finInternalEncumbranceObjCd = finInternalEncumbranceObjCd;
451     }
452 
453     /**
454      * Gets the finPreEncumbranceObjectCode attribute.
455      * 
456      * @return Returns the finPreEncumbranceObjectCode.
457      */
458     public String getFinPreEncumbranceObjectCode() {
459         return finPreEncumbranceObjectCode;
460     }
461 
462     /**
463      * Sets the finPreEncumbranceObjectCode attribute value.
464      * 
465      * @param finPreEncumbranceObjectCode The finPreEncumbranceObjectCode to set.
466      */
467     public void setFinPreEncumbranceObjectCode(String finPreEncumbranceObjectCode) {
468         this.finPreEncumbranceObjectCode = finPreEncumbranceObjectCode;
469     }
470 
471     /**
472      * Gets the icrExpenseFinancialObjectCd attribute.
473      * 
474      * @return Returns the icrExpenseFinancialObjectCd.
475      */
476     public String getIcrExpenseFinancialObjectCd() {
477         return icrExpenseFinancialObjectCd;
478     }
479 
480     /**
481      * Sets the icrExpenseFinancialObjectCd attribute value.
482      * 
483      * @param icrExpenseFinancialObjectCd The icrExpenseFinancialObjectCd to set.
484      */
485     public void setIcrExpenseFinancialObjectCd(String icrExpenseFinancialObjectCd) {
486         this.icrExpenseFinancialObjectCd = icrExpenseFinancialObjectCd;
487     }
488 
489     /**
490      * Gets the icrIncomeFinancialObjectCode attribute.
491      * 
492      * @return Returns the icrIncomeFinancialObjectCode.
493      */
494     public String getIcrIncomeFinancialObjectCode() {
495         return icrIncomeFinancialObjectCode;
496     }
497 
498     /**
499      * Sets the icrIncomeFinancialObjectCode attribute value.
500      * 
501      * @param icrIncomeFinancialObjectCode The icrIncomeFinancialObjectCode to set.
502      */
503     public void setIcrIncomeFinancialObjectCode(String icrIncomeFinancialObjectCode) {
504         this.icrIncomeFinancialObjectCode = icrIncomeFinancialObjectCode;
505     }
506 
507     /**
508      * Gets the expBdgtEliminationsFinObjCd attribute.
509      * 
510      * @return Returns the expBdgtEliminationsFinObjCd
511      */
512     public String getExpBdgtEliminationsFinObjCd() {
513         return expBdgtEliminationsFinObjCd;
514     }
515 
516     /**
517      * Sets the expBdgtEliminationsFinObjCd attribute.
518      * 
519      * @param expBdgtEliminationsFinObjCd The expBdgtEliminationsFinObjCd to set.
520      */
521     public void setExpBdgtEliminationsFinObjCd(String expBdgtEliminationsFinObjCd) {
522         this.expBdgtEliminationsFinObjCd = expBdgtEliminationsFinObjCd;
523     }
524 
525     /**
526      * Gets the incBdgtEliminationsFinObjCd attribute.
527      * 
528      * @return Returns the incBdgtEliminationsFinObjCd
529      */
530     public String getIncBdgtEliminationsFinObjCd() {
531         return incBdgtEliminationsFinObjCd;
532     }
533 
534     /**
535      * Sets the incBdgtEliminationsFinObjCd attribute.
536      * 
537      * @param incBdgtEliminationsFinObjCd The incBdgtEliminationsFinObjCd to set.
538      */
539     public void setIncBdgtEliminationsFinObjCd(String incBdgtEliminationsFinObjCd) {
540         this.incBdgtEliminationsFinObjCd = incBdgtEliminationsFinObjCd;
541     }
542 
543     /**
544      * Gets the finCoaManagerPrincipalId attribute.
545      * 
546      * @return Returns the finCoaManagerPrincipalId.
547      */
548     public String getFinCoaManagerPrincipalId() {
549         if (StringUtils.isNotBlank(chartOfAccountsCode) && StringUtils.isBlank(finCoaManagerPrincipalId)) {
550             Person chartManager = getChartService().getChartManager(chartOfAccountsCode);
551             if (chartManager != null) {
552                 finCoaManager = chartManager;
553                 finCoaManagerPrincipalId = chartManager.getPrincipalId();
554             } else {
555                 finCoaManagerPrincipalId = null;
556                 finCoaManager = null;
557             }
558         }
559         return finCoaManagerPrincipalId;
560     }
561 
562     /**
563      * Sets the finCoaManagerPrincipalId attribute value.
564      * 
565      * @param finCoaManagerPrincipalId The finCoaManagerPrincipalId to set.
566      */
567     public void setFinCoaManagerPrincipalId(String finCoaManagerPrincipalId) {
568         this.finCoaManagerPrincipalId = finCoaManagerPrincipalId;
569     }
570 
571     /**
572      * @return Returns the reportsToChartOfAccountsCode.
573      */
574     public String getReportsToChartOfAccountsCode() {
575         return reportsToChartOfAccountsCode;
576     }
577 
578     /**
579      * @param reportsToChartOfAccountsCode The reportsToChartOfAccountsCode to set.
580      */
581     public void setReportsToChartOfAccountsCode(String reportsToChartOfAccountsCode) {
582         this.reportsToChartOfAccountsCode = reportsToChartOfAccountsCode;
583     }
584 
585     /**
586      * Gets the fundBalanceObject attribute.
587      * 
588      * @return Returns the fundBalanceObject.
589      */
590     public ObjectCode getFundBalanceObject() {
591         return fundBalanceObject;
592     }
593 
594     /**
595      * Sets the fundBalanceObject attribute value.
596      * 
597      * @param fundBalanceObject The fundBalanceObject to set.
598      * @deprecated
599      */
600     public void setFundBalanceObject(ObjectCode fundBalanceObject) {
601         this.fundBalanceObject = fundBalanceObject;
602     }
603 
604     /**
605      * Gets the fundBalanceObjectCode attribute.
606      * 
607      * @return Returns the fundBalanceObjectCode.
608      */
609     public String getFundBalanceObjectCode() {
610         return fundBalanceObjectCode;
611     }
612 
613     /**
614      * Sets the fundBalanceObjectCode attribute value.
615      * 
616      * @param fundBalanceObjectCode The fundBalanceObjectCode to set.
617      */
618     public void setFundBalanceObjectCode(String fundBalanceObjectCode) {
619         this.fundBalanceObjectCode = fundBalanceObjectCode;
620     }
621 
622     /**
623      * @return Returns the code and description in format: xx - xxxxxxxxxxxxxxxx
624      */
625     public String getCodeAndDescription() {
626         if (StringUtils.isNotBlank(getChartOfAccountsCode()) && StringUtils.isNotBlank(getFinChartOfAccountDescription()))
627             return getChartOfAccountsCode() + " - " + getFinChartOfAccountDescription();
628         else 
629             return "";
630     }
631 
632     public String getCode() {
633         return this.chartOfAccountsCode;
634     }
635 
636     public String getName() {
637         return this.finChartOfAccountDescription;
638     }
639 
640     protected static ChartService getChartService() {
641         if ( chartService == null ) {
642             chartService = SpringContext.getBean(ChartService.class);
643         }
644         return chartService;
645     }
646 
647     public void setCode(String chartOfAccountsCode) {
648         setChartOfAccountsCode(chartOfAccountsCode);        
649     }
650 
651     public void setName(String finChartOfAccountDescription) {
652         setFinChartOfAccountDescription(finChartOfAccountDescription);
653     }
654     
655     public String getChartCodeForReport() {
656         return this.chartOfAccountsCode;
657     }
658 }
659