001: /*
002: * Copyright 2005-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: package org.kuali.module.chart.bo;
017:
018: import java.util.LinkedHashMap;
019:
020: import org.apache.ojb.broker.PersistenceBroker;
021: import org.apache.ojb.broker.PersistenceBrokerException;
022: import org.kuali.core.bo.PersistableBusinessObjectBase;
023: import org.kuali.core.service.BusinessObjectService;
024: import org.kuali.kfs.context.SpringContext;
025: import org.kuali.module.gl.bo.SufficientFundRebuild;
026:
027: /**
028: *
029: */
030: public class ObjLevel extends PersistableBusinessObjectBase {
031: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
032: .getLogger(ObjLevel.class);
033:
034: private String chartOfAccountsCode;
035: private String financialObjectLevelCode;
036: private String financialObjectLevelName;
037: private String financialObjectLevelShortNm;
038: private boolean financialObjectLevelActiveIndicator;
039: private String financialReportingSortCode;
040: private String financialConsolidationObjectCode;
041:
042: private ObjectCons financialConsolidationObject;
043: private Chart chartOfAccounts;
044:
045: /**
046: * Constructs a ObjLevel.java.
047: */
048: public ObjLevel() {
049: super ();
050: this .financialConsolidationObject = new ObjectCons();
051: }
052:
053: /**
054: * Gets the financialObjectLevelCode attribute.
055: *
056: * @return Returns the financialObjectLevelCode
057: */
058: public String getFinancialObjectLevelCode() {
059: return financialObjectLevelCode;
060: }
061:
062: /**
063: * Sets the financialObjectLevelCode attribute.
064: *
065: * @param financialObjectLevelCode The financialObjectLevelCode to set.
066: */
067: public void setFinancialObjectLevelCode(
068: String financialObjectLevelCode) {
069: this .financialObjectLevelCode = financialObjectLevelCode;
070: }
071:
072: /**
073: * Gets the financialObjectLevelName attribute.
074: *
075: * @return Returns the financialObjectLevelName
076: */
077: public String getFinancialObjectLevelName() {
078: return financialObjectLevelName;
079: }
080:
081: /**
082: * Sets the financialObjectLevelName attribute.
083: *
084: * @param financialObjectLevelName The financialObjectLevelName to set.
085: */
086: public void setFinancialObjectLevelName(
087: String financialObjectLevelName) {
088: this .financialObjectLevelName = financialObjectLevelName;
089: }
090:
091: /**
092: * Gets the financialObjectLevelShortNm attribute.
093: *
094: * @return Returns the financialObjectLevelShortNm
095: */
096: public String getFinancialObjectLevelShortNm() {
097: return financialObjectLevelShortNm;
098: }
099:
100: /**
101: * Sets the financialObjectLevelShortNm attribute.
102: *
103: * @param financialObjectLevelShortNm The financialObjectLevelShortNm to set.
104: */
105: public void setFinancialObjectLevelShortNm(
106: String financialObjectLevelShortNm) {
107: this .financialObjectLevelShortNm = financialObjectLevelShortNm;
108: }
109:
110: /**
111: * Gets the financialObjectLevelActiveIndicator attribute.
112: *
113: * @return Returns the financialObjectLevelActiveIndicator
114: */
115: public boolean isFinancialObjectLevelActiveIndicator() {
116: return financialObjectLevelActiveIndicator;
117: }
118:
119: /**
120: * Sets the financialObjectLevelActiveIndicator attribute.
121: *
122: * @param financialObjectLevelActiveIndicator The financialObjectLevelActiveIndicator to set.
123: */
124: public void setFinancialObjectLevelActiveIndicator(
125: boolean financialObjectLevelActiveIndicator) {
126: this .financialObjectLevelActiveIndicator = financialObjectLevelActiveIndicator;
127: }
128:
129: /**
130: * Gets the financialReportingSortCode attribute.
131: *
132: * @return Returns the financialReportingSortCode
133: */
134: public String getFinancialReportingSortCode() {
135: return financialReportingSortCode;
136: }
137:
138: /**
139: * Sets the financialReportingSortCode attribute.
140: *
141: * @param financialReportingSortCode The financialReportingSortCode to set.
142: */
143: public void setFinancialReportingSortCode(
144: String financialReportingSortCode) {
145: this .financialReportingSortCode = financialReportingSortCode;
146: }
147:
148: public String getConsolidatedObjectCode() {
149: return financialConsolidationObject
150: .getFinancialReportingSortCode();
151: }
152:
153: /**
154: * Gets the financialConsolidationObject attribute.
155: *
156: * @return Returns the financialConsolidationObject
157: */
158: public ObjectCons getFinancialConsolidationObject() {
159: return financialConsolidationObject;
160: }
161:
162: /**
163: * Sets the financialConsolidationObject attribute.
164: *
165: * @param financialConsolidationObject The financialConsolidationObject to set.
166: */
167: public void setFinancialConsolidationObject(
168: ObjectCons financialConsolidationObject) {
169: this .financialConsolidationObject = financialConsolidationObject;
170: }
171:
172: public String getChartOfAccountsCode() {
173: return chartOfAccountsCode;
174: }
175:
176: /**
177: * Gets the chartOfAccounts attribute.
178: *
179: * @return Returns the chartOfAccounts
180: */
181: public Chart getChartOfAccounts() {
182: return chartOfAccounts;
183: }
184:
185: /**
186: * Sets the chartOfAccounts attribute.
187: *
188: * @param chartOfAccounts The chartOfAccounts to set.
189: * @deprecated
190: */
191: public void setChartOfAccounts(Chart chartOfAccounts) {
192: this .chartOfAccounts = chartOfAccounts;
193: }
194:
195: /**
196: * @return Returns the financialConsolidationObjectCode.
197: */
198: public String getFinancialConsolidationObjectCode() {
199: return financialConsolidationObjectCode;
200: }
201:
202: /**
203: * @param financialConsolidationObjectCode The financialConsolidationObjectCode to set.
204: */
205: public void setFinancialConsolidationObjectCode(
206: String financialConsolidationObjectCode) {
207: this .financialConsolidationObjectCode = financialConsolidationObjectCode;
208: }
209:
210: /**
211: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
212: */
213: protected LinkedHashMap toStringMapper() {
214: LinkedHashMap m = new LinkedHashMap();
215:
216: m.put("chartOfAccountsCode", this .chartOfAccountsCode);
217: m
218: .put("financialObjectLevelCode",
219: this .financialObjectLevelCode);
220:
221: return m;
222: }
223:
224: public void setChartOfAccountsCode(String chart) {
225: this .chartOfAccountsCode = chart;
226: }
227:
228: @Override
229: public void beforeUpdate(PersistenceBroker persistenceBroker)
230: throws PersistenceBrokerException {
231: super .beforeUpdate(persistenceBroker);
232: try {
233: // KULCOA-549: update the sufficient funds table
234: // get the current data from the database
235: BusinessObjectService boService = SpringContext
236: .getBean(BusinessObjectService.class);
237: ObjLevel originalObjLevel = (ObjLevel) boService
238: .retrieve(this );
239:
240: if (originalObjLevel != null) {
241: if (!originalObjLevel
242: .getFinancialConsolidationObjectCode().equals(
243: getFinancialConsolidationObjectCode())) {
244: SufficientFundRebuild sfr = new SufficientFundRebuild();
245: sfr
246: .setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
247: sfr.setChartOfAccountsCode(originalObjLevel
248: .getChartOfAccountsCode());
249: sfr
250: .setAccountNumberFinancialObjectCode(originalObjLevel
251: .getFinancialConsolidationObjectCode());
252: if (boService.retrieve(sfr) == null) {
253: persistenceBroker.store(sfr);
254: }
255: sfr = new SufficientFundRebuild();
256: sfr
257: .setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
258: sfr
259: .setChartOfAccountsCode(getChartOfAccountsCode());
260: sfr
261: .setAccountNumberFinancialObjectCode(getFinancialConsolidationObjectCode());
262: if (boService.retrieve(sfr) == null) {
263: persistenceBroker.store(sfr);
264: }
265: }
266: }
267: } catch (Exception ex) {
268: LOG
269: .error(
270: "Problem updating sufficient funds rebuild table: ",
271: ex);
272: }
273: }
274:
275: }
|