本文整理汇总了Java中org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint类的典型用法代码示例。如果您正苦于以下问题:Java CaseConstraint类的具体用法?Java CaseConstraint怎么用?Java CaseConstraint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CaseConstraint类属于org.kuali.rice.krad.datadictionary.validation.constraint包,在下文中一共展示了CaseConstraint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCaseConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* This method processes a single CaseConstraint. Internally it makes calls to
* processWhenConstraint for each WhenConstraint that exists in this constraint. It adds a
* "dependsOn" css class to this field for the field which the CaseConstraint references.
*
* @param field input field
* @param view active view
* @param constraint case constraint providing the field reference
* @param andedCase the boolean logic to be anded when determining if this case is satisfied
* (used for nested CaseConstraints)
* @param validationState validation state
* @param stateMapping state mapping
*/
public static void processCaseConstraint(InputField field, View view, CaseConstraint constraint, String andedCase,
String validationState, StateMapping stateMapping) {
if (constraint.getOperator() == null) {
constraint.setOperator("equals");
}
String operator = "==";
if (constraint.getOperator().equalsIgnoreCase("not_equals") || constraint.getOperator().equalsIgnoreCase(
"not_equal")) {
operator = "!=";
} else if (constraint.getOperator().equalsIgnoreCase("greater_than_equal")) {
operator = ">=";
} else if (constraint.getOperator().equalsIgnoreCase("less_than_equal")) {
operator = "<=";
} else if (constraint.getOperator().equalsIgnoreCase("greater_than")) {
operator = ">";
} else if (constraint.getOperator().equalsIgnoreCase("less_than")) {
operator = "<";
} else if (constraint.getOperator().equalsIgnoreCase("has_value")) {
operator = "";
}
// add more operator types here if more are supported later
field.getControl().addStyleClass("dependsOn-" + ScriptUtils.escapeName(constraint.getPropertyName()));
if (constraint.getWhenConstraint() != null && !constraint.getWhenConstraint().isEmpty()) {
//String fieldPath = field.getBindingInfo().getBindingObjectPath() + "." + constraint.getPropertyName();
String fieldPath = constraint.getPropertyName();
for (WhenConstraint wc : constraint.getWhenConstraint()) {
wc = ConstraintStateUtils.getApplicableConstraint(wc, validationState, stateMapping);
if (wc != null) {
processWhenConstraint(field, view, constraint, wc, ScriptUtils.escapeName(fieldPath), operator,
andedCase, validationState, stateMapping);
}
}
}
}
示例2: init
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
@Override
public void init() {
resolverMap = new HashMap<String, ConstraintResolver<AttributeDefinition>>();
resolverMap.put(SimpleConstraint.class.getName(), new SimpleConstraintResolver<AttributeDefinition>());
resolverMap.put(CaseConstraint.class.getName(), new CaseConstraintResolver<AttributeDefinition>());
resolverMap.put(DataTypeConstraint.class.getName(), new DefinitionConstraintResolver<AttributeDefinition>());
resolverMap.put(LengthConstraint.class.getName(), new DefinitionConstraintResolver<AttributeDefinition>());
resolverMap.put(ValidCharactersConstraint.class.getName(),
new ValidCharactersConstraintResolver<AttributeDefinition>());
resolverMap.put(PrerequisiteConstraint.class.getName(),
new PrerequisiteConstraintsResolver<AttributeDefinition>());
resolverMap.put(MustOccurConstraint.class.getName(), new MustOccurConstraintsResolver<AttributeDefinition>());
}
示例3: processCaseConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* This method processes a single CaseConstraint. Internally it makes calls
* to processWhenConstraint for each WhenConstraint that exists in this
* constraint. It adds a "dependsOn" css class to this field for the field
* which the CaseConstraint references.
*
* @param view
* @param andedCase the boolean logic to be anded when determining if this case is
* satisfied (used for nested CaseConstraints)
*/
public static void processCaseConstraint(InputField field, View view, CaseConstraint constraint, String andedCase,
String validationState, StateMapping stateMapping) {
if (constraint.getOperator() == null) {
constraint.setOperator("equals");
}
String operator = "==";
if (constraint.getOperator().equalsIgnoreCase("not_equals") || constraint.getOperator().equalsIgnoreCase(
"not_equal")) {
operator = "!=";
} else if (constraint.getOperator().equalsIgnoreCase("greater_than_equal")) {
operator = ">=";
} else if (constraint.getOperator().equalsIgnoreCase("less_than_equal")) {
operator = "<=";
} else if (constraint.getOperator().equalsIgnoreCase("greater_than")) {
operator = ">";
} else if (constraint.getOperator().equalsIgnoreCase("less_than")) {
operator = "<";
} else if (constraint.getOperator().equalsIgnoreCase("has_value")) {
operator = "";
}
// add more operator types here if more are supported later
field.getControl().addStyleClass("dependsOn-" + ScriptUtils.escapeName(constraint.getPropertyName()));
if (constraint.getWhenConstraint() != null && !constraint.getWhenConstraint().isEmpty()) {
//String fieldPath = field.getBindingInfo().getBindingObjectPath() + "." + constraint.getPropertyName();
String fieldPath = constraint.getPropertyName();
for (WhenConstraint wc : constraint.getWhenConstraint()) {
wc = ConstraintStateUtils.getApplicableConstraint(wc, validationState, stateMapping);
if (wc != null) {
processWhenConstraint(field, view, constraint, wc, ScriptUtils.escapeName(fieldPath), operator,
andedCase, validationState, stateMapping);
}
}
}
}
示例4: getCaseConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@BeanTagAttribute
public CaseConstraint getCaseConstraint() {
return this.caseConstraint;
}
示例5: setCaseConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void setCaseConstraint(CaseConstraint caseConstraint) {
this.caseConstraint = caseConstraint;
}
示例6: processWhenConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* This method processes the WhenConstraint passed in. The when constraint is used to create a
* boolean statement to determine if the constraint will be applied. The necessary rules/methods
* for applying this constraint are created in the createRule call. Note the use of the use of
* coerceValue js function call.
*
* @param view
* @param wc
* @param fieldPath
* @param operator
* @param andedCase
*/
private static void processWhenConstraint(InputField field, View view, CaseConstraint caseConstraint,
WhenConstraint wc, String fieldPath, String operator, String andedCase, String validationState,
StateMapping stateMapping) {
String ruleString = "";
// prerequisite constraint
String booleanStatement = "";
if (wc.getValues() != null) {
String caseStr = "";
if (!caseConstraint.isCaseSensitive()) {
caseStr = ".toUpperCase()";
}
for (int i = 0; i < wc.getValues().size(); i++) {
if (operator.isEmpty()) {
// has_value case
if (wc.getValues().get(i) instanceof String && ((String) wc.getValues().get(i)).equalsIgnoreCase(
"false")) {
booleanStatement = booleanStatement + "(coerceValue('" + fieldPath + "') == '')";
} else {
booleanStatement = booleanStatement + "(coerceValue('" + fieldPath + "') != '')";
}
} else {
// everything else
booleanStatement = booleanStatement
+ "(coerceValue('"
+ fieldPath
+ "')"
+ caseStr
+ " "
+ operator
+ " \""
+ wc.getValues().get(i)
+ "\""
+ caseStr
+ ")";
}
if ((i + 1) != wc.getValues().size()) {
booleanStatement = booleanStatement + " || ";
}
}
}
if (andedCase != null) {
booleanStatement = "(" + booleanStatement + ") && (" + andedCase + ")";
}
if (wc.getConstraint() != null && StringUtils.isNotEmpty(booleanStatement)) {
Constraint constraint = ConstraintStateUtils.getApplicableConstraint(wc.getConstraint(), validationState,
stateMapping);
if (constraint != null) {
ruleString = createRule(field, constraint, booleanStatement, view, validationState, stateMapping);
}
}
if (StringUtils.isNotEmpty(ruleString)) {
addScriptToPage(view, field, ruleString);
}
}
示例7: ViewAttributeValueReader
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* Constructor for ViewAttributeValueReader, the View must already be indexed and
* the InputFields must have already be initialized for this reader to work properly
*
* @param form model object representing the View's form data
*/
public ViewAttributeValueReader(ViewModel form) {
this.form = form;
ViewPostMetadata viewPostMetadata = form.getViewPostMetadata();
// Copying information stored about InputField in the post metadata to info objects for use by this reader
for (String id : viewPostMetadata.getInputFieldIds()) {
InputFieldConstrainableInfo info = new InputFieldConstrainableInfo();
Object label = viewPostMetadata.getComponentPostData(id, UifConstants.PostMetadata.LABEL);
if (label != null) {
info.setLabel((String) label);
}
Object name = viewPostMetadata.getComponentPostData(id, UifConstants.PostMetadata.PATH);
if (name != null) {
info.setName((String) name);
}
Object validCharactersConstraint = viewPostMetadata.getComponentPostData(id,
UifConstants.PostMetadata.VALID_CHARACTER_CONSTRAINT);
if (validCharactersConstraint != null) {
info.setValidCharactersConstraint((ValidCharactersConstraint) validCharactersConstraint);
}
Object caseConstraint = viewPostMetadata.getComponentPostData(id,
UifConstants.PostMetadata.CASE_CONSTRAINT);
if (caseConstraint != null) {
info.setCaseConstraint((CaseConstraint) caseConstraint);
}
Object prerequisiteConstraints = viewPostMetadata.getComponentPostData(id,
UifConstants.PostMetadata.PREREQ_CONSTSTRAINTS);
if (prerequisiteConstraints != null) {
info.setPrerequisiteConstraints((List<PrerequisiteConstraint>) prerequisiteConstraints);
}
Object mustOccurConstraints = viewPostMetadata.getComponentPostData(id,
UifConstants.PostMetadata.MUST_OCCUR_CONSTRAINTS);
if (mustOccurConstraints != null) {
info.setMustOccurConstraints((List<MustOccurConstraint>) mustOccurConstraints);
}
Object simpleConstraint = viewPostMetadata.getComponentPostData(id,
UifConstants.PostMetadata.SIMPLE_CONSTRAINT);
if (simpleConstraint != null) {
info.setSimpleConstraint((SimpleConstraint) simpleConstraint);
}
inputFields.add(info);
inputFieldMap.put(info.getName(), info);
}
}
示例8: getCaseConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public CaseConstraint getCaseConstraint() {
return caseConstraint;
}
示例9: setCaseConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.datadictionary.validation.ViewAttributeValueReader.InputFieldConstrainableInfo#getCaseConstraint()
*/
public void setCaseConstraint(CaseConstraint caseConstraint) {
this.caseConstraint = caseConstraint;
}
示例10: process
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.datadictionary.validation.processor.ConstraintProcessor#process(org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult,
* Object, org.kuali.rice.krad.datadictionary.validation.constraint.Constraint,
* org.kuali.rice.krad.datadictionary.validation.AttributeValueReader)
*/
@Override
public ProcessorResult process(DictionaryValidationResult result, Object value, CaseConstraint caseConstraint,
AttributeValueReader attributeValueReader) throws AttributeValidationException {
// Don't process this constraint if it's null
if (null == caseConstraint) {
return new ProcessorResult(result.addNoConstraint(attributeValueReader, CONSTRAINT_NAME));
}
AttributeValueReader constraintAttributeReader = attributeValueReader.clone();
String operator = (ValidationUtils.hasText(caseConstraint.getOperator())) ? caseConstraint.getOperator() :
"EQUALS";
AttributeValueReader fieldPathReader = (ValidationUtils.hasText(caseConstraint.getPropertyName())) ?
getChildAttributeValueReader(caseConstraint.getPropertyName(), attributeValueReader) :
attributeValueReader;
Constrainable caseField = (null != fieldPathReader) ? fieldPathReader.getDefinition(
fieldPathReader.getAttributeName()) : null;
Object fieldValue = (null != fieldPathReader) ? fieldPathReader.getValue(fieldPathReader.getAttributeName()) :
value;
DataType fieldDataType = (null != caseField && caseField instanceof DataTypeConstraint) ?
((DataTypeConstraint) caseField).getDataType() : null;
// Default to a string comparison
if (fieldDataType == null) {
fieldDataType = DataType.STRING;
}
// If fieldValue is null then skip Case check
if (null == fieldValue) {
// FIXME: not sure if the definition and attribute value reader should change under this case
return new ProcessorResult(result.addSkipped(attributeValueReader, CONSTRAINT_NAME), caseField,
fieldPathReader);
}
List<Constraint> constraints = new ArrayList<Constraint>();
// Extract value for field Key
for (WhenConstraint wc : caseConstraint.getWhenConstraint()) {
evaluateWhenConstraint(fieldValue, fieldDataType, operator, caseConstraint, wc, attributeValueReader,
constraints);
}
if (!constraints.isEmpty()) {
return new ProcessorResult(result.addSuccess(attributeValueReader, CONSTRAINT_NAME), null,
constraintAttributeReader, constraints);
}
// Assuming that not finding any case constraints is equivalent to 'skipping' the constraint
return new ProcessorResult(result.addSkipped(attributeValueReader, CONSTRAINT_NAME));
}
示例11: getConstraintType
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.datadictionary.validation.processor.ConstraintProcessor#getConstraintType()
*/
@Override
public Class<? extends Constraint> getConstraintType() {
return CaseConstraint.class;
}
示例12: getCaseConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* @return the caseConstraint
*/
@Override
@BeanTagAttribute(type = BeanTagAttribute.AttributeType.DIRECTORBYTYPE)
public CaseConstraint getCaseConstraint() {
return this.caseConstraint;
}
示例13: setCaseConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* @param caseConstraint the caseConstraint to set
*/
public void setCaseConstraint(CaseConstraint caseConstraint) {
this.caseConstraint = caseConstraint;
}
示例14: getCaseConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* The {@code CaseConstraint} that applies to this {@code InputField}
*
* @return the case constraint for this input field
*/
@Override
@BeanTagAttribute(name = "caseConstraint", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
public CaseConstraint getCaseConstraint() {
return this.caseConstraint;
}
示例15: processWhenConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; //导入依赖的package包/类
/**
* This method processes the WhenConstraint passed in. The when constraint
* is used to create a boolean statement to determine if the constraint will
* be applied. The necessary rules/methods for applying this constraint are
* created in the createRule call. Note the use of the use of coerceValue js
* function call.
*
* @param view
* @param wc
* @param fieldPath
* @param operator
* @param andedCase
*/
private static void processWhenConstraint(InputField field, View view, CaseConstraint caseConstraint,
WhenConstraint wc, String fieldPath, String operator, String andedCase, String validationState,
StateMapping stateMapping) {
String ruleString = "";
// prerequisite constraint
String booleanStatement = "";
if (wc.getValues() != null) {
String caseStr = "";
if (!caseConstraint.isCaseSensitive()) {
caseStr = ".toUpperCase()";
}
for (int i = 0; i < wc.getValues().size(); i++) {
if (operator.isEmpty()) {
// has_value case
if (wc.getValues().get(i) instanceof String && ((String) wc.getValues().get(i)).equalsIgnoreCase(
"false")) {
booleanStatement = booleanStatement + "(coerceValue('" + fieldPath + "') == '')";
} else {
booleanStatement = booleanStatement + "(coerceValue('" + fieldPath + "') != '')";
}
} else {
// everything else
booleanStatement = booleanStatement
+ "(coerceValue('"
+ fieldPath
+ "')"
+ caseStr
+ " "
+ operator
+ " \""
+ wc.getValues().get(i)
+ "\""
+ caseStr
+ ")";
}
if ((i + 1) != wc.getValues().size()) {
booleanStatement = booleanStatement + " || ";
}
}
}
if (andedCase != null) {
booleanStatement = "(" + booleanStatement + ") && (" + andedCase + ")";
}
if (wc.getConstraint() != null && StringUtils.isNotEmpty(booleanStatement)) {
Constraint constraint = ConstraintStateUtils.getApplicableConstraint(wc.getConstraint(), validationState,
stateMapping);
if (constraint != null) {
ruleString = createRule(field, constraint, booleanStatement, view, validationState, stateMapping);
}
}
if (StringUtils.isNotEmpty(ruleString)) {
addScriptToPage(view, field, ruleString);
}
}