001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.krad.datadictionary.validation.constraint;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import javax.xml.bind.annotation.XmlAccessType;
022 import javax.xml.bind.annotation.XmlAccessorType;
023 import javax.xml.bind.annotation.XmlElement;
024
025
026 /**
027 * A class that implements the required accessor for label keys. This provides a convenient base class
028 * from which other constraints can be derived.
029 *
030 * This class is a direct copy of one that was in Kuali Student.
031 *
032 * @author Kuali Rice Team (rice.collab@kuali.org)
033 * @since 1.1
034 */
035 @XmlAccessorType(XmlAccessType.FIELD)
036 public class BaseConstraint implements Constraint {
037 @XmlElement
038 protected String labelKey;
039 @XmlElement
040 protected Boolean applyClientSide;
041
042 List<String> validationMessageParams;
043
044 public BaseConstraint(){
045 applyClientSide = Boolean.valueOf(true);
046 }
047
048 /**
049 * LabelKey should be a single word key. This key is used to find a message to use for this
050 * constraint from available messages. The key is also used for defining/retrieving validation method
051 * names when applicable for ValidCharactersContraints.
052 *
053 * If a comma separated list of keys is used, a message will be generated that is a comma separated list of
054 * the messages retrieved for each key.
055 *
056 * @see ValidCharactersConstraint
057 *
058 * @return
059 */
060 public String getLabelKey() {
061 return labelKey;
062 }
063
064 public void setLabelKey(String labelKey) {
065 this.labelKey = labelKey;
066 }
067
068 /**
069 * If this is true, the constraint should be applied on the client side when the user interacts with
070 * a field - if this constraint can be interpreted for client side use. Default is true.
071 * @return the applyClientSide
072 */
073 public Boolean getApplyClientSide() {
074 return this.applyClientSide;
075 }
076
077 /**
078 * @param applyClientSide the applyClientSide to set
079 */
080 public void setApplyClientSide(Boolean applyClientSide) {
081 this.applyClientSide = applyClientSide;
082 }
083
084
085 /**
086 * Parameters to be used in the string retrieved by this constraint's labelKey, ordered by number of
087 * the param
088 * @return the validationMessageParams
089 */
090 public List<String> getValidationMessageParams() {
091 return this.validationMessageParams;
092 }
093
094 /**
095 * Parameters to be used in the string retrieved by this constraint's labelKey, ordered by number of
096 * the param
097 * @return the validationMessageParams
098 */
099 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 }