1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 = 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 }