1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.validation.impl;
17
18 import static org.kuali.ole.sys.document.validation.impl.AccountingDocumentRuleBaseConstants.ERROR_PATH.DOCUMENT_ERROR_PREFIX;
19
20 import org.kuali.ole.sys.OLEKeyConstants;
21 import org.kuali.ole.sys.OLEPropertyConstants;
22 import org.kuali.ole.sys.document.AccountingDocument;
23 import org.kuali.ole.sys.document.validation.GenericValidation;
24 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
25 import org.kuali.rice.krad.util.GlobalVariables;
26
27
28
29
30
31 public class OneSidedRequiredAccountingLinesCountValidation extends GenericValidation {
32 private AccountingDocument accountingDocumentForValidation;
33 private int requiredMinimumCount = 1;
34
35
36
37
38
39
40 public boolean validate(AttributedDocumentEvent event) {
41 if (getAccountingDocumentForValidation().getSourceAccountingLines().size() < getRequiredMinimumCount()) {
42 GlobalVariables.getMessageMap().putError(DOCUMENT_ERROR_PREFIX + OLEPropertyConstants.SOURCE_ACCOUNTING_LINES, OLEKeyConstants.ERROR_DOCUMENT_ACCOUNTING_LINES_NO_SINGLE_SECTION_ACCOUNTING_LINES);
43 return false;
44 }
45 return true;
46 }
47
48
49
50
51
52 public AccountingDocument getAccountingDocumentForValidation() {
53 return accountingDocumentForValidation;
54 }
55
56
57
58
59
60 public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
61 this.accountingDocumentForValidation = accountingDocumentForValidation;
62 }
63
64
65
66
67
68 public int getRequiredMinimumCount() {
69 return requiredMinimumCount;
70 }
71
72
73
74
75
76 public void setRequiredMinimumCount(int requiredCount) {
77 this.requiredMinimumCount = requiredCount;
78 }
79 }