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.OLEConstants.ACCOUNTING_LINE_ERRORS;
19 import static org.kuali.ole.sys.OLEKeyConstants.ERROR_DOCUMENT_OPTIONAL_ONE_SIDED_DOCUMENT_REQUIRED_NUMBER_OF_ACCOUNTING_LINES_NOT_MET;
20
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
26
27
28
29
30 public class OptionalOneSidedDocumentAccountingLinesCountValidation extends GenericValidation {
31 private AccountingDocument accountingDocumentForValidation;
32
33
34
35
36
37
38
39 public boolean validate(AttributedDocumentEvent event) {
40 int sourceSectionSize = getAccountingDocumentForValidation().getSourceAccountingLines().size();
41 int targetSectionSize = getAccountingDocumentForValidation().getTargetAccountingLines().size();
42
43 if ((sourceSectionSize == 0 && targetSectionSize < 2) || (targetSectionSize == 0 && sourceSectionSize < 2)) {
44 GlobalVariables.getMessageMap().putError(ACCOUNTING_LINE_ERRORS, ERROR_DOCUMENT_OPTIONAL_ONE_SIDED_DOCUMENT_REQUIRED_NUMBER_OF_ACCOUNTING_LINES_NOT_MET);
45
46 return false;
47 }
48
49 return true;
50 }
51
52
53
54
55
56 public AccountingDocument getAccountingDocumentForValidation() {
57 return accountingDocumentForValidation;
58 }
59
60
61
62
63
64 public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
65 this.accountingDocumentForValidation = accountingDocumentForValidation;
66 }
67
68
69 }