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.PurapParameterConstants;
019 import org.kuali.kfs.module.purap.PurapRuleConstants;
020 import org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem;
021 import org.kuali.kfs.module.purap.document.PurchaseOrderDocument;
022 import org.kuali.kfs.sys.context.SpringContext;
023 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
024 import org.kuali.kfs.sys.service.impl.KfsParameterConstants;
025 import org.kuali.rice.kns.service.ParameterService;
026
027 public 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).getIndicatorParameter(KfsParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_COMMODITY_CODE_IND);
044 if (!enableCommodityCode) {
045 return false;
046 }
047 else {
048 return getParameterService().getIndicatorParameter(PurchaseOrderDocument.class, PurapRuleConstants.ITEMS_REQUIRE_COMMODITY_CODE_IND);
049 }
050 }
051 public PurchaseOrderEmptyItemWithAccountsValidation getEmptyItemsWithAccountsValidation() {
052 return emptyItemsWithAccountsValidation;
053 }
054
055 public void setEmptyItemsWithAccountsValidation(PurchaseOrderEmptyItemWithAccountsValidation emptyItemsWithAccountsValidation) {
056 this.emptyItemsWithAccountsValidation = emptyItemsWithAccountsValidation;
057 }
058
059 }