1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.validation.impl;
17
18 import org.kuali.ole.sys.OLEConstants;
19 import org.kuali.ole.sys.OLEKeyConstants;
20 import org.kuali.ole.sys.OLEPropertyConstants;
21 import org.kuali.ole.sys.document.AccountingDocument;
22 import org.kuali.ole.sys.document.validation.GenericValidation;
23 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24 import org.kuali.rice.krad.util.GlobalVariables;
25 import org.kuali.rice.krad.util.MessageMap;
26
27 public class DisbursementVoucherAccountingLineCountValidation extends GenericValidation {
28 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DisbursementVoucherAccountingLineCountValidation.class);
29
30 private AccountingDocument accountingDocumentForValidation;
31
32
33
34
35 public boolean validate(AttributedDocumentEvent event) {
36 LOG.debug("validate start");
37 boolean isValid = true;
38
39 MessageMap errors = GlobalVariables.getMessageMap();
40 errors.addToErrorPath(OLEPropertyConstants.DOCUMENT);
41
42 if (accountingDocumentForValidation.getSourceAccountingLines().size() < 1) {
43 errors.putErrorWithoutFullErrorPath(OLEConstants.ACCOUNTING_LINE_ERRORS, OLEKeyConstants.ERROR_NO_ACCOUNTING_LINES);
44 isValid = false;
45 }
46
47 errors.removeFromErrorPath(OLEPropertyConstants.DOCUMENT);
48
49 return isValid;
50 }
51
52
53
54
55
56
57 public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
58 this.accountingDocumentForValidation = accountingDocumentForValidation;
59 }
60
61
62
63
64
65 public AccountingDocument getAccountingDocumentForValidation() {
66 return accountingDocumentForValidation;
67 }
68
69 }