001 /* 002 * Copyright 2011 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 */ 016 package org.kuali.kfs.module.purap.document.validation.impl; 017 018 import org.kuali.kfs.coa.businessobject.ObjectCode; 019 import org.kuali.kfs.module.purap.PurapRuleConstants; 020 import org.kuali.kfs.module.purap.businessobject.PurApAccountingLine; 021 import org.kuali.kfs.module.purap.document.VendorCreditMemoDocument; 022 import org.kuali.kfs.sys.KFSPropertyConstants; 023 import org.kuali.kfs.sys.businessobject.SourceAccountingLine; 024 import org.kuali.kfs.sys.context.SpringContext; 025 import org.kuali.kfs.sys.document.validation.GenericValidation; 026 import org.kuali.kfs.sys.document.validation.event.AddAccountingLineEvent; 027 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent; 028 import org.kuali.rice.kns.service.ParameterEvaluator; 029 import org.kuali.rice.kns.service.ParameterService; 030 031 public class VendorCreditMemoObjectCodeValidation extends GenericValidation { 032 033 private ParameterService parameterService; 034 035 public boolean validate(AttributedDocumentEvent event) { 036 boolean valid = true; 037 PurApAccountingLine account = (PurApAccountingLine)((AddAccountingLineEvent)event).getAccountingLine(); 038 ObjectCode objectCode = account.getObjectCode(); 039 040 ParameterEvaluator parameterEvaluator = parameterService.getParameterEvaluator(VendorCreditMemoDocument.class, PurapRuleConstants.VALID_OBJECT_LEVELS_BY_OBJECT_TYPE_PARM_NM, PurapRuleConstants.INVALID_OBJECT_LEVELS_BY_OBJECT_TYPE_PARM_NM, objectCode.getFinancialObjectTypeCode(), objectCode.getFinancialObjectLevelCode()); 041 return parameterEvaluator.evaluateAndAddError(SourceAccountingLine.class, "objectCode.financialObjectLevelCode", KFSPropertyConstants.FINANCIAL_OBJECT_CODE); 042 } 043 044 public ParameterService getParameterService() { 045 return parameterService; 046 } 047 048 public void setParameterService(ParameterService parameterService) { 049 this.parameterService = parameterService; 050 } 051 052 }