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.module.purap.businessobject.PurApItem; 019 import org.kuali.kfs.sys.context.SpringContext; 020 import org.kuali.kfs.sys.document.validation.GenericValidation; 021 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent; 022 import org.kuali.rice.kew.exception.WorkflowException; 023 import org.kuali.rice.kns.service.DataDictionaryService; 024 import org.kuali.rice.kns.service.ParameterService; 025 import org.kuali.rice.kns.workflow.service.KualiWorkflowInfo; 026 027 public class PurchasingAccountsPayableNewIndividualItemValidation extends GenericValidation { 028 029 private DataDictionaryService dataDictionaryService; 030 private ParameterService parameterService; 031 private PurApItem itemForValidation; 032 private PurchasingAccountsPayableBelowTheLineValuesValidation belowTheLineValuesValidation; 033 034 public boolean validate(AttributedDocumentEvent event) { 035 boolean valid = true; 036 if (itemForValidation.getItemType().isAdditionalChargeIndicator()) { 037 belowTheLineValuesValidation.setItemForValidation(itemForValidation); 038 valid &= belowTheLineValuesValidation.validate(event); 039 } 040 return valid; 041 } 042 043 protected String getDocumentTypeLabel(String documentTypeName) { 044 try { 045 return SpringContext.getBean(KualiWorkflowInfo.class).getDocType(documentTypeName).getDocTypeLabel(); 046 } 047 catch (WorkflowException e) { 048 throw new RuntimeException("Caught Exception trying to get Workflow Document Type", e); 049 } 050 } 051 public ParameterService getParameterService() { 052 return parameterService; 053 } 054 055 public void setParameterService(ParameterService parameterService) { 056 this.parameterService = parameterService; 057 } 058 059 public PurApItem getItemForValidation() { 060 return itemForValidation; 061 } 062 063 public void setItemForValidation(PurApItem itemForValidation) { 064 this.itemForValidation = itemForValidation; 065 } 066 067 public DataDictionaryService getDataDictionaryService() { 068 return dataDictionaryService; 069 } 070 071 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { 072 this.dataDictionaryService = dataDictionaryService; 073 } 074 075 public PurchasingAccountsPayableBelowTheLineValuesValidation getBelowTheLineValuesValidation() { 076 return belowTheLineValuesValidation; 077 } 078 079 public void setBelowTheLineValuesValidation(PurchasingAccountsPayableBelowTheLineValuesValidation belowTheLineValuesValidation) { 080 this.belowTheLineValuesValidation = belowTheLineValuesValidation; 081 } 082 083 084 }