View Javadoc
1   /*
2    * Copyright 2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.fp.document.validation.impl;
17  
18  import org.kuali.ole.sys.OLEConstants;
19  import org.kuali.ole.sys.OLEKeyConstants;
20  import org.kuali.ole.sys.document.AccountingDocument;
21  import org.kuali.ole.sys.document.validation.GenericValidation;
22  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
23  import org.kuali.rice.krad.util.GlobalVariables;
24  
25  /**
26   * The Budget Adjustment's variation on the lines required for routing met validation - here, we just need
27   * to make sure that the total number of accounting lines on the document is greater than 0.
28   */
29  public class BudgetAdjustmentAccountingLinesRequiredForRoutingValidation extends GenericValidation {
30      private AccountingDocument accountingDocumentForValidation;
31  
32      /**
33       * The BA document does not have to have source accounting lines. In the case of setting up a budget for a new account, only targets
34       * line (increase section) are setup.
35       * @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
36       */
37      public boolean validate(AttributedDocumentEvent event) {
38          // check that both source and target are not empty, in which case is an error
39          if (getAccountingDocumentForValidation().getSourceAccountingLines().isEmpty() && getAccountingDocumentForValidation().getTargetAccountingLines().isEmpty()) {
40              GlobalVariables.getMessageMap().putError(OLEConstants.ACCOUNTING_LINE_ERRORS, OLEKeyConstants.ERROR_DOCUMENT_NO_ACCOUNTING_LINES);
41              return false;
42          }
43  
44          return true;
45      }
46  
47      /**
48       * Gets the accountingDocumentForValidation attribute. 
49       * @return Returns the accountingDocumentForValidation.
50       */
51      public AccountingDocument getAccountingDocumentForValidation() {
52          return accountingDocumentForValidation;
53      }
54  
55      /**
56       * Sets the accountingDocumentForValidation attribute value.
57       * @param accountingDocumentForValidation The accountingDocumentForValidation to set.
58       */
59      public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
60          this.accountingDocumentForValidation = accountingDocumentForValidation;
61      }
62  }