org.kuali.rice.krad.datadictionary.validation.constraint
Class BaseConstraint

java.lang.Object
  extended by org.kuali.rice.krad.datadictionary.validation.constraint.BaseConstraint
All Implemented Interfaces:
Serializable, Constraint
Direct Known Subclasses:
CaseConstraint, MustOccurConstraint, PrerequisiteConstraint, SimpleConstraint, ValidCharactersConstraint

public class BaseConstraint
extends Object
implements Constraint

A class that implements the required accessor for label keys. This provides a convenient base class from which other constraints can be derived. Only BaseConstraints can have state validation. This class is a direct copy of one that was in Kuali Student.

Since:
1.1
Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
Serialized Form

Field Summary
protected  Boolean applyClientSide
           
protected  List<? extends BaseConstraint> constraintStateOverrides
           
protected  String labelKey
           
protected  List<String> states
           
protected  List<String> validationMessageParams
           
 
Constructor Summary
BaseConstraint()
           
 
Method Summary
 Boolean getApplyClientSide()
          If this is true, the constraint should be applied on the client side when the user interacts with a field - if this constraint can be interpreted for client side use.
 List<? extends BaseConstraint> getConstraintStateOverrides()
          Get the list of constraintStateOverrides which represent constraints that will replace THIS constraint when their state is matched during validation.
 String getLabelKey()
          LabelKey should be a single word key.
 List<String> getStates()
          A list of states to apply this constraint for, this will effect when a constraint is applied.
 List<String> getValidationMessageParams()
          Parameters to be used in the string retrieved by this constraint's labelKey, ordered by number of the param
 String[] getValidationMessageParamsArray()
          Parameters to be used in the string retrieved by this constraint's labelKey, ordered by number of the param
 void setApplyClientSide(Boolean applyClientSide)
           
 void setConstraintStateOverrides(List<? extends BaseConstraint> constraintStateOverrides)
          Set the constraintStateOverrides to be used when a state is matched during validation
 void setLabelKey(String labelKey)
           
 void setStates(List<String> states)
          Set the states for this contraint to be applied on
 void setValidationMessageParams(List<String> validationMessageParams)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

labelKey

protected String labelKey

applyClientSide

protected Boolean applyClientSide

validationMessageParams

protected List<String> validationMessageParams

states

protected List<String> states

constraintStateOverrides

protected List<? extends BaseConstraint> constraintStateOverrides
Constructor Detail

BaseConstraint

public BaseConstraint()
Method Detail

getLabelKey

public String getLabelKey()
LabelKey should be a single word key. This key is used to find a message to use for this constraint from available messages. The key is also used for defining/retrieving validation method names when applicable for ValidCharactersContraints. If a comma separated list of keys is used, a message will be generated that is a comma separated list of the messages retrieved for each key.

Returns:
See Also:
ValidCharactersConstraint

setLabelKey

public void setLabelKey(String labelKey)

getApplyClientSide

public Boolean getApplyClientSide()
If this is true, the constraint should be applied on the client side when the user interacts with a field - if this constraint can be interpreted for client side use. Default is true.

Returns:
the applyClientSide

setApplyClientSide

public void setApplyClientSide(Boolean applyClientSide)
Parameters:
applyClientSide - the applyClientSide to set

getValidationMessageParams

public List<String> getValidationMessageParams()
Parameters to be used in the string retrieved by this constraint's labelKey, ordered by number of the param

Returns:
the validationMessageParams

getValidationMessageParamsArray

public String[] getValidationMessageParamsArray()
Parameters to be used in the string retrieved by this constraint's labelKey, ordered by number of the param

Returns:
the validationMessageParams

setValidationMessageParams

public void setValidationMessageParams(List<String> validationMessageParams)
Parameters:
validationMessageParams - the validationMessageParams to set

getStates

public List<String> getStates()
A list of states to apply this constraint for, this will effect when a constraint is applied.

Each state this constraint is applied for needs to be declared with few additional options:

These can be mixed and matched, as appropriate, though states using a + symbol should always be the last item of a list (as they imply this state and everything else after).

Example state list may be: ["state1", "state3>state5", "state6+"]. In this example, note that this constraint is never applied to "state2" (assuming these example states represent a state order by number)

Returns:
the states to apply the constraint on, an empty list if the constraint is applied for all states

setStates

public void setStates(List<String> states)
Set the states for this contraint to be applied on

Parameters:
states -

getConstraintStateOverrides

public List<? extends BaseConstraint> getConstraintStateOverrides()
Get the list of constraintStateOverrides which represent constraints that will replace THIS constraint when their state is matched during validation. Because of this, constraints added to this list MUST have their states defined.

ConstraintStateOverrides always take precedence over this constraint if they apply to the state being evaluated during validation. These settings have no effect if there is no stateMapping represented on the entry/view being evaluated.

Returns:
List of constraint overrides for this constraint

setConstraintStateOverrides

public void setConstraintStateOverrides(List<? extends BaseConstraint> constraintStateOverrides)
Set the constraintStateOverrides to be used when a state is matched during validation

Parameters:
constraintStateOverrides -


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.