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 org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.sys.businessobject.AccountingLine;
20 import org.kuali.ole.sys.document.AccountingDocument;
21 import org.kuali.ole.sys.document.validation.Validation;
22 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
23 import org.kuali.rice.krad.util.ObjectUtils;
24
25
26
27
28 public class AccountingLineCheckValidationHutch implements Validation {
29 protected Validation lineAmountValidation;
30 protected Validation lineCheckValidation;
31 protected Validation lineValuesAllowedValidation;
32
33 protected String accountingDocumentParameterPropertyName;
34 protected String accountingLineParameterPropertyName;
35
36 protected AccountingDocument accountingDocumentForValidation;
37 protected AccountingLine accountingLineForValidation;
38
39 protected boolean quitOnFail;
40
41
42
43
44 public boolean shouldQuitOnFail() {
45 return quitOnFail;
46 }
47
48
49
50
51
52 public void setShouldQuitOnFail(boolean b) {
53 quitOnFail = b;
54 }
55
56
57
58
59 public boolean stageValidation(AttributedDocumentEvent event) {
60 grabDocumentAndLineForValidationFromEvent(event);
61 updateValidationsWithParameters();
62 return validate(event);
63 }
64
65
66
67
68
69
70 protected void grabDocumentAndLineForValidationFromEvent(AttributedDocumentEvent event) {
71 if (StringUtils.isNotBlank(accountingDocumentParameterPropertyName)) {
72 accountingDocumentForValidation = (AccountingDocument)ObjectUtils.getPropertyValue(event, accountingDocumentParameterPropertyName);
73 }
74 if (StringUtils.isNotBlank(accountingLineParameterPropertyName)) {
75 accountingLineForValidation = (AccountingLine)ObjectUtils.getPropertyValue(event, accountingLineParameterPropertyName);
76 }
77 }
78
79
80
81
82 protected void updateValidationsWithParameters() {
83
84 }
85
86
87
88
89
90 public boolean validate(AttributedDocumentEvent event) {
91
92 return false;
93 }
94
95
96
97
98
99 public Validation getLineAmountValidation() {
100 return lineAmountValidation;
101 }
102
103
104
105
106
107 public void setLineAmountValidation(Validation lineAmountValidation) {
108 this.lineAmountValidation = lineAmountValidation;
109 }
110
111
112
113
114
115 public Validation getLineCheckValidation() {
116 return lineCheckValidation;
117 }
118
119
120
121
122
123 public void setLineCheckValidation(Validation lineCheckValidation) {
124 this.lineCheckValidation = lineCheckValidation;
125 }
126
127
128
129
130
131 public Validation getLineValuesAllowedValidation() {
132 return lineValuesAllowedValidation;
133 }
134
135
136
137
138
139 public void setLineValuesAllowedValidation(Validation lineValuesAllowedValidation) {
140 this.lineValuesAllowedValidation = lineValuesAllowedValidation;
141 }
142 }