1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.coa.document.validation.impl;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.coa.businessobject.Account;
20 import org.kuali.ole.coa.businessobject.IndirectCostRecoveryRateDetail;
21 import org.kuali.ole.sys.OLEConstants;
22 import org.kuali.rice.kns.document.MaintenanceDocument;
23 import org.kuali.rice.krad.util.ObjectUtils;
24
25
26
27
28
29 public class IndirectCostRecoveryRateDetailPreRules extends MaintenancePreRulesBase {
30
31
32 protected IndirectCostRecoveryRateDetail indirectCostRecoveryRateDetail;
33
34
35 public IndirectCostRecoveryRateDetailPreRules() {
36
37 }
38
39
40
41
42
43
44
45
46
47
48 protected boolean doCustomPreRules(MaintenanceDocument document) {
49 setupConvenienceObjects(document);
50 checkForContinuationAccounts();
51
52 LOG.debug("done with continuation account, proceeeding with remaining pre rules");
53
54 setSubAccountToDashesIfBlank();
55 setSubObjectToDashesIfBlank();
56
57 return true;
58 }
59
60
61
62
63 protected void checkForContinuationAccounts() {
64 LOG.debug("entering checkForContinuationAccounts()");
65
66 if (StringUtils.isNotBlank(indirectCostRecoveryRateDetail.getAccountNumber())) {
67 Account account = checkForContinuationAccount("Account Number", indirectCostRecoveryRateDetail.getChartOfAccountsCode(), indirectCostRecoveryRateDetail.getAccountNumber(), "");
68 if (ObjectUtils.isNotNull(account)) {
69 indirectCostRecoveryRateDetail.setAccountNumber(account.getAccountNumber());
70 indirectCostRecoveryRateDetail.setChartOfAccountsCode(account.getChartOfAccountsCode());
71 }
72 }
73 }
74
75
76
77
78 protected void setSubAccountToDashesIfBlank() {
79 String newSubAccount = indirectCostRecoveryRateDetail.getSubAccountNumber();
80 if (StringUtils.isBlank(newSubAccount)) {
81 indirectCostRecoveryRateDetail.setSubAccountNumber(OLEConstants.getDashSubAccountNumber());
82 }
83 }
84
85
86
87
88 protected void setSubObjectToDashesIfBlank() {
89 String newSubObject = indirectCostRecoveryRateDetail.getFinancialSubObjectCode();
90 if (StringUtils.isBlank(newSubObject)) {
91 indirectCostRecoveryRateDetail.setFinancialSubObjectCode(OLEConstants.getDashFinancialSubObjectCode());
92 }
93 }
94
95
96
97
98
99
100 protected void setupConvenienceObjects(MaintenanceDocument document) {
101
102
103 indirectCostRecoveryRateDetail = (IndirectCostRecoveryRateDetail) document.getNewMaintainableObject().getBusinessObject();
104 }
105 }