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 static org.kuali.ole.sys.document.validation.impl.AccountingDocumentRuleBaseConstants.ERROR_PATH.DOCUMENT_ERROR_PREFIX;
19  
20  import org.kuali.ole.fp.document.AdvanceDepositDocument;
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   * This class...
28   */
29  public class AdvanceDepositMinimumAdvanceDepositValidation extends GenericValidation {
30      private AdvanceDepositDocument accountingDocumentForValidation;
31      private int requiredMinimumCount;
32      /**
33       * @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
34       */
35      public boolean validate(AttributedDocumentEvent event) {
36          AdvanceDepositDocument ad = getAccountingDocumentForValidation();
37          if (ad.getAdvanceDeposits().size() < requiredMinimumCount) {
38              GlobalVariables.getMessageMap().putError(DOCUMENT_ERROR_PREFIX, OLEKeyConstants.AdvanceDeposit.ERROR_DOCUMENT_ADVANCE_DEPOSIT_REQ_NUMBER_DEPOSITS_NOT_MET);
39              return false;
40          }
41          return true;
42      }
43      /**
44       * Gets the documentForValidation attribute. 
45       * @return Returns the documentForValidation.
46       */
47      public AdvanceDepositDocument getAccountingDocumentForValidation() {
48          return accountingDocumentForValidation;
49      }
50      /**
51       * Sets the documentForValidation attribute value.
52       * @param documentForValidation The documentForValidation to set.
53       */
54      public void setAccountingDocumentForValidation(AdvanceDepositDocument accountingDocumentForValidation) {
55          this.accountingDocumentForValidation = accountingDocumentForValidation;
56      }
57      /**
58       * Gets the requiredMinimumCount attribute. 
59       * @return Returns the requiredMinimumCount.
60       */
61      public int getRequiredMinimumCount() {
62          return requiredMinimumCount;
63      }
64      /**
65       * Sets the requiredMinimumCount attribute value.
66       * @param requiredMinimumCount The requiredMinimumCount to set.
67       */
68      public void setRequiredMinimumCount(int requiredMinimumCount) {
69          this.requiredMinimumCount = requiredMinimumCount;
70      }
71  
72  }