001/* 002 * Copyright 2008-2009 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.ole.select.document.validation.impl; 017 018import org.kuali.ole.module.purap.businessobject.PurApAccountingLine; 019import org.kuali.ole.module.purap.businessobject.PurApItem; 020import org.kuali.ole.module.purap.document.validation.impl.*; 021import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent; 022import org.kuali.rice.krad.util.ObjectUtils; 023 024public class OlePurchasingAccountsPayableProcessAccountValidation extends 025 PurchasingAccountsPayableProcessAccountValidation { 026 027 private PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation; 028 private PurchasingAccountsPayableAccountPercentValidation accountPercentValidation; 029 private PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation; 030 private PurApItem itemForValidation; 031 private PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation; 032 private PurchasingAccountingLineAmountValidation accountLineAmountValidation; 033 private PurchasingAccountsPayableAccountTotalValidation accountTotalValidation; 034 035 @Override 036 public boolean validate(AttributedDocumentEvent event) { 037 boolean valid = true; 038 039 if (ObjectUtils.isNull(itemForValidation)) { 040 return valid; 041 } 042 043 hasAccountsValidation.setItemForValidation(itemForValidation); 044 valid &= hasAccountsValidation.validate(event); 045 046 if (valid) { 047 getAccountHasAtlestOnePercentValidation().setItemForValidation(itemForValidation); 048 valid &= getAccountHasAtlestOnePercentValidation().validate(event); 049 } 050 051 if (valid) { 052 for (PurApAccountingLine account : itemForValidation.getSourceAccountingLines()) { 053 getAccountLineAmountValidation().setUpdatedAccountingLine(account); 054 valid &= getAccountLineAmountValidation().validate(event); 055 if (!valid) { 056 break; 057 } 058 } 059 } 060 061 if (valid) { 062 accountPercentValidation.setItemForValidation(itemForValidation); 063 valid &= accountPercentValidation.validate(event); 064 } 065 066 if (valid) { 067 accountTotalValidation.setItemForValidation(itemForValidation); 068 valid &= accountTotalValidation.validate(event); 069 } 070 071 if (valid) { 072 accountingStringsValidation.setItemForValidation(itemForValidation); 073 valid &= accountingStringsValidation.validate(event); 074 } 075 076 return valid; 077 } 078 079 public PurchasingAccountsPayableHasAccountsValidation getHasAccountsValidation() { 080 return hasAccountsValidation; 081 } 082 083 public void setHasAccountsValidation(PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation) { 084 this.hasAccountsValidation = hasAccountsValidation; 085 } 086 087 public PurchasingAccountsPayableAccountPercentValidation getAccountPercentValidation() { 088 return accountPercentValidation; 089 } 090 091 public void setAccountPercentValidation(PurchasingAccountsPayableAccountPercentValidation accountPercentValidation) { 092 this.accountPercentValidation = accountPercentValidation; 093 } 094 095 public PurchasingAccountsPayableUniqueAccountingStringsValidation getAccountingStringsValidation() { 096 return accountingStringsValidation; 097 } 098 099 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}