001    /**
002     * Copyright 2005-2012 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 org.apache.commons.lang.StringUtils;
019    import org.kuali.rice.krad.uif.UifConstants;
020    
021    import javax.xml.bind.annotation.XmlAccessType;
022    import javax.xml.bind.annotation.XmlAccessorType;
023    import javax.xml.bind.annotation.XmlElement;
024    import java.util.ArrayList;
025    import java.util.List;
026    
027    /**
028     * Prerequisite constraints require that some other attribute be non-empty in order for the constraint to be valid. 
029     * So, a 7-digit US phone number might have a prerequisite of an area code, or an address street2 might have a prerequisite
030     * that street1 is non-empty. 
031     * 
032     * @author Kuali Rice Team (rice.collab@kuali.org)
033     * @since 1.1
034     */
035    @XmlAccessorType(XmlAccessType.FIELD)
036    public class PrerequisiteConstraint extends BaseConstraint {
037            @XmlElement
038        protected String propertyName;
039    
040            public String getPropertyName() {
041                    return propertyName;
042            }
043    
044            public void setPropertyName(String propertyName) {
045                    this.propertyName = propertyName;
046            }
047    
048        @Override
049        /**
050         * @see BaseConstraint#getValidationMessageParams()
051         * @return the validation message list if defined. If not defined,  return  the property name
052         */
053        public List<String> getValidationMessageParams() {
054            if(super.getValidationMessageParams() == null) {
055                ArrayList<String> params = new ArrayList<String>(1);
056                params.add(getPropertyName());
057                return params;
058            } else {
059                return super.getValidationMessageParams();
060            }
061        }
062    }