View Javadoc
1   /**
2    * Copyright 2005-2015 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 org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  /**
25   * Prerequisite constraints require that some other attribute be non-empty in order for the constraint to be valid.
26   * So, a 7-digit US phone number might have a prerequisite of an area code, or an address street2 might have a
27   * prerequisite that street1 is non-empty.
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   * @since 1.1
31   */
32  @BeanTag(name = "prerequisiteConstraint", parent = "PrerequisiteConstraint")
33  public class PrerequisiteConstraint extends BaseConstraint {
34      protected String propertyName;
35  
36      @BeanTagAttribute(name = "propertyName")
37      public String getPropertyName() {
38          return propertyName;
39      }
40  
41      public void setPropertyName(String propertyName) {
42          this.propertyName = propertyName;
43      }
44  
45      @Override
46      /**
47       * @see BaseConstraint#getValidationMessageParams()
48       * @return the validation message list if defined. If not defined,  return  the property name
49       */
50      public List<String> getValidationMessageParams() {
51          if (super.getValidationMessageParams() == null) {
52              ArrayList<String> params = new ArrayList<String>(1);
53              params.add(getPropertyName());
54              return params;
55          } else {
56              return super.getValidationMessageParams();
57          }
58      }
59  }