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.module.purap.document.validation.impl; 017 018import org.kuali.ole.module.purap.PurapParameterConstants; 019import org.kuali.ole.module.purap.PurapRuleConstants; 020import org.kuali.ole.module.purap.businessobject.PurchaseOrderItem; 021import org.kuali.ole.module.purap.document.PurchaseOrderDocument; 022import org.kuali.ole.sys.context.SpringContext; 023import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent; 024import org.kuali.ole.sys.service.impl.OleParameterConstants; 025import org.kuali.rice.coreservice.framework.parameter.ParameterService; 026 027public class PurchaseOrderNewIndividualItemValidation extends PurchasingNewIndividualItemValidation { 028 029 PurchaseOrderEmptyItemWithAccountsValidation emptyItemsWithAccountsValidation; 030 031 public boolean validate(AttributedDocumentEvent event) { 032 boolean valid = super.validate(event); 033 emptyItemsWithAccountsValidation.setItemForValidation((PurchaseOrderItem) super.getItemForValidation()); 034 valid &= emptyItemsWithAccountsValidation.validate(event); 035 036 return valid; 037 } 038 039 @Override 040 protected boolean commodityCodeIsRequired() { 041 //if the ENABLE_COMMODITY_CODE_IND parameter is N then we don't 042 //need to check for the ITEMS_REQUIRE_COMMODITY_CODE_IND parameter anymore, just return false. 043 boolean enableCommodityCode = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(OleParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_COMMODITY_CODE_IND); 044 if (!enableCommodityCode) { 045 return false; 046 } else { 047 return getParameterService().getParameterValueAsBoolean(PurchaseOrderDocument.class, PurapRuleConstants.ITEMS_REQUIRE_COMMODITY_CODE_IND); 048 } 049 } 050 051 public PurchaseOrderEmptyItemWithAccountsValidation getEmptyItemsWithAccountsValidation() { 052 return emptyItemsWithAccountsValidation; 053 } 054 055 public void setEmptyItemsWithAccountsValidation(PurchaseOrderEmptyItemWithAccountsValidation emptyItemsWithAccountsValidation) { 056 this.emptyItemsWithAccountsValidation = emptyItemsWithAccountsValidation; 057 } 058 059}