1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation.constraint;
17
18 import org.kuali.rice.krad.datadictionary.validator.ErrorReport;
19 import org.kuali.rice.krad.datadictionary.validator.TracerToken;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class CaseConstraint extends BaseConstraint {
37
38 protected String propertyName;
39 protected String operator;
40 protected boolean caseSensitive;
41
42 protected List<WhenConstraint> whenConstraint;
43
44
45
46
47
48
49 public List<WhenConstraint> getWhenConstraint() {
50 return whenConstraint;
51 }
52
53
54
55
56
57
58 public void setWhenConstraint(List<WhenConstraint> whenConstraint) {
59 this.whenConstraint = whenConstraint;
60 }
61
62
63
64
65
66
67 public String getPropertyName() {
68 return propertyName;
69 }
70
71
72
73
74
75
76 public void setPropertyName(String propertyName) {
77 this.propertyName = propertyName;
78 }
79
80
81
82
83
84
85
86 public String getOperator() {
87 return operator;
88 }
89
90
91
92
93
94
95
96 public void setOperator(String operator) {
97 this.operator = operator;
98 }
99
100
101
102
103
104
105 public boolean isCaseSensitive() {
106 return caseSensitive;
107 }
108
109
110
111
112
113
114 public void setCaseSensitive(boolean caseSensitive) {
115 this.caseSensitive = caseSensitive;
116 }
117
118
119
120
121
122
123
124
125 @Override
126 public ArrayList<ErrorReport> completeValidation(TracerToken tracer){
127 ArrayList<ErrorReport> reports=new ArrayList<ErrorReport>();
128 tracer.addBean("CaseConstraint", getMessageKey());
129
130 if(getWhenConstraint()==null){
131 ErrorReport error = new ErrorReport(ErrorReport.ERROR);
132 error.setValidationFailed("WhenCaseConstraints should at least have 1 item");
133 error.setBeanLocation(tracer.getBeanLocation());
134 error.addCurrentValue("whenCaseConstraint = "+getWhenConstraint());
135 reports.add(error);
136 }else{
137 if(getWhenConstraint().size()==0){
138 ErrorReport error = new ErrorReport(ErrorReport.ERROR);
139 error.setValidationFailed("WhenCaseConstraints should at least have 1 item");
140 error.setBeanLocation(tracer.getBeanLocation());
141 error.addCurrentValue("whenCaseConstraint.size() = "+getWhenConstraint().size());
142 reports.add(error);
143 }else{
144 for(int i=0;i<getWhenConstraint().size();i++){
145 reports.addAll(getWhenConstraint().get(i).completeValidation(tracer.getCopy()));
146 }
147 }
148 }
149
150 reports.addAll(super.completeValidation(tracer.getCopy()));
151
152 return reports;
153 }
154 }