1 /**
2 * Copyright 2005-2012 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 java.util.ArrayList;
19 import java.util.List;
20
21 import javax.xml.bind.annotation.XmlAccessType;
22 import javax.xml.bind.annotation.XmlAccessorType;
23 import javax.xml.bind.annotation.XmlElement;
24
25
26 /**
27 * A class that implements the required accessor for label keys. This provides a convenient base class
28 * from which other constraints can be derived.
29 *
30 * This class is a direct copy of one that was in Kuali Student.
31 *
32 * @author Kuali Rice Team (rice.collab@kuali.org)
33 * @since 1.1
34 */
35 @XmlAccessorType(XmlAccessType.FIELD)
36 public class BaseConstraint implements Constraint {
37 @XmlElement
38 protected String labelKey;
39 @XmlElement
40 protected Boolean applyClientSide;
41
42 List<String> validationMessageParams;
43
44 public BaseConstraint(){
45 applyClientSide = Boolean.valueOf(true);
46 }
47
48 /**
49 * LabelKey should be a single word key. This key is used to find a message to use for this
50 * constraint from available messages. The key is also used for defining/retrieving validation method
51 * names when applicable for ValidCharactersContraints.
52 *
53 * If a comma separated list of keys is used, a message will be generated that is a comma separated list of
54 * the messages retrieved for each key.
55 *
56 * @see ValidCharactersConstraint
57 *
58 * @return
59 */
60 public String getLabelKey() {
61 return labelKey;
62 }
63
64 public void setLabelKey(String labelKey) {
65 this.labelKey = labelKey;
66 }
67
68 /**
69 * If this is true, the constraint should be applied on the client side when the user interacts with
70 * a field - if this constraint can be interpreted for client side use. Default is true.
71 * @return the applyClientSide
72 */
73 public Boolean getApplyClientSide() {
74 return this.applyClientSide;
75 }
76
77 /**
78 * @param applyClientSide the applyClientSide to set
79 */
80 public void setApplyClientSide(Boolean applyClientSide) {
81 this.applyClientSide = applyClientSide;
82 }
83
84
85 /**
86 * Parameters to be used in the string retrieved by this constraint's labelKey, ordered by number of
87 * the param
88 * @return the validationMessageParams
89 */
90 public List<String> getValidationMessageParams() {
91 return this.validationMessageParams;
92 }
93
94 /**
95 * Parameters to be used in the string retrieved by this constraint's labelKey, ordered by number of
96 * the param
97 * @return the validationMessageParams
98 */
99 public String[] getValidationMessageParamsArray() {
100 if(this.getValidationMessageParams() != null){
101 return this.getValidationMessageParams().toArray(new String[this.getValidationMessageParams().size()]);
102 }
103 else{
104 return null;
105 }
106
107 }
108
109 /**
110 * @param validationMessageParams the validationMessageParams to set
111 */
112 public void setValidationMessageParams(List<String> validationMessageParams) {
113 this.validationMessageParams = validationMessageParams;
114 }
115
116
117 }