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