View Javadoc
1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.purap.document.validation.impl;
17  
18  import org.kuali.ole.module.purap.PurapParameterConstants;
19  import org.kuali.ole.module.purap.PurapRuleConstants;
20  import org.kuali.ole.module.purap.businessobject.PurchaseOrderItem;
21  import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
22  import org.kuali.ole.sys.context.SpringContext;
23  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24  import org.kuali.ole.sys.service.impl.OleParameterConstants;
25  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
26  
27  public class PurchaseOrderNewIndividualItemValidation extends PurchasingNewIndividualItemValidation {
28  
29      PurchaseOrderEmptyItemWithAccountsValidation emptyItemsWithAccountsValidation;
30  
31      public boolean validate(AttributedDocumentEvent event) {
32          boolean valid = super.validate(event);
33          emptyItemsWithAccountsValidation.setItemForValidation((PurchaseOrderItem) super.getItemForValidation());
34          valid &= emptyItemsWithAccountsValidation.validate(event);
35  
36          return valid;
37      }
38  
39      @Override
40      protected boolean commodityCodeIsRequired() {
41          //if the ENABLE_COMMODITY_CODE_IND parameter is  N then we don't
42          //need to check for the ITEMS_REQUIRE_COMMODITY_CODE_IND parameter anymore, just return false. 
43          boolean enableCommodityCode = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(OleParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_COMMODITY_CODE_IND);
44          if (!enableCommodityCode) {
45              return false;
46          } else {
47              return getParameterService().getParameterValueAsBoolean(PurchaseOrderDocument.class, PurapRuleConstants.ITEMS_REQUIRE_COMMODITY_CODE_IND);
48          }
49      }
50  
51      public PurchaseOrderEmptyItemWithAccountsValidation getEmptyItemsWithAccountsValidation() {
52          return emptyItemsWithAccountsValidation;
53      }
54  
55      public void setEmptyItemsWithAccountsValidation(PurchaseOrderEmptyItemWithAccountsValidation emptyItemsWithAccountsValidation) {
56          this.emptyItemsWithAccountsValidation = emptyItemsWithAccountsValidation;
57      }
58  
59  }