Updates to data dictionary constraints

- Added getType and getParameters methods to Constraint interface
  - Updated existing constraint implementations
Updates to FormService
  - Implemented regex pattern match for selecting appropriate form processor
  - Added constraints to Form object constructed in NodeHandler

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12396 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2008-12-15 21:18:51 +00:00
parent 6bda204c4d
commit e04da90fac
14 changed files with 257 additions and 30 deletions

View File

@@ -24,6 +24,9 @@
*/
package org.alfresco.repo.dictionary.constraint;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.service.cmr.dictionary.ConstraintException;
import org.alfresco.service.cmr.dictionary.DictionaryException;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
@@ -49,6 +52,15 @@ public class NumericRangeConstraint extends AbstractConstraint
private double minValue = Double.MIN_VALUE;
private double maxValue = Double.MAX_VALUE;
/*
* @see org.alfresco.service.cmr.dictionary.Constraint#getType()
*/
@Override
public String getType()
{
return "MINMAX";
}
@Override
public String toString()
@@ -107,10 +119,16 @@ public class NumericRangeConstraint extends AbstractConstraint
this.maxValue = maxValue;
}
/*
* @see org.alfresco.service.cmr.dictionary.Constraint#initialize()
*/
public void initialize()
{
}
/*
* @see org.alfresco.repo.dictionary.constraint.AbstractConstraint#evaluateSingleValue(java.lang.Object)
*/
protected void evaluateSingleValue(Object value)
{
// ensure that the value can be converted to a double
@@ -136,4 +154,17 @@ public class NumericRangeConstraint extends AbstractConstraint
throw new ConstraintException(ERR_OUT_OF_RANGE, checkValue, minValue, maxValue);
}
}
/*
* @see org.alfresco.service.cmr.dictionary.Constraint#getParameters()
*/
public Map<String, Object> getParameters()
{
Map<String, Object> params = new HashMap<String, Object>(2);
params.put("minValue", this.minValue);
params.put("maxValue", this.maxValue);
return params;
}
}