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 java.util.List;
19  
20  import org.kuali.ole.fp.document.PreEncumbranceDocument;
21  import org.kuali.ole.sys.OLEKeyConstants;
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  /**
27   * Validates that an accounting line does not have a capital object object code 
28   */
29  public class PreEncumbranceRequiredAccountingLinesCountValidation extends GenericValidation {
30      private PreEncumbranceDocument accountingDocumentForValidation;
31  
32      /**
33       * Validates that an accounting line does not have a capital object object code
34       * <strong>Expects an accounting line as the first a parameter</strong>
35       * @see org.kuali.ole.sys.document.validation.Validation#validate(java.lang.Object[])
36       */
37      public boolean validate(AttributedDocumentEvent event) {
38          List sourceAccountingLineList = this.accountingDocumentForValidation.getSourceAccountingLines();
39          List targetAccountingLineList = this.accountingDocumentForValidation.getTargetAccountingLines();
40          if (sourceAccountingLineList.size() == 0 && targetAccountingLineList.size() == 0 ) {
41              GlobalVariables.getMessageMap().putError("sourceAccountingLines", OLEKeyConstants.ERROR_DOCUMENT_PRE_ENCUMBRANCE_SINGLE_SECTION_NO_ACCOUNTING_LINES, new String[] { null });
42              return false;
43          }
44          
45          return true;
46      }
47      
48      /**
49       * Gets the accountingDocumentForValidation attribute. 
50       * @return Returns the accountingDocumentForValidation.
51       */
52      public PreEncumbranceDocument getAccountingDocumentForValidation() {
53          return accountingDocumentForValidation;
54      }
55  
56      /**
57       * Sets the accountingDocumentForValidation attribute value.
58       * @param accountingDocumentForValidation The accountingDocumentForValidation to set.
59       */
60      public void setAccountingDocumentForValidation(PreEncumbranceDocument accountingDocumentForValidation) {
61          this.accountingDocumentForValidation = accountingDocumentForValidation;
62      }
63  
64      
65     
66  }