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