1 /**
2 * Copyright 2005-2011 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krad.datadictionary.validation.constraint;
17
18 import javax.xml.bind.annotation.XmlAccessType;
19 import javax.xml.bind.annotation.XmlAccessorType;
20 import javax.xml.bind.annotation.XmlElement;
21 import java.util.List;
22
23 /**
24 * Must occur constraints are constraints that indicate some range of acceptable valid results. So a must occur constraint
25 * might indicate that between 1 and 3 prequisite constraints must be valid. For example, on a person object, it might be
26 * that one of three fields must be filled in:
27 *
28 * 1. username
29 * 2. email
30 * 3. phone number
31 *
32 * By imposing a must occur constraint on the person object iself, and setting three prequisite constraints below it, with a min of 1
33 * and a max of 3, this requirement can be enforced.
34 *
35 * A more complicated example might be that a US address is only valid if it provides either:
36 * (a) a city and state, or
37 * (b) a postal code
38 *
39 * To enforce this, a single must occur constraint would have two children: (1) a prequisite constraint on postal code, and (2) a must occur constraint
40 * with two child prequisite constraints, on city and state, respectively. By setting min=1/max=2 at the top must occur constraint,
41 * and min=2/max=2 at the leaf constraint, this requirement can be enforced.
42 *
43 * @author Kuali Rice Team (rice.collab@kuali.org)
44 * @since 1.1
45 */
46 @XmlAccessorType(XmlAccessType.FIELD)
47 public class MustOccurConstraint extends BaseConstraint {
48
49 @XmlElement
50 private List<PrerequisiteConstraint> prerequisiteConstraints;
51 @XmlElement
52 private List<MustOccurConstraint> mustOccurConstraints;
53 @XmlElement
54 private Integer min;
55 @XmlElement
56 private Integer max;
57
58 public List<PrerequisiteConstraint> getPrerequisiteConstraints() {
59 return prerequisiteConstraints;
60 }
61
62 public void setPrerequisiteConstraints(List<PrerequisiteConstraint> prerequisiteConstraints) {
63 this.prerequisiteConstraints = prerequisiteConstraints;
64 }
65
66 public List<MustOccurConstraint> getMustOccurConstraints() {
67 return mustOccurConstraints;
68 }
69
70 public void setMustOccurConstraints(List<MustOccurConstraint> occurs) {
71 this.mustOccurConstraints = occurs;
72 }
73
74 public Integer getMin() {
75 return min;
76 }
77
78 public void setMin(Integer min) {
79 this.min = min;
80 }
81
82 public Integer getMax() {
83 return max;
84 }
85
86 public void setMax(Integer max) {
87 this.max = max;
88 }
89 }