View Javadoc
1   /*
2    * Copyright 2008 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.coa.businessobject.ObjectCode;
19  import org.kuali.ole.module.purap.PurapRuleConstants;
20  import org.kuali.ole.module.purap.businessobject.PurApAccountingLine;
21  import org.kuali.ole.module.purap.document.VendorCreditMemoDocument;
22  import org.kuali.ole.sys.OLEPropertyConstants;
23  import org.kuali.ole.sys.businessobject.SourceAccountingLine;
24  import org.kuali.ole.sys.context.SpringContext;
25  import org.kuali.ole.sys.document.validation.GenericValidation;
26  import org.kuali.ole.sys.document.validation.event.AddAccountingLineEvent;
27  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
28  import org.kuali.rice.core.api.parameter.ParameterEvaluator;
29  import org.kuali.rice.core.api.parameter.ParameterEvaluatorService;
30  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
31  
32  public class VendorCreditMemoObjectCodeValidation extends GenericValidation {
33  
34      private ParameterService parameterService;
35  
36      public boolean validate(AttributedDocumentEvent event) {
37          boolean valid = true;
38          PurApAccountingLine account = (PurApAccountingLine) ((AddAccountingLineEvent) event).getAccountingLine();
39          ObjectCode objectCode = account.getObjectCode();
40  
41          ParameterEvaluator parameterEvaluator = /*REFACTORME*/SpringContext.getBean(ParameterEvaluatorService.class).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());
42          return parameterEvaluator.evaluateAndAddError(SourceAccountingLine.class, "objectCode.financialObjectLevelCode", OLEPropertyConstants.FINANCIAL_OBJECT_CODE);
43      }
44  
45      public ParameterService getParameterService() {
46          return parameterService;
47      }
48  
49      public void setParameterService(ParameterService parameterService) {
50          this.parameterService = parameterService;
51      }
52  
53  }