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.bo.Summarizable;
024: import org.kuali.core.service.BusinessObjectService;
025: import org.kuali.core.service.impl.PersistenceStructureServiceImpl;
026: import org.kuali.kfs.bo.Options;
027: import org.kuali.kfs.context.SpringContext;
028: import org.kuali.module.chart.bo.codes.BudgetAggregationCode;
029: import org.kuali.module.chart.bo.codes.FederalFundedCode;
030: import org.kuali.module.chart.bo.codes.MandatoryTransferEliminationCode;
031: import org.kuali.module.gl.bo.SufficientFundRebuild;
032:
033: /**
034: *
035: */
036: public class ObjectCode extends PersistableBusinessObjectBase implements
037: Summarizable {
038:
039: static {
040: PersistenceStructureServiceImpl.referenceConversionMap.put(
041: ObjectCode.class, ObjectCodeCurrent.class);
042: }
043:
044: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
045: .getLogger(ObjectCode.class);
046:
047: private static final long serialVersionUID = -965833141452795485L;
048: private Integer universityFiscalYear;
049: private String chartOfAccountsCode;
050: private String financialObjectCode;
051: private String financialObjectCodeName;
052: private String financialObjectCodeShortName;
053: private String historicalFinancialObjectCode;
054: private boolean financialObjectActiveCode;
055: private String financialObjectLevelCode;
056: private String reportsToChartOfAccountsCode;
057: private String reportsToFinancialObjectCode;
058: private String financialObjectTypeCode;
059: private String financialObjectSubTypeCode;
060: private String financialBudgetAggregationCd;
061: private String nextYearFinancialObjectCode;
062: private String finObjMandatoryTrnfrelimCd;
063: private String financialFederalFundedCode;
064:
065: private transient BudgetAggregationCode financialBudgetAggregation;
066: private transient MandatoryTransferEliminationCode finObjMandatoryTrnfrelim;
067: private transient FederalFundedCode financialFederalFunded;
068: private transient Options universityFiscal;
069: private transient ObjLevel financialObjectLevel;
070: private transient Chart chartOfAccounts;
071: private transient Chart reportsToChartOfAccounts;
072: private transient ObjectCode reportsToFinancialObject;
073: private transient ObjectType financialObjectType;
074: private transient ObjSubTyp financialObjectSubType;
075:
076: /**
077: * Default no-arg constructor.
078: */
079: public ObjectCode() {
080: // initialize the object fiscal year to the current fiscal year
081: // universityFiscalYear = SpringContext.getBean(DateTimeService.class).getCurrentFiscalYear();
082:
083: // construct the referenced objects for the calling of the referencing object
084: this .financialObjectLevel = new ObjLevel();
085: this .financialObjectType = new ObjectType();
086: }
087:
088: /**
089: * Constructs a ObjectCode.java with the given defaults; this way, it is not necessary to use any deprecated setters.
090: *
091: * @param fiscalYear
092: * @param chart
093: * @param financialObjectCode - an active object code
094: */
095: public ObjectCode(Integer fiscalYear, String chart,
096: String financialObjectCode) {
097: this .universityFiscalYear = fiscalYear;
098: this .chartOfAccountsCode = chart;
099: this .financialObjectCode = financialObjectCode;
100: this .financialObjectActiveCode = true;
101: }
102:
103: /**
104: * This method is only for use by the framework
105: */
106: public void setUniversityFiscalYear(Integer i) {
107: this .universityFiscalYear = i;
108: }
109:
110: /**
111: * Gets the financialFederalFunded attribute.
112: *
113: * @return Returns the financialFederalFunded.
114: */
115: public FederalFundedCode getFinancialFederalFunded() {
116: return financialFederalFunded;
117: }
118:
119: /**
120: * Sets the financialFederalFunded attribute value.
121: *
122: * @param financialFederalFunded The financialFederalFunded to set.
123: * @deprecated
124: */
125: public void setFinancialFederalFunded(
126: FederalFundedCode financialFederalFunded) {
127: this .financialFederalFunded = financialFederalFunded;
128: }
129:
130: /**
131: * Gets the finObjMandatoryTrnfrelim attribute.
132: *
133: * @return Returns the finObjMandatoryTrnfrelimCd.
134: */
135: public MandatoryTransferEliminationCode getFinObjMandatoryTrnfrelim() {
136: return finObjMandatoryTrnfrelim;
137: }
138:
139: /**
140: * Sets the finObjMandatoryTrnfrelim attribute value.
141: *
142: * @param finObjMandatoryTrnfrelim The finObjMandatoryTrnfrelim to set.
143: * @deprecated
144: */
145: public void setFinObjMandatoryTrnfrelim(
146: MandatoryTransferEliminationCode finObjMandatoryTrnfrelim) {
147: this .finObjMandatoryTrnfrelim = finObjMandatoryTrnfrelim;
148: }
149:
150: /**
151: * Gets the financialObjectCode attribute.
152: *
153: * @return Returns the financialObjectCode
154: */
155: public String getFinancialObjectCode() {
156: return financialObjectCode;
157: }
158:
159: /**
160: * Sets the financialObjectCode attribute.
161: *
162: * @param financialObjectCode The financialObjectCode to set.
163: */
164: public void setFinancialObjectCode(String financialObjectCode) {
165: this .financialObjectCode = financialObjectCode;
166: }
167:
168: /**
169: * Gets the financialObjectCodeName attribute.
170: *
171: * @return Returns the financialObjectCodeName
172: */
173: public String getFinancialObjectCodeName() {
174: return financialObjectCodeName;
175: }
176:
177: /**
178: * Sets the financialObjectCodeName attribute.
179: *
180: * @param financialObjectCodeName The financialObjectCodeName to set.
181: */
182: public void setFinancialObjectCodeName(
183: String financialObjectCodeName) {
184: this .financialObjectCodeName = financialObjectCodeName;
185: }
186:
187: /**
188: * Gets the financialObjectCodeShortName attribute.
189: *
190: * @return Returns the financialObjectCodeShortName
191: */
192: public String getFinancialObjectCodeShortName() {
193: return financialObjectCodeShortName;
194: }
195:
196: /**
197: * Sets the financialObjectCodeShortName attribute.
198: *
199: * @param financialObjectCodeShortName The financialObjectCodeShortName to set.
200: */
201: public void setFinancialObjectCodeShortName(
202: String financialObjectCodeShortName) {
203: this .financialObjectCodeShortName = financialObjectCodeShortName;
204: }
205:
206: /**
207: * Gets the historicalFinancialObjectCode attribute.
208: *
209: * @return Returns the historicalFinancialObjectCode
210: */
211: public String getHistoricalFinancialObjectCode() {
212: return historicalFinancialObjectCode;
213: }
214:
215: /**
216: * Sets the historicalFinancialObjectCode attribute.
217: *
218: * @param historicalFinancialObjectCode The historicalFinancialObjectCode to set.
219: */
220: public void setHistoricalFinancialObjectCode(
221: String historicalFinancialObjectCode) {
222: this .historicalFinancialObjectCode = historicalFinancialObjectCode;
223: }
224:
225: /**
226: * Gets the financialObjectActiveCode attribute.
227: *
228: * @return Returns the financialObjectActiveCode
229: */
230: public boolean isFinancialObjectActiveCode() {
231: return financialObjectActiveCode;
232: }
233:
234: /**
235: * Sets the financialObjectActiveCode attribute.
236: *
237: * @param financialObjectActiveCode The financialObjectActiveCode to set.
238: */
239: public void setFinancialObjectActiveCode(
240: boolean financialObjectActiveCode) {
241: this .financialObjectActiveCode = financialObjectActiveCode;
242: }
243:
244: /**
245: * Gets the financialBudgetAggregationCd attribute.
246: *
247: * @return Returns the financialBudgetAggregationCd
248: */
249: /*
250: * public BudgetAggregationCode getFinancialBudgetAggregation() { return financialBudgetAggregation; }
251: */
252:
253: /**
254: * Sets the financialBudgetAggregationCd attribute.
255: *
256: * @param financialBudgetAggregationCd The financialBudgetAggregationCd to set.
257: * @deprecated
258: */
259: /*
260: * public void setFinancialBudgetAggregation(BudgetAggregationCode financialBudgetAggregationCd) {
261: * this.financialBudgetAggregation = financialBudgetAggregationCd; }
262: */
263:
264: /**
265: * Gets the universityFiscal attribute.
266: *
267: * @return Returns the universityFiscal
268: */
269: public Options getUniversityFiscal() {
270: return universityFiscal;
271: }
272:
273: /**
274: * Sets the universityFiscal attribute.
275: *
276: * @param universityFiscal The universityFiscal to set.
277: * @deprecated
278: */
279: public void setUniversityFiscal(Options universityFiscal) {
280: this .universityFiscal = universityFiscal;
281: }
282:
283: /**
284: * Gets the financialObjectLevel attribute.
285: *
286: * @return Returns the financialObjectLevel
287: */
288: public ObjLevel getFinancialObjectLevel() {
289: return financialObjectLevel;
290: }
291:
292: /**
293: * Sets the financialObjectLevel attribute.
294: *
295: * @param financialObjectLevel The financialObjectLevel to set.
296: * @deprecated
297: */
298: public void setFinancialObjectLevel(ObjLevel financialObjectLevel) {
299: this .financialObjectLevel = financialObjectLevel;
300: }
301:
302: /**
303: * Gets the chartOfAccounts attribute.
304: *
305: * @return Returns the chartOfAccounts
306: */
307: public Chart getChartOfAccounts() {
308: return chartOfAccounts;
309: }
310:
311: /**
312: * Sets the chartOfAccounts attribute.
313: *
314: * @param chartOfAccounts The chartOfAccounts to set.
315: * @deprecated
316: */
317: public void setChartOfAccounts(Chart chartOfAccounts) {
318: this .chartOfAccounts = chartOfAccounts;
319: }
320:
321: /**
322: * Gets the reportsToChartOfAccounts attribute.
323: *
324: * @return Returns the reportsToChartOfAccounts
325: */
326: public Chart getReportsToChartOfAccounts() {
327: return reportsToChartOfAccounts;
328: }
329:
330: /**
331: * Sets the reportsToChartOfAccounts attribute.
332: *
333: * @param reportsToChartOfAccounts The reportsToChartOfAccounts to set.
334: * @deprecated
335: */
336: public void setReportsToChartOfAccounts(
337: Chart reportsToChartOfAccounts) {
338: this .reportsToChartOfAccounts = reportsToChartOfAccounts;
339: }
340:
341: /**
342: * Gets the reportsToFinancialObject attribute.
343: *
344: * @return Returns the reportsToFinancialObject
345: */
346: public ObjectCode getReportsToFinancialObject() {
347: return reportsToFinancialObject;
348: }
349:
350: /**
351: * Sets the reportsToFinancialObject attribute.
352: *
353: * @param reportsToFinancialObject The reportsToFinancialObject to set.
354: * @deprecated
355: */
356: public void setReportsToFinancialObject(
357: ObjectCode reportsToFinancialObject) {
358: this .reportsToFinancialObject = reportsToFinancialObject;
359: }
360:
361: /**
362: * Gets the financialObjectType attribute.
363: *
364: * @return Returns the financialObjectType
365: */
366: public ObjectType getFinancialObjectType() {
367: return financialObjectType;
368: }
369:
370: /**
371: * Sets the financialObjectType attribute.
372: *
373: * @param financialObjectType The financialObjectType to set.
374: * @deprecated
375: */
376: public void setFinancialObjectType(ObjectType financialObjectType) {
377: this .financialObjectType = financialObjectType;
378: }
379:
380: /**
381: * Gets the financialObjectSubType attribute.
382: *
383: * @return Returns the financialObjectSubType
384: */
385: public ObjSubTyp getFinancialObjectSubType() {
386: return financialObjectSubType;
387: }
388:
389: /**
390: * Sets the financialObjectSubType attribute.
391: *
392: * @param financialObjectSubType The financialObjectSubType to set.
393: * @deprecated
394: */
395: public void setFinancialObjectSubType(
396: ObjSubTyp financialObjectSubType) {
397: this .financialObjectSubType = financialObjectSubType;
398: }
399:
400: /**
401: */
402: public void setChartOfAccountsCode(String string) {
403: this .chartOfAccountsCode = string;
404: }
405:
406: /**
407: *
408: */
409: public String getChartOfAccountsCode() {
410: return this .chartOfAccountsCode;
411: }
412:
413: /**
414: *
415: */
416: public Integer getUniversityFiscalYear() {
417: return this .universityFiscalYear;
418: }
419:
420: /**
421: * @return Returns the financialBudgetAggregationCd.
422: */
423: public String getFinancialBudgetAggregationCd() {
424: return financialBudgetAggregationCd;
425: }
426:
427: /**
428: * @param financialBudgetAggregationCd The financialBudgetAggregationCd to set.
429: */
430: public void setFinancialBudgetAggregationCd(
431: String financialBudgetAggregationCd) {
432: this .financialBudgetAggregationCd = financialBudgetAggregationCd;
433: }
434:
435: /**
436: * @return Returns the financialObjectLevelCode.
437: */
438: public String getFinancialObjectLevelCode() {
439: return financialObjectLevelCode;
440: }
441:
442: /**
443: * @param financialObjectLevelCode The financialObjectLevelCode to set.
444: */
445: public void setFinancialObjectLevelCode(
446: String financialObjectLevelCode) {
447: this .financialObjectLevelCode = financialObjectLevelCode;
448: }
449:
450: /**
451: * @return Returns the financialObjectSubTypeCode.
452: */
453: public String getFinancialObjectSubTypeCode() {
454: return financialObjectSubTypeCode;
455: }
456:
457: /**
458: * @param financialObjectSubTypeCode The financialObjectSubTypeCode to set.
459: */
460: public void setFinancialObjectSubTypeCode(
461: String financialObjectSubTypeCode) {
462: this .financialObjectSubTypeCode = financialObjectSubTypeCode;
463: }
464:
465: /**
466: * @return Returns the financialObjectTypeCode.
467: */
468: public String getFinancialObjectTypeCode() {
469: return financialObjectTypeCode;
470: }
471:
472: /**
473: * @param financialObjectTypeCode The financialObjectTypeCode to set.
474: */
475: public void setFinancialObjectTypeCode(
476: String financialObjectTypeCode) {
477: this .financialObjectTypeCode = financialObjectTypeCode;
478: }
479:
480: /**
481: * @return Returns the nextYearFinancialObjectCode.
482: */
483: public String getNextYearFinancialObjectCode() {
484: return nextYearFinancialObjectCode;
485: }
486:
487: /**
488: * @param nextYearFinancialObjectCode The nextYearFinancialObjectCode to set.
489: */
490: public void setNextYearFinancialObjectCode(
491: String nextYearFinancialObjectCode) {
492: this .nextYearFinancialObjectCode = nextYearFinancialObjectCode;
493: }
494:
495: /**
496: * @return Returns the reportsToChartOfAccountsCode.
497: */
498: public String getReportsToChartOfAccountsCode() {
499: return reportsToChartOfAccountsCode;
500: }
501:
502: /**
503: * @param reportsToChartOfAccountsCode The reportsToChartOfAccountsCode to set.
504: */
505: public void setReportsToChartOfAccountsCode(
506: String reportsToChartOfAccountsCode) {
507: this .reportsToChartOfAccountsCode = reportsToChartOfAccountsCode;
508: }
509:
510: /**
511: * @return Returns the reportsToFinancialObjectCode.
512: */
513: public String getReportsToFinancialObjectCode() {
514: return reportsToFinancialObjectCode;
515: }
516:
517: /**
518: * @param reportsToFinancialObjectCode The reportsToFinancialObjectCode to set.
519: */
520: public void setReportsToFinancialObjectCode(
521: String reportsToFinancialObjectCode) {
522: this .reportsToFinancialObjectCode = reportsToFinancialObjectCode;
523: }
524:
525: /**
526: * @return Returns the financialFederalFundedCode.
527: */
528: public String getFinancialFederalFundedCode() {
529: return financialFederalFundedCode;
530: }
531:
532: /**
533: * @param financialFederalFundedCode The financialFederalFundedCode to set.
534: */
535: public void setFinancialFederalFundedCode(
536: String financialFederalFundedCode) {
537: this .financialFederalFundedCode = financialFederalFundedCode;
538: }
539:
540: /**
541: * @return Returns the finObjMandatoryTrnfrelimCd.
542: */
543: public String getFinObjMandatoryTrnfrelimCd() {
544: return finObjMandatoryTrnfrelimCd;
545: }
546:
547: /**
548: * @param finObjMandatoryTrnfrelimCd The finObjMandatoryTrnfrelimCd to set.
549: */
550: public void setFinObjMandatoryTrnfrelimCd(
551: String finObjMandatoryTrnfrelimCd) {
552: this .finObjMandatoryTrnfrelimCd = finObjMandatoryTrnfrelimCd;
553: }
554:
555: public BudgetAggregationCode getFinancialBudgetAggregation() {
556: return financialBudgetAggregation;
557: }
558:
559: /**
560: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
561: */
562: protected LinkedHashMap toStringMapper() {
563:
564: LinkedHashMap m = new LinkedHashMap();
565: m.put("chartOfAccountsCode", this .chartOfAccountsCode);
566: m.put("financialObjectCode", this .financialObjectCode);
567:
568: return m;
569: }
570:
571: @Override
572: public void beforeUpdate(PersistenceBroker persistenceBroker)
573: throws PersistenceBrokerException {
574: super .beforeUpdate(persistenceBroker);
575: try {
576: // KULCOA-549: update the sufficient funds table
577: // get the current data from the database
578: BusinessObjectService boService = SpringContext
579: .getBean(BusinessObjectService.class);
580: ObjectCode originalObjectCode = (ObjectCode) boService
581: .retrieve(this );
582:
583: if (originalObjectCode != null) {
584: if (!originalObjectCode.getFinancialObjectLevelCode()
585: .equals(getFinancialObjectLevelCode())) {
586: SufficientFundRebuild sfr = new SufficientFundRebuild();
587: sfr
588: .setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
589: sfr.setChartOfAccountsCode(originalObjectCode
590: .getChartOfAccountsCode());
591: sfr
592: .setAccountNumberFinancialObjectCode(originalObjectCode
593: .getFinancialObjectLevelCode());
594: if (boService.retrieve(sfr) == null) {
595: persistenceBroker.store(sfr);
596: }
597: sfr = new SufficientFundRebuild();
598: sfr
599: .setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
600: sfr
601: .setChartOfAccountsCode(getChartOfAccountsCode());
602: sfr
603: .setAccountNumberFinancialObjectCode(getFinancialObjectLevelCode());
604: if (boService.retrieve(sfr) == null) {
605: persistenceBroker.store(sfr);
606: }
607: }
608: }
609: } catch (Exception ex) {
610: LOG
611: .error(
612: "Problem updating sufficient funds rebuild table: ",
613: ex);
614: }
615: }
616:
617: public boolean isActive() {
618: return this .financialObjectActiveCode;
619: }
620:
621: public void setActive(boolean a) {
622: this .financialObjectActiveCode = a;
623: }
624:
625: public void setCode(String code) {
626: this .chartOfAccountsCode = code;
627: }
628:
629: public void setName(String name) {
630: this .financialObjectCodeName = name;
631: }
632:
633: public String getCode() {
634: return this .financialObjectCode;
635: }
636:
637: public String getName() {
638: return this.financialObjectCodeName;
639: }
640:
641: }
|