当前位置: 首页>>代码示例>>Java>>正文


Java CaseConstraint.getOperator方法代码示例

本文整理汇总了Java中org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint.getOperator方法的典型用法代码示例。如果您正苦于以下问题:Java CaseConstraint.getOperator方法的具体用法?Java CaseConstraint.getOperator怎么用?Java CaseConstraint.getOperator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint的用法示例。


在下文中一共展示了CaseConstraint.getOperator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
            }
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:51,代码来源:ClientValidationUtils.java

示例2: 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);
            }
        }
    }
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:48,代码来源:ClientValidationUtils.java

示例3: 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));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:55,代码来源:CaseConstraintProcessor.java


注:本文中的org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint.getOperator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。