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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 @BeanTag(name = "mustOccurConstraint")
53 public class MustOccurConstraint extends BaseConstraint {
54
55 private List<PrerequisiteConstraint> prerequisiteConstraints;
56 private List<MustOccurConstraint> mustOccurConstraints;
57 private Integer min;
58 private Integer max;
59
60 @BeanTagAttribute(name = "prerequisiteConstraints", type = BeanTagAttribute.AttributeType.LISTBEAN)
61 public List<PrerequisiteConstraint> getPrerequisiteConstraints() {
62 return prerequisiteConstraints;
63 }
64
65 public void setPrerequisiteConstraints(List<PrerequisiteConstraint> prerequisiteConstraints) {
66 this.prerequisiteConstraints = prerequisiteConstraints;
67 }
68
69 @BeanTagAttribute(name = "mustOccurConstraints", type = BeanTagAttribute.AttributeType.LISTBEAN)
70 public List<MustOccurConstraint> getMustOccurConstraints() {
71 return mustOccurConstraints;
72 }
73
74 public void setMustOccurConstraints(List<MustOccurConstraint> occurs) {
75 this.mustOccurConstraints = occurs;
76 }
77
78 @BeanTagAttribute(name = "min")
79 public Integer getMin() {
80 return min;
81 }
82
83 public void setMin(Integer min) {
84 this.min = min;
85 }
86
87 @BeanTagAttribute(name = "max")
88 public Integer getMax() {
89 return max;
90 }
91
92 public void setMax(Integer max) {
93 this.max = max;
94 }
95
96
97
98
99
100
101
102 @Override
103 public void completeValidation(ValidationTrace tracer) {
104 tracer.addBean("MustOccurConstraint", getMessageKey());
105
106 if (getMax() <= 0) {
107 String currentValues[] = {"max =" + getMax()};
108 tracer.createWarning("Max must be greater than 0", currentValues);
109 }
110
111 if (getPrerequisiteConstraints() == null) {
112 String currentValues[] = {"prerequisiteConstraints =" + getPrerequisiteConstraints()};
113 tracer.createWarning("PrerequisiteConstraints cannot be null or empty", currentValues);
114 } else if (getPrerequisiteConstraints().size() == 0) {
115 String currentValues[] = {"prerequisiteConstraints.size =" + getPrerequisiteConstraints().size()};
116 tracer.createWarning("PrerequisiteConstraints cannot be null or empty", currentValues);
117 ;
118 } else {
119 for (int i = 0; i < getPrerequisiteConstraints().size(); i++) {
120 getPrerequisiteConstraints().get(i).completeValidation(tracer.getCopy());
121 }
122 }
123
124 if (getMustOccurConstraints() == null) {
125 String currentValues[] = {"mustOccurConstraints =" + getMustOccurConstraints()};
126 tracer.createWarning("MustOccurConstraints cannot be null or empty", currentValues);
127 } else if (getMustOccurConstraints().size() == 0) {
128 String currentValues[] = {"mustOccurConstraints.size =" + getMustOccurConstraints().size()};
129 tracer.createWarning("MustOccurConstraints cannot be null or empty", currentValues);
130 } else {
131 for (int i = 0; i < getMustOccurConstraints().size(); i++) {
132 getMustOccurConstraints().get(i).completeValidation(tracer.getCopy());
133 }
134 }
135
136 super.completeValidation(tracer.getCopy());
137 }
138 }