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.fp.document.CreditCardReceiptDocument;
19  import org.kuali.ole.sys.OLEKeyConstants;
20  import org.kuali.ole.sys.OLEPropertyConstants;
21  import org.kuali.ole.sys.document.AccountingDocument;
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 CreditCardReceiptMinimumCreditCardReceiptValidation extends GenericValidation {
30      private AccountingDocument 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          CreditCardReceiptDocument ccr = (CreditCardReceiptDocument)getAccountingDocumentForValidation();
37          if (ccr.getCreditCardReceipts().size() < requiredMinimumCount) {
38              GlobalVariables.getMessageMap().putError(OLEPropertyConstants.NEW_CREDIT_CARD_RECEIPT, OLEKeyConstants.CreditCardReceipt.ERROR_DOCUMENT_CREDIT_CARD_RECEIPT_REQ_NUMBER_RECEIPTS_NOT_MET);
39              return false;
40          }
41          return true;
42      }
43     
44      /**
45       * Gets the accountingDocumentForValidation attribute. 
46       * @return Returns the accountingDocumentForValidation.
47       */
48      public AccountingDocument getAccountingDocumentForValidation() {
49          return accountingDocumentForValidation;
50      }
51  
52      /**
53       * Sets the accountingDocumentForValidation attribute value.
54       * @param accountingDocumentForValidation The accountingDocumentForValidation to set.
55       */
56      public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
57          this.accountingDocumentForValidation = accountingDocumentForValidation;
58      }
59  
60      /**
61       * Gets the requiredMinimumCount attribute. 
62       * @return Returns the requiredMinimumCount.
63       */
64      public int getRequiredMinimumCount() {
65          return requiredMinimumCount;
66      }
67      /**
68       * Sets the requiredMinimumCount attribute value.
69       * @param requiredMinimumCount The requiredMinimumCount to set.
70       */
71      public void setRequiredMinimumCount(int requiredMinimumCount) {
72          this.requiredMinimumCount = requiredMinimumCount;
73      }
74  
75  }