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.parse.BeanTag;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
21
22 import java.util.List;
23
24
25
26
27
28
29
30
31
32
33
34
35
36 @BeanTag(name = "caseConstriant-bean", parent = "CaseConstraint")
37 public class CaseConstraint extends BaseConstraint {
38
39 protected String propertyName;
40 protected String operator;
41 protected boolean caseSensitive;
42
43 protected List<WhenConstraint> whenConstraint;
44
45
46
47
48
49
50 @BeanTagAttribute(name = "whenConstraint", type = BeanTagAttribute.AttributeType.LISTBEAN)
51 public List<WhenConstraint> getWhenConstraint() {
52 return whenConstraint;
53 }
54
55
56
57
58
59
60 public void setWhenConstraint(List<WhenConstraint> whenConstraint) {
61 this.whenConstraint = whenConstraint;
62 }
63
64
65
66
67
68
69 @BeanTagAttribute(name = "propertyName")
70 public String getPropertyName() {
71 return propertyName;
72 }
73
74
75
76
77
78
79 public void setPropertyName(String propertyName) {
80 this.propertyName = propertyName;
81 }
82
83
84
85
86
87
88
89
90 @BeanTagAttribute(name = "operator")
91 public String getOperator() {
92 return operator;
93 }
94
95
96
97
98
99
100
101 public void setOperator(String operator) {
102 this.operator = operator;
103 }
104
105
106
107
108
109
110 @BeanTagAttribute(name = "caseSensitive")
111 public boolean isCaseSensitive() {
112 return caseSensitive;
113 }
114
115
116
117
118
119
120 public void setCaseSensitive(boolean caseSensitive) {
121 this.caseSensitive = caseSensitive;
122 }
123
124
125
126
127
128
129
130 @Override
131 public void completeValidation(ValidationTrace tracer) {
132 tracer.addBean("CaseConstraint", getMessageKey());
133
134 if (getWhenConstraint() == null) {
135 String currentValues[] = {"whenCaseConstraint = " + getWhenConstraint()};
136 tracer.createWarning("WhenCaseConstraints should at least have 1 item", currentValues);
137 } else {
138 if (getWhenConstraint().size() == 0) {
139 String currentValues[] = {"whenCaseConstraint.size() = " + getWhenConstraint().size()};
140 tracer.createError("WhenCaseConstraints should at least have 1 item", currentValues);
141 } else {
142 for (int i = 0; i < getWhenConstraint().size(); i++) {
143 getWhenConstraint().get(i).completeValidation(tracer.getCopy());
144 }
145 }
146 }
147 }
148 }