1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.fp.document.validation.impl;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.ole.sys.OLEKeyConstants;
20  import org.kuali.ole.sys.OLEPropertyConstants;
21  import org.kuali.ole.sys.businessobject.AccountingLine;
22  import org.kuali.ole.sys.document.validation.GenericValidation;
23  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  
26  public class IndirectCostAdjustmentChartOfAccountsValidation extends GenericValidation {
27      protected AccountingLine accountingLineForValidation;
28      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(IndirectCostAdjustmentChartOfAccountsValidation.class);
29      
30      
31  
32  
33      public boolean validate(AttributedDocumentEvent event) {
34          boolean isValid = true;
35          AccountingLine accountingLine = getAccountingLineForValidation();
36  
37          if (accountingLine.isSourceAccountingLine()) {
38              String icrExpense = accountingLine.getChart().getIcrExpenseFinancialObjectCd();
39              isValid &= StringUtils.isNotBlank(icrExpense);
40              if (!isValid) {
41                  GlobalVariables.getMessageMap().putError(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, OLEKeyConstants.IndirectCostAdjustment.ERROR_DOCUMENT_ICA_GRANT_INVALID_CHART_OF_ACCOUNTS, accountingLine.getChartOfAccountsCode());
42                  if (LOG.isDebugEnabled()) {
43                      LOG.debug("rule failure: " + OLEKeyConstants.IndirectCostAdjustment.ERROR_DOCUMENT_ICA_GRANT_INVALID_CHART_OF_ACCOUNTS + " / " + accountingLine.getChartOfAccountsCode() );
44                  }
45              }
46          }
47          else {
48              String icrIncome = accountingLine.getChart().getIcrIncomeFinancialObjectCode();
49              isValid &= StringUtils.isNotBlank(icrIncome);
50              if (!isValid) {
51                  GlobalVariables.getMessageMap().putError(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, OLEKeyConstants.IndirectCostAdjustment.ERROR_DOCUMENT_ICA_RECEIPT_INVALID_CHART_OF_ACCOUNTS, accountingLine.getChartOfAccountsCode());
52                  if (LOG.isDebugEnabled()) {
53                      LOG.debug("rule failure: " + OLEKeyConstants.IndirectCostAdjustment.ERROR_DOCUMENT_ICA_RECEIPT_INVALID_CHART_OF_ACCOUNTS + " / " + accountingLine.getChartOfAccountsCode() );
54                  }
55              }
56          }
57  
58          return isValid;
59      }
60  
61      
62  
63  
64  
65      public AccountingLine getAccountingLineForValidation() {
66          return accountingLineForValidation;
67      }
68  
69      
70  
71  
72  
73      public void setAccountingLineForValidation(AccountingLine accountingLineForValidation) {
74          this.accountingLineForValidation = accountingLineForValidation;
75      }
76      
77  }