View Javadoc
1   /*
2    * Copyright 2008-2009 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.module.purap.document.validation.impl;
17  
18  import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
19  import org.kuali.ole.module.purap.service.PurapAccountingLineRuleHelperService;
20  import org.kuali.ole.sys.businessobject.AccountingLine;
21  import org.kuali.ole.sys.document.validation.GenericValidation;
22  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
23  
24  /**
25   * A validation which uses the AccountingLineRuleHelperService to validate the values on an accounting line
26   */
27  public class PurapAccountingLineDataDictionaryValidation extends GenericValidation {
28      private PurapAccountingLineRuleHelperService ruleHelperService;
29      private AccountingLine accountingLineForValidation;
30  
31      /**
32       * Okay, okay, so yeah, I could have handled this through a bunch of DD validations.  But it's late Thursday afternoon
33       * and someone has already written this code for me...
34       * <strong>Expects an accounting line as the first parameter</strong>
35       *
36       * @see org.kuali.ole.sys.document.validation.Validation#validate(java.lang.Object[])
37       */
38      public boolean validate(AttributedDocumentEvent event) {
39          ruleHelperService.setDocument((PurchasingAccountsPayableDocument) event.getDocument());
40          return ruleHelperService.validateAccountingLine(accountingLineForValidation);
41      }
42  
43      /**
44       * Sets the ruleHelperService attribute value.
45       *
46       * @param ruleHelperService The ruleHelperService to set.
47       */
48      public void setAccountingLineRuleHelperService(PurapAccountingLineRuleHelperService ruleHelperService) {
49          this.ruleHelperService = ruleHelperService;
50      }
51  
52      /**
53       * Gets the accountingLineForValidation attribute.
54       *
55       * @return Returns the accountingLineForValidation.
56       */
57      public AccountingLine getAccountingLineForValidation() {
58          return accountingLineForValidation;
59      }
60  
61      /**
62       * Sets the accountingLineForValidation attribute value.
63       *
64       * @param accountingLineForValidation The accountingLineForValidation to set.
65       */
66      public void setAccountingLineForValidation(AccountingLine accountingLineForValidation) {
67          this.accountingLineForValidation = accountingLineForValidation;
68      }
69  }