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.OrganizationReversionGlobal;
21 import org.kuali.ole.coa.businessobject.OrganizationReversionGlobalDetail;
22 import org.kuali.ole.coa.businessobject.OrganizationReversionGlobalOrganization;
23 import org.kuali.rice.kns.document.MaintenanceDocument;
24 import org.kuali.rice.krad.util.ObjectUtils;
25
26
27
28
29
30 public class OrganizationReversionGlobalPreRules extends MaintenancePreRulesBase {
31 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OrganizationReversionGlobalPreRules.class);
32
33
34
35
36
37
38
39
40
41 @Override
42 public boolean doCustomPreRules(MaintenanceDocument maintenanceDocument) {
43 OrganizationReversionGlobal globalOrgReversion = (OrganizationReversionGlobal) maintenanceDocument.getNewMaintainableObject().getBusinessObject();
44 checkForContinuationAccounts(globalOrgReversion);
45 copyKeyAttributesToCollections(globalOrgReversion);
46 return true;
47 }
48
49
50
51
52
53
54 public void checkForContinuationAccounts(OrganizationReversionGlobal globalOrgReversion) {
55 if (!StringUtils.isBlank(globalOrgReversion.getBudgetReversionChartOfAccountsCode()) && !StringUtils.isBlank(globalOrgReversion.getBudgetReversionAccountNumber())) {
56 Account account = checkForContinuationAccount("Budget Reversion Account Number", globalOrgReversion.getBudgetReversionChartOfAccountsCode(), globalOrgReversion.getBudgetReversionAccountNumber(), "");
57 if (ObjectUtils.isNotNull(account)) {
58 globalOrgReversion.setBudgetReversionChartOfAccountsCode(account.getChartOfAccountsCode());
59 globalOrgReversion.setBudgetReversionAccountNumber(account.getAccountNumber());
60 }
61 }
62 if (!StringUtils.isBlank(globalOrgReversion.getCashReversionFinancialChartOfAccountsCode()) && !StringUtils.isBlank(globalOrgReversion.getBudgetReversionAccountNumber())) {
63 Account account = checkForContinuationAccount("Cash Reversion Account Number", globalOrgReversion.getCashReversionFinancialChartOfAccountsCode(), globalOrgReversion.getCashReversionAccountNumber(), "");
64 if (ObjectUtils.isNotNull(account)) {
65 globalOrgReversion.setCashReversionFinancialChartOfAccountsCode(account.getChartOfAccountsCode());
66 globalOrgReversion.setCashReversionAccountNumber(account.getAccountNumber());
67 }
68 }
69 }
70
71
72
73
74
75
76
77 public void copyKeyAttributesToCollections(OrganizationReversionGlobal globalOrgRev) {
78 for (OrganizationReversionGlobalDetail orgRevDetail : globalOrgRev.getOrganizationReversionGlobalDetails()) {
79 orgRevDetail.setDocumentNumber(globalOrgRev.getDocumentNumber());
80 }
81
82 for (OrganizationReversionGlobalOrganization orgRevOrg : globalOrgRev.getOrganizationReversionGlobalOrganizations()) {
83 orgRevOrg.setDocumentNumber(globalOrgRev.getDocumentNumber());
84 }
85 }
86
87 }