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.select.document.validation.impl;
17  
18  import org.kuali.ole.module.purap.businessobject.PurApAccountingLine;
19  import org.kuali.ole.module.purap.businessobject.PurApItem;
20  import org.kuali.ole.module.purap.document.validation.impl.*;
21  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
22  import org.kuali.rice.krad.util.ObjectUtils;
23  
24  public class OlePurchasingAccountsPayableProcessAccountValidation extends
25          PurchasingAccountsPayableProcessAccountValidation {
26  
27      private PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation;
28      private PurchasingAccountsPayableAccountPercentValidation accountPercentValidation;
29      private PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation;
30      private PurApItem itemForValidation;
31      private PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation;
32      private PurchasingAccountingLineAmountValidation accountLineAmountValidation;
33      private PurchasingAccountsPayableAccountTotalValidation accountTotalValidation;
34  
35      @Override
36      public boolean validate(AttributedDocumentEvent event) {
37          boolean valid = true;
38  
39          if (ObjectUtils.isNull(itemForValidation)) {
40              return valid;
41          }
42  
43          hasAccountsValidation.setItemForValidation(itemForValidation);
44          valid &= hasAccountsValidation.validate(event);
45  
46          if (valid) {
47              getAccountHasAtlestOnePercentValidation().setItemForValidation(itemForValidation);
48              valid &= getAccountHasAtlestOnePercentValidation().validate(event);
49          }
50  
51          if (valid) {
52              for (PurApAccountingLine account : itemForValidation.getSourceAccountingLines()) {
53                  getAccountLineAmountValidation().setUpdatedAccountingLine(account);
54                  valid &= getAccountLineAmountValidation().validate(event);
55                  if (!valid) {
56                      break;
57                  }
58              }
59          }
60  
61          if (valid) {
62              accountPercentValidation.setItemForValidation(itemForValidation);
63              valid &= accountPercentValidation.validate(event);
64          }
65  
66          if (valid) {
67              accountTotalValidation.setItemForValidation(itemForValidation);
68              valid &= accountTotalValidation.validate(event);
69          }
70  
71          if (valid) {
72              accountingStringsValidation.setItemForValidation(itemForValidation);
73              valid &= accountingStringsValidation.validate(event);
74          }
75  
76          return valid;
77      }
78  
79      public PurchasingAccountsPayableHasAccountsValidation getHasAccountsValidation() {
80          return hasAccountsValidation;
81      }
82  
83      public void setHasAccountsValidation(PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation) {
84          this.hasAccountsValidation = hasAccountsValidation;
85      }
86  
87      public PurchasingAccountsPayableAccountPercentValidation getAccountPercentValidation() {
88          return accountPercentValidation;
89      }
90  
91      public void setAccountPercentValidation(PurchasingAccountsPayableAccountPercentValidation accountPercentValidation) {
92          this.accountPercentValidation = accountPercentValidation;
93      }
94  
95      public PurchasingAccountsPayableUniqueAccountingStringsValidation getAccountingStringsValidation() {
96          return accountingStringsValidation;
97      }
98  
99      public void setAccountingStringsValidation(PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation) {
100         this.accountingStringsValidation = accountingStringsValidation;
101     }
102 
103     public PurApItem getItemForValidation() {
104         return itemForValidation;
105     }
106 
107     public void setItemForValidation(PurApItem itemForValidation) {
108         this.itemForValidation = itemForValidation;
109     }
110 
111     /**
112      * @return Returns the accountHasAtleastOnePercentValidation
113      */
114 
115     public PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation getAccountHasAtlestOnePercentValidation() {
116         return accountHasAtleastOnePercentValidation;
117     }
118 
119     /**
120      * Sets the accountHasAtleastOnePercentValidation attribute.
121      *
122      * @param accountHasAtleastOnePercentValidation
123      *         The accountHasAtleastOnePercentValidation to set.
124      */
125     public void setAccountHasAtleastOnePercentValidation(PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation) {
126         this.accountHasAtleastOnePercentValidation = accountHasAtleastOnePercentValidation;
127     }
128 
129     /**
130      * Gets the accountLineAmountValidation attribute.
131      *
132      * @return Returns the accountLineAmountValidation
133      */
134 
135     public PurchasingAccountingLineAmountValidation getAccountLineAmountValidation() {
136         return accountLineAmountValidation;
137     }
138 
139     /**
140      * Sets the accountLineAmountValidation attribute.
141      *
142      * @param accountLineAmountValidation The accountLineAmountValidation to set.
143      */
144     public void setAccountLineAmountValidation(PurchasingAccountingLineAmountValidation accountLineAmountValidation) {
145         this.accountLineAmountValidation = accountLineAmountValidation;
146     }
147 
148     /**
149      * Gets the accountTotalValidation attribute.
150      *
151      * @return Returns the accountTotalValidation
152      */
153 
154     public PurchasingAccountsPayableAccountTotalValidation getAccountTotalValidation() {
155         return accountTotalValidation;
156     }
157 
158     /**
159      * Sets the accountTotalValidation attribute.
160      *
161      * @param accountTotalValidation The accountTotalValidation to set.
162      */
163     public void setAccountTotalValidation(PurchasingAccountsPayableAccountTotalValidation accountTotalValidation) {
164         this.accountTotalValidation = accountTotalValidation;
165     }
166 }