1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
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.gl.businessobject.SufficientFundRebuild;
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.ole.sys.businessobject.FiscalYearBasedBusinessObject;
24  import org.kuali.ole.sys.businessobject.SystemOptions;
25  import org.kuali.ole.sys.context.SpringContext;
26  import org.kuali.rice.krad.bo.KualiCode;
27  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
28  import org.kuali.rice.krad.service.BusinessObjectService;
29  import org.kuali.rice.krad.service.impl.PersistenceStructureServiceImpl;
30  
31  
32  
33  
34  public class ObjectCode extends PersistableBusinessObjectBase implements KualiCode, FiscalYearBasedBusinessObject {
35  
36  
37      static {
38          PersistenceStructureServiceImpl.referenceConversionMap.put(ObjectCode.class, ObjectCodeCurrent.class);
39      }
40  
41      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ObjectCode.class);
42  
43      public static final String CACHE_NAME = OLEConstants.APPLICATION_NAMESPACE_CODE + "/" + "ObjectCode";
44      
45      private static final long serialVersionUID = -965833141452795485L;
46      protected Integer universityFiscalYear;
47      protected String chartOfAccountsCode;
48      protected String financialObjectCode;
49      protected String financialObjectCodeName;
50      protected String financialObjectCodeShortName;
51      protected String historicalFinancialObjectCode;
52      protected boolean active;
53      protected String financialObjectLevelCode;
54      protected String reportsToChartOfAccountsCode;
55      protected String reportsToFinancialObjectCode;
56      protected String financialObjectTypeCode;
57      protected String financialObjectSubTypeCode;
58      protected String financialBudgetAggregationCd;
59      protected String nextYearFinancialObjectCode;
60      protected String finObjMandatoryTrnfrelimCd;
61      protected String financialFederalFundedCode;
62          
63      protected transient BudgetAggregationCode financialBudgetAggregation;
64      protected transient MandatoryTransferEliminationCode finObjMandatoryTrnfrelim;
65      protected transient FederalFundedCode financialFederalFunded;
66      protected transient SystemOptions universityFiscal;
67      protected transient ObjectLevel financialObjectLevel;
68      protected transient Chart chartOfAccounts;
69      protected transient Chart reportsToChartOfAccounts;
70      protected transient ObjectCode reportsToFinancialObject;
71      protected transient ObjectType financialObjectType;
72      protected transient ObjectSubType financialObjectSubType;
73      
74      
75  
76  
77      public ObjectCode() {
78          
79          
80  
81          
82          this.financialObjectLevel = new ObjectLevel();
83          this.financialObjectType = new ObjectType();
84      }
85  
86      
87  
88  
89  
90  
91  
92  
93      public ObjectCode(Integer fiscalYear, String chart, String financialObjectCode) {
94          this.universityFiscalYear = fiscalYear;
95          this.chartOfAccountsCode = chart;
96          this.financialObjectCode = financialObjectCode;
97          this.active = true;
98      }
99  
100     
101 
102 
103     public void setUniversityFiscalYear(Integer i) {
104         this.universityFiscalYear = i;
105     }
106 
107     
108 
109 
110 
111 
112     public FederalFundedCode getFinancialFederalFunded() {
113         return financialFederalFunded;
114     }
115 
116     
117 
118 
119 
120 
121 
122     public void setFinancialFederalFunded(FederalFundedCode financialFederalFunded) {
123         this.financialFederalFunded = financialFederalFunded;
124     }
125 
126     
127 
128 
129 
130 
131     public MandatoryTransferEliminationCode getFinObjMandatoryTrnfrelim() {
132         return finObjMandatoryTrnfrelim;
133     }
134 
135 
136     
137 
138 
139 
140 
141 
142     public void setFinObjMandatoryTrnfrelim(MandatoryTransferEliminationCode finObjMandatoryTrnfrelim) {
143         this.finObjMandatoryTrnfrelim = finObjMandatoryTrnfrelim;
144     }
145 
146     
147 
148 
149 
150 
151     public String getFinancialObjectCode() {
152         return financialObjectCode;
153     }
154 
155     
156 
157 
158 
159 
160     public void setFinancialObjectCode(String financialObjectCode) {
161         this.financialObjectCode = financialObjectCode;
162     }
163 
164     
165 
166 
167 
168 
169     public String getFinancialObjectCodeName() {
170         return financialObjectCodeName;
171     }
172 
173     
174 
175 
176 
177 
178     public void setFinancialObjectCodeName(String financialObjectCodeName) {
179         this.financialObjectCodeName = financialObjectCodeName;
180     }
181 
182     
183 
184 
185 
186 
187     public String getFinancialObjectCodeShortName() {
188         return financialObjectCodeShortName;
189     }
190 
191     
192 
193 
194 
195 
196     public void setFinancialObjectCodeShortName(String financialObjectCodeShortName) {
197         this.financialObjectCodeShortName = financialObjectCodeShortName;
198     }
199 
200     
201 
202 
203 
204 
205     public String getHistoricalFinancialObjectCode() {
206         return historicalFinancialObjectCode;
207     }
208 
209     
210 
211 
212 
213 
214     public void setHistoricalFinancialObjectCode(String historicalFinancialObjectCode) {
215         this.historicalFinancialObjectCode = historicalFinancialObjectCode;
216     }
217 
218     
219 
220 
221 
222 
223     public boolean isFinancialObjectActiveCode() {
224         return active;
225     }
226 
227     
228 
229 
230 
231 
232     public void setFinancialObjectActiveCode(boolean active) {
233         this.active = active;
234     }
235 
236     
237 
238 
239 
240 
241     
242 
243 
244 
245     
246 
247 
248 
249 
250 
251     
252 
253 
254 
255 
256     
257 
258 
259 
260 
261     public SystemOptions getUniversityFiscal() {
262         return universityFiscal;
263     }
264 
265     
266 
267 
268 
269 
270 
271     public void setUniversityFiscal(SystemOptions universityFiscal) {
272         this.universityFiscal = universityFiscal;
273     }
274 
275     
276 
277 
278 
279 
280     public ObjectLevel getFinancialObjectLevel() {
281         return financialObjectLevel;
282     }
283 
284     
285 
286 
287 
288 
289 
290     public void setFinancialObjectLevel(ObjectLevel financialObjectLevel) {
291         this.financialObjectLevel = financialObjectLevel;
292     }
293 
294     
295 
296 
297 
298 
299     public Chart getChartOfAccounts() {
300         return chartOfAccounts;
301     }
302 
303     
304 
305 
306 
307 
308 
309     public void setChartOfAccounts(Chart chartOfAccounts) {
310         this.chartOfAccounts = chartOfAccounts;
311     }
312 
313     
314 
315 
316 
317 
318     public Chart getReportsToChartOfAccounts() {
319         return reportsToChartOfAccounts;
320     }
321 
322     
323 
324 
325 
326 
327 
328     public void setReportsToChartOfAccounts(Chart reportsToChartOfAccounts) {
329         this.reportsToChartOfAccounts = reportsToChartOfAccounts;
330     }
331 
332     
333 
334 
335 
336 
337     public ObjectCode getReportsToFinancialObject() {
338         return reportsToFinancialObject;
339     }
340 
341     
342 
343 
344 
345 
346 
347     public void setReportsToFinancialObject(ObjectCode reportsToFinancialObject) {
348         this.reportsToFinancialObject = reportsToFinancialObject;
349     }
350 
351     
352 
353 
354 
355 
356     public ObjectType getFinancialObjectType() {
357         return financialObjectType;
358     }
359 
360     
361 
362 
363 
364 
365 
366     public void setFinancialObjectType(ObjectType financialObjectType) {
367         this.financialObjectType = financialObjectType;
368     }
369 
370     
371 
372 
373 
374 
375     public ObjectSubType getFinancialObjectSubType() {
376         return financialObjectSubType;
377     }
378 
379     
380 
381 
382 
383 
384 
385     public void setFinancialObjectSubType(ObjectSubType financialObjectSubType) {
386         this.financialObjectSubType = financialObjectSubType;
387     }
388 
389     
390 
391     public void setChartOfAccountsCode(String string) {
392         this.chartOfAccountsCode = string;
393     }
394 
395     
396 
397 
398     public String getChartOfAccountsCode() {
399         return this.chartOfAccountsCode;
400     }
401 
402     
403 
404 
405     public Integer getUniversityFiscalYear() {
406         return this.universityFiscalYear;
407     }
408 
409     
410 
411 
412     public String getFinancialBudgetAggregationCd() {
413         return financialBudgetAggregationCd;
414     }
415 
416     
417 
418 
419     public void setFinancialBudgetAggregationCd(String financialBudgetAggregationCd) {
420         this.financialBudgetAggregationCd = financialBudgetAggregationCd;
421     }
422 
423     
424 
425 
426     public String getFinancialObjectLevelCode() {
427         return financialObjectLevelCode;
428     }
429 
430     
431 
432 
433     public void setFinancialObjectLevelCode(String financialObjectLevelCode) {
434         this.financialObjectLevelCode = financialObjectLevelCode;
435     }
436 
437     
438 
439 
440     public String getFinancialObjectSubTypeCode() {
441         return financialObjectSubTypeCode;
442     }
443 
444     
445 
446 
447     public void setFinancialObjectSubTypeCode(String financialObjectSubTypeCode) {
448         this.financialObjectSubTypeCode = financialObjectSubTypeCode;
449     }
450 
451     
452 
453 
454     public String getFinancialObjectTypeCode() {
455         return financialObjectTypeCode;
456     }
457 
458     
459 
460 
461     public void setFinancialObjectTypeCode(String financialObjectTypeCode) {
462         this.financialObjectTypeCode = financialObjectTypeCode;
463     }
464 
465     
466 
467 
468     public String getNextYearFinancialObjectCode() {
469         return nextYearFinancialObjectCode;
470     }
471 
472     
473 
474 
475     public void setNextYearFinancialObjectCode(String nextYearFinancialObjectCode) {
476         this.nextYearFinancialObjectCode = nextYearFinancialObjectCode;
477     }
478 
479     
480 
481 
482     public String getReportsToChartOfAccountsCode() {
483         return reportsToChartOfAccountsCode;
484     }
485 
486     
487 
488 
489     public void setReportsToChartOfAccountsCode(String reportsToChartOfAccountsCode) {
490         this.reportsToChartOfAccountsCode = reportsToChartOfAccountsCode;
491     }
492 
493     
494 
495 
496     public String getReportsToFinancialObjectCode() {
497         return reportsToFinancialObjectCode;
498     }
499 
500     
501 
502 
503     public void setReportsToFinancialObjectCode(String reportsToFinancialObjectCode) {
504         this.reportsToFinancialObjectCode = reportsToFinancialObjectCode;
505     }
506 
507     
508 
509 
510     public String getFinancialFederalFundedCode() {
511         return financialFederalFundedCode;
512     }
513 
514     
515 
516 
517     public void setFinancialFederalFundedCode(String financialFederalFundedCode) {
518         this.financialFederalFundedCode = financialFederalFundedCode;
519     }
520 
521     
522 
523 
524     public String getFinObjMandatoryTrnfrelimCd() {
525         return finObjMandatoryTrnfrelimCd;
526     }
527 
528     
529 
530 
531     public void setFinObjMandatoryTrnfrelimCd(String finObjMandatoryTrnfrelimCd) {
532         this.finObjMandatoryTrnfrelimCd = finObjMandatoryTrnfrelimCd;
533     }
534 
535     public BudgetAggregationCode getFinancialBudgetAggregation() {
536         return financialBudgetAggregation;
537     }
538 
539     public void setFinancialBudgetAggregation(BudgetAggregationCode financialBudgetAggregation) {
540         this.financialBudgetAggregation = financialBudgetAggregation;
541     }
542 
543     
544 
545 
546     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
547 
548         LinkedHashMap<String, String> m = new LinkedHashMap<String, String>();
549         m.put("chartOfAccountsCode", this.chartOfAccountsCode);
550         m.put("financialObjectCode", this.financialObjectCode);
551 
552         return m;
553     }
554 
555     protected static BusinessObjectService businessObjectService;
556     
557     protected BusinessObjectService getBusinessObjectService() {
558         if ( businessObjectService == null ) {
559             businessObjectService = SpringContext.getBean(BusinessObjectService.class);
560         }
561         return businessObjectService;
562     }
563     
564     @Override protected void preUpdate() {
565         
566         super.preUpdate();
567         try {
568             
569             
570             ObjectCode originalObjectCode = (ObjectCode) getBusinessObjectService().retrieve(this);
571 
572             if (originalObjectCode != null) {
573                 if (!originalObjectCode.getFinancialObjectLevelCode().equals(getFinancialObjectLevelCode())) {
574                     SufficientFundRebuild sfr = new SufficientFundRebuild();
575                     sfr.setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
576                     sfr.setChartOfAccountsCode(originalObjectCode.getChartOfAccountsCode());
577                     sfr.setAccountNumberFinancialObjectCode(originalObjectCode.getFinancialObjectLevelCode());
578                     if (getBusinessObjectService().retrieve(sfr) == null) {
579                         getBusinessObjectService().save(sfr);
580                     }
581                     sfr = new SufficientFundRebuild();
582                     sfr.setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
583                     sfr.setChartOfAccountsCode(getChartOfAccountsCode());
584                     sfr.setAccountNumberFinancialObjectCode(getFinancialObjectLevelCode());
585                     if (getBusinessObjectService().retrieve(sfr) == null) {
586                         getBusinessObjectService().save(sfr);
587                     }
588                 }
589             }
590         } catch (Exception ex) {
591             LOG.error("Problem updating sufficient funds rebuild table: ", ex);
592         }
593     }
594 
595     public boolean isActive() {
596         return this.active;
597     }
598 
599     public void setActive(boolean a) {
600         this.active = a;
601     }
602 
603     public void setCode(String code) {
604         this.chartOfAccountsCode = code;
605     }
606 
607     public void setName(String name) {
608         this.financialObjectCodeName = name;
609     }
610 
611     public String getCode() {
612         return this.financialObjectCode;
613     }
614 
615     public String getName() {
616         return this.financialObjectCodeName;
617     }
618 
619     
620 
621 
622 
623     public boolean isReportingToSelf() {
624         return StringUtils.equals(this.getChartOfAccountsCode(), this.getReportsToChartOfAccountsCode()) && StringUtils.equals(this.getFinancialObjectCode(), this.getReportsToFinancialObjectCode());
625     }
626 }