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.sys.document.validation.impl;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.ole.sys.businessobject.AccountingLine;
20  import org.kuali.ole.sys.document.AccountingDocument;
21  import org.kuali.ole.sys.document.validation.Validation;
22  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
23  import org.kuali.rice.krad.util.ObjectUtils;
24  
25  /**
26   * 
27   */
28  public class AccountingLineCheckValidationHutch implements Validation {
29      protected Validation lineAmountValidation;
30      protected Validation lineCheckValidation;
31      protected Validation lineValuesAllowedValidation;
32      
33      protected String accountingDocumentParameterPropertyName;
34      protected String accountingLineParameterPropertyName;
35      
36      protected AccountingDocument accountingDocumentForValidation;
37      protected AccountingLine accountingLineForValidation;
38      
39      protected boolean quitOnFail;
40  
41      /**
42       * @see org.kuali.ole.sys.document.validation.Validation#shouldQuitOnFail()
43       */
44      public boolean shouldQuitOnFail() {
45          return quitOnFail;
46      }
47      
48      /**
49       * Sets whether the validation hutch should quit on the failure of the entire validation case failing.
50       * @param b
51       */
52      public void setShouldQuitOnFail(boolean b) {
53          quitOnFail = b;
54      }
55  
56      /**
57       * @see org.kuali.ole.sys.document.validation.Validation#stageValidation(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
58       */
59      public boolean stageValidation(AttributedDocumentEvent event) {
60          grabDocumentAndLineForValidationFromEvent(event);
61          updateValidationsWithParameters();
62          return validate(event);
63      }
64      
65      /**
66       * Using the parameter property names set, finds the accounting document and accounting line to be validate
67       * from the property.
68       * @param event the event to take properties from
69       */
70      protected void grabDocumentAndLineForValidationFromEvent(AttributedDocumentEvent event) {
71          if (StringUtils.isNotBlank(accountingDocumentParameterPropertyName)) {
72              accountingDocumentForValidation = (AccountingDocument)ObjectUtils.getPropertyValue(event, accountingDocumentParameterPropertyName);
73          }
74          if (StringUtils.isNotBlank(accountingLineParameterPropertyName)) {
75              accountingLineForValidation = (AccountingLine)ObjectUtils.getPropertyValue(event, accountingLineParameterPropertyName);
76          }
77      }
78      
79      /**
80       * Updates the child validations with accounting document and accounting line information.
81       */
82      protected void updateValidationsWithParameters() {
83          
84      }
85  
86      /**
87       * 
88       * @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
89       */
90      public boolean validate(AttributedDocumentEvent event) {
91          // TODO Auto-generated method stub
92          return false;
93      }
94  
95      /**
96       * Gets the lineAmountValidation attribute. 
97       * @return Returns the lineAmountValidation.
98       */
99      public Validation getLineAmountValidation() {
100         return lineAmountValidation;
101     }
102 
103     /**
104      * Sets the lineAmountValidation attribute value.
105      * @param lineAmountValidation The lineAmountValidation to set.
106      */
107     public void setLineAmountValidation(Validation lineAmountValidation) {
108         this.lineAmountValidation = lineAmountValidation;
109     }
110 
111     /**
112      * Gets the lineCheckValidation attribute. 
113      * @return Returns the lineCheckValidation.
114      */
115     public Validation getLineCheckValidation() {
116         return lineCheckValidation;
117     }
118 
119     /**
120      * Sets the lineCheckValidation attribute value.
121      * @param lineCheckValidation The lineCheckValidation to set.
122      */
123     public void setLineCheckValidation(Validation lineCheckValidation) {
124         this.lineCheckValidation = lineCheckValidation;
125     }
126 
127     /**
128      * Gets the lineValuesAllowedValidation attribute. 
129      * @return Returns the lineValuesAllowedValidation.
130      */
131     public Validation getLineValuesAllowedValidation() {
132         return lineValuesAllowedValidation;
133     }
134 
135     /**
136      * Sets the lineValuesAllowedValidation attribute value.
137      * @param lineValuesAllowedValidation The lineValuesAllowedValidation to set.
138      */
139     public void setLineValuesAllowedValidation(Validation lineValuesAllowedValidation) {
140         this.lineValuesAllowedValidation = lineValuesAllowedValidation;
141     }
142 }