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.kuali.ole.gl.businessobject.SufficientFundRebuild;
21  import org.kuali.ole.sys.context.SpringContext;
22  import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
23  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
24  import org.kuali.rice.krad.service.BusinessObjectService;
25  
26  /**
27   * 
28   */
29  public class ObjectLevel extends PersistableBusinessObjectBase implements MutableInactivatable {
30      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ObjectLevel.class);
31  
32      private String chartOfAccountsCode;
33      private String financialObjectLevelCode;
34      private String financialObjectLevelName;
35      private String financialObjectLevelShortNm;
36      private boolean active;
37      private String financialReportingSortCode;
38      private String financialConsolidationObjectCode;
39  
40      private ObjectConsolidation financialConsolidationObject;
41      private Chart chartOfAccounts;
42  
43  
44      /**
45       * Constructs a ObjLevel.java.
46       */
47      public ObjectLevel() {
48          super();
49          this.financialConsolidationObject = new ObjectConsolidation();
50      }
51  
52      /**
53       * Gets the financialObjectLevelCode attribute.
54       * 
55       * @return Returns the financialObjectLevelCode
56       */
57      public String getFinancialObjectLevelCode() {
58          return financialObjectLevelCode;
59      }
60  
61      /**
62       * Sets the financialObjectLevelCode attribute.
63       * 
64       * @param financialObjectLevelCode The financialObjectLevelCode to set.
65       */
66      public void setFinancialObjectLevelCode(String financialObjectLevelCode) {
67          this.financialObjectLevelCode = financialObjectLevelCode;
68      }
69  
70      /**
71       * Gets the financialObjectLevelName attribute.
72       * 
73       * @return Returns the financialObjectLevelName
74       */
75      public String getFinancialObjectLevelName() {
76          return financialObjectLevelName;
77      }
78  
79      /**
80       * Sets the financialObjectLevelName attribute.
81       * 
82       * @param financialObjectLevelName The financialObjectLevelName to set.
83       */
84      public void setFinancialObjectLevelName(String financialObjectLevelName) {
85          this.financialObjectLevelName = financialObjectLevelName;
86      }
87  
88      /**
89       * Gets the financialObjectLevelShortNm attribute.
90       * 
91       * @return Returns the financialObjectLevelShortNm
92       */
93      public String getFinancialObjectLevelShortNm() {
94          return financialObjectLevelShortNm;
95      }
96  
97      /**
98       * Sets the financialObjectLevelShortNm attribute.
99       * 
100      * @param financialObjectLevelShortNm The financialObjectLevelShortNm to set.
101      */
102     public void setFinancialObjectLevelShortNm(String financialObjectLevelShortNm) {
103         this.financialObjectLevelShortNm = financialObjectLevelShortNm;
104     }
105 
106     /**
107      * Gets the financialObjectLevelActiveIndicator attribute.
108      * 
109      * @return Returns the financialObjectLevelActiveIndicator
110      */
111     public boolean isActive() {
112         return active;
113     }
114 
115     /**
116      * Sets the financialObjectLevelActiveIndicator attribute.
117      * 
118      * @param financialObjectLevelActiveIndicator The financialObjectLevelActiveIndicator to set.
119      */
120     public void setActive(boolean financialObjectLevelActiveIndicator) {
121         this.active = financialObjectLevelActiveIndicator;
122     }
123 
124     /**
125      * Gets the financialReportingSortCode attribute.
126      * 
127      * @return Returns the financialReportingSortCode
128      */
129     public String getFinancialReportingSortCode() {
130         return financialReportingSortCode;
131     }
132 
133     /**
134      * Sets the financialReportingSortCode attribute.
135      * 
136      * @param financialReportingSortCode The financialReportingSortCode to set.
137      */
138     public void setFinancialReportingSortCode(String financialReportingSortCode) {
139         this.financialReportingSortCode = financialReportingSortCode;
140     }
141 
142 
143     public String getConsolidatedObjectCode() {
144         return financialConsolidationObject.getFinancialReportingSortCode();
145     }
146 
147     /**
148      * Gets the financialConsolidationObject attribute.
149      * 
150      * @return Returns the financialConsolidationObject
151      */
152     public ObjectConsolidation getFinancialConsolidationObject() {
153         return financialConsolidationObject;
154     }
155 
156     /**
157      * Sets the financialConsolidationObject attribute.
158      * 
159      * @param financialConsolidationObject The financialConsolidationObject to set.
160      */
161     public void setFinancialConsolidationObject(ObjectConsolidation financialConsolidationObject) {
162         this.financialConsolidationObject = financialConsolidationObject;
163     }
164 
165     public String getChartOfAccountsCode() {
166         return chartOfAccountsCode;
167     }
168 
169     /**
170      * Gets the chartOfAccounts attribute.
171      * 
172      * @return Returns the chartOfAccounts
173      */
174     public Chart getChartOfAccounts() {
175         return chartOfAccounts;
176     }
177 
178     /**
179      * Sets the chartOfAccounts attribute.
180      * 
181      * @param chartOfAccounts The chartOfAccounts to set.
182      * @deprecated
183      */
184     public void setChartOfAccounts(Chart chartOfAccounts) {
185         this.chartOfAccounts = chartOfAccounts;
186     }
187 
188 
189     /**
190      * @return Returns the financialConsolidationObjectCode.
191      */
192     public String getFinancialConsolidationObjectCode() {
193         return financialConsolidationObjectCode;
194     }
195 
196     /**
197      * @param financialConsolidationObjectCode The financialConsolidationObjectCode to set.
198      */
199     public void setFinancialConsolidationObjectCode(String financialConsolidationObjectCode) {
200         this.financialConsolidationObjectCode = financialConsolidationObjectCode;
201     }
202 
203     public void setChartOfAccountsCode(String chart) {
204         this.chartOfAccountsCode = chart;
205     }
206 
207     @Override protected void preUpdate() {
208         super.preUpdate();
209         try {
210             // KULCOA-549: update the sufficient funds table
211             // get the current data from the database
212             BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);
213             ObjectLevel originalObjLevel = (ObjectLevel) boService.retrieve(this);
214 
215             if (originalObjLevel != null) {
216                 if (!originalObjLevel.getFinancialConsolidationObjectCode().equals(getFinancialConsolidationObjectCode())) {
217                     SufficientFundRebuild sfr = new SufficientFundRebuild();
218                     sfr.setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
219                     sfr.setChartOfAccountsCode(originalObjLevel.getChartOfAccountsCode());
220                     sfr.setAccountNumberFinancialObjectCode(originalObjLevel.getFinancialConsolidationObjectCode());
221                     if (boService.retrieve(sfr) == null) {
222                         boService.save(sfr);
223                     }
224                     sfr = new SufficientFundRebuild();
225                     sfr.setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
226                     sfr.setChartOfAccountsCode(getChartOfAccountsCode());
227                     sfr.setAccountNumberFinancialObjectCode(getFinancialConsolidationObjectCode());
228                     if (boService.retrieve(sfr) == null) {
229                         boService.save(sfr);
230                     }
231                 }
232             }
233         }
234         catch (Exception ex) {
235             LOG.error("Problem updating sufficient funds rebuild table: ", ex);
236         }
237     }
238 
239 }