本文整理汇总了Java中org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint类的典型用法代码示例。如果您正苦于以下问题:Java PrerequisiteConstraint类的具体用法?Java PrerequisiteConstraint怎么用?Java PrerequisiteConstraint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrerequisiteConstraint类属于org.kuali.rice.krad.datadictionary.validation.constraint包,在下文中一共展示了PrerequisiteConstraint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ProcessorResult process(DictionaryValidationResult result, Object value, PrerequisiteConstraint constraint,
AttributeValueReader attributeValueReader) throws AttributeValidationException {
if (ValidationUtils.isNullOrEmpty(value)) {
return new ProcessorResult(result.addSkipped(attributeValueReader, CONSTRAINT_NAME));
}
ConstraintValidationResult constraintValidationResult = processPrerequisiteConstraint(constraint,
attributeValueReader);
if (constraint != null) {
if (StringUtils.isNotBlank(constraint.getMessageKey())) {
constraintValidationResult.setConstraintLabelKey(constraint.getMessageKey());
} else {
constraintValidationResult.setConstraintLabelKey(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + FALLBACK_KEY);
}
constraintValidationResult.setErrorParameters(constraint.getValidationMessageParamsArray());
}
result.addConstraintValidationResult(attributeValueReader, constraintValidationResult);
return new ProcessorResult(constraintValidationResult);
}
示例2: testCaseConstraintInvoked
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
@Test
public void testCaseConstraintInvoked() {
ProcessorResult processorResult = processRaw(noStateAddress, "country", countryIsUSACaseConstraint);
List<Constraint> constraints = processorResult.getConstraints();
Assert.assertNotNull(constraints);
Assert.assertEquals(1, constraints.size());
Constraint constraint = constraints.get(0);
Assert.assertTrue(constraint instanceof PrerequisiteConstraint);
PrerequisiteConstraint prerequisiteConstraint = (PrerequisiteConstraint)constraint;
Assert.assertEquals("state", prerequisiteConstraint.getPropertyName());
ConstraintValidationResult result = processorResult.getFirstConstraintValidationResult();
Assert.assertEquals(0, dictionaryValidationResult.getNumberOfWarnings());
Assert.assertEquals(0, dictionaryValidationResult.getNumberOfErrors());
Assert.assertEquals(ErrorLevel.OK, result.getStatus());
Assert.assertEquals(new CaseConstraintProcessor().getName(), result.getConstraintName());
}
示例3: process
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.datadictionary.validation.processor.ConstraintProcessor#process(DictionaryValidationResult,
* Object, org.kuali.rice.krad.datadictionary.validation.capability.Validatable,
* org.kuali.rice.krad.datadictionary.validation.AttributeValueReader)
*/
@Override
public ProcessorResult process(DictionaryValidationResult result, Object value, PrerequisiteConstraint constraint,
AttributeValueReader attributeValueReader) throws AttributeValidationException {
if (ValidationUtils.isNullOrEmpty(value)) {
return new ProcessorResult(result.addSkipped(attributeValueReader, CONSTRAINT_NAME));
}
ConstraintValidationResult constraintValidationResult = processPrerequisiteConstraint(constraint,
attributeValueReader);
if (constraint != null) {
if (StringUtils.isNotBlank(constraint.getMessageKey())) {
constraintValidationResult.setConstraintLabelKey(constraint.getMessageKey());
} else {
constraintValidationResult.setConstraintLabelKey(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + FALLBACK_KEY);
}
constraintValidationResult.setErrorParameters(constraint.getValidationMessageParamsArray());
}
result.addConstraintValidationResult(attributeValueReader, constraintValidationResult);
return new ProcessorResult(constraintValidationResult);
}
示例4: adjustPrerequisiteConstraintBinding
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* Adjust paths on the prerequisite constraint bindings
*
* @param prerequisiteConstraints
*/
protected void adjustPrerequisiteConstraintBinding(List<PrerequisiteConstraint> prerequisiteConstraints) {
if (prerequisiteConstraints != null) {
for (PrerequisiteConstraint prerequisiteConstraint : prerequisiteConstraints) {
String propertyName = getBindingInfo().getPropertyAdjustedBindingPath(
prerequisiteConstraint.getPropertyName());
prerequisiteConstraint.setPropertyName(propertyName);
}
}
}
示例5: processPrerequisiteConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* Processes a Prerequisite constraint that should be applied when the booleanStatement passed
* in evaluates to true.
*
* @param field input field
* @param constraint prerequisite constraint to process
* @param view active view
* @param booleanStatement the booleanstatement in js - should return true when the validation
* rule should be applied
*/
public static void processPrerequisiteConstraint(InputField field, PrerequisiteConstraint constraint, View view,
String booleanStatement) {
if (constraint != null && constraint.getApplyClientSide().booleanValue()) {
String dependsClass = "dependsOn-" + ScriptUtils.escapeName(constraint.getPropertyName());
String addClass = "jQuery('[name=\""
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "\"]').addClass('"
+ dependsClass
+ "');"
+
"jQuery('[name=\""
+ ScriptUtils.escapeName(constraint.getPropertyName())
+ "\"]').addClass('"
+ "dependsOn-"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "');";
addScriptToPage(view, field, addClass
+ getPrerequisiteStatement(field, view, constraint, booleanStatement)
+ getPostrequisiteStatement(field, constraint, booleanStatement));
//special requiredness indicator handling
String showIndicatorScript = "setupShowReqIndicatorCheck('" + ScriptUtils.escapeName(
field.getBindingInfo().getBindingPath()) + "', '" + ScriptUtils.escapeName(
constraint.getPropertyName()) + "', " + "function(){\nreturn (coerceValue('" + ScriptUtils
.escapeName(field.getBindingInfo().getBindingPath()) + "') && " + booleanStatement + ");});\n";
addScriptToPage(view, field, showIndicatorScript);
}
}
示例6: init
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的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>());
}
示例7: process
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
private ConstraintValidationResult process(Object object, String attributeName, PrerequisiteConstraint constraint) {
AttributeValueReader attributeValueReader = new DictionaryObjectAttributeValueReader(object, "org.kuali.rice.kns.datadictionary.validation.MockAddress", addressEntry);
attributeValueReader.setAttributeName(attributeName);
Object value = attributeValueReader.getValue();
return processor.process(dictionaryValidationResult, value, constraint, attributeValueReader).getFirstConstraintValidationResult();
}
示例8: processPrerequisiteConstraint
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* Processes a Prerequisite constraint that should be applied
* when the booleanStatement passed in evaluates to true.
*
* @param constraint prerequisiteConstraint
* @param view
* @param booleanStatement the booleanstatement in js - should return true when the
* validation rule should be applied
*/
public static void processPrerequisiteConstraint(InputField field, PrerequisiteConstraint constraint, View view,
String booleanStatement) {
if (constraint != null && constraint.getApplyClientSide().booleanValue()) {
String dependsClass = "dependsOn-" + ScriptUtils.escapeName(constraint.getPropertyName());
String addClass = "jQuery('[name=\""
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "\"]').addClass('"
+ dependsClass
+ "');"
+
"jQuery('[name=\""
+ ScriptUtils.escapeName(constraint.getPropertyName())
+ "\"]').addClass('"
+ "dependsOn-"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "');";
addScriptToPage(view, field, addClass
+ getPrerequisiteStatement(field, view, constraint, booleanStatement)
+ getPostrequisiteStatement(field, constraint, booleanStatement));
//special requiredness indicator handling
String showIndicatorScript = "setupShowReqIndicatorCheck('" + ScriptUtils.escapeName(
field.getBindingInfo().getBindingPath()) + "', '" + ScriptUtils.escapeName(
constraint.getPropertyName()) + "', " + "function(){\nreturn (coerceValue('" + ScriptUtils
.escapeName(field.getBindingInfo().getBindingPath()) + "') && " + booleanStatement + ");});\n";
addScriptToPage(view, field, showIndicatorScript);
}
}
示例9: getDependencyConstraints
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@BeanTagAttribute
public List<PrerequisiteConstraint> getDependencyConstraints() {
return this.dependencyConstraints;
}
示例10: setDependencyConstraints
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void setDependencyConstraints(List<PrerequisiteConstraint> dependencyConstraints) {
this.dependencyConstraints = dependencyConstraints;
}
示例11: getPrerequisiteConstraints
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<PrerequisiteConstraint> getPrerequisiteConstraints() {
return dependencyConstraints;
}
示例12: getPrerequisiteStatement
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* Creates the script necessary for executing a prerequisite rule in which this field occurs
* after the field specified in the prerequisite rule - since it requires a specific set of UI
* logic. Builds an if statement containing an addMethod jquery validator call. Adds a
* "dependsOn" css class to this field for the field specified.
*
* @param constraint prerequisiteConstraint
* @param booleanStatement the booleanstatement in js - should return true when the validation
* rule should be applied
* @return statement derived from the constraint
*/
private static String getPrerequisiteStatement(InputField field, View view, PrerequisiteConstraint constraint,
String booleanStatement) {
methodKey++;
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
String message = "";
if (StringUtils.isEmpty(constraint.getMessageKey())) {
message = messageService.getMessageText(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "prerequisite");
message = MessageStructureUtils.translateStringMessage(message);
} else {
message = generateMessageText(constraint.getMessageNamespaceCode(),
constraint.getMessageComponentCode(), constraint.getMessageKey(),
constraint.getValidationMessageParams());
}
if (StringUtils.isEmpty(message)) {
message = "prerequisite - No message";
} else {
Field requiredField = (Field) view.getViewIndex().getDataFieldByPath(constraint.getPropertyName());
if (requiredField != null && StringUtils.isNotEmpty(requiredField.getLabel())) {
message = MessageFormat.format(message, requiredField.getLabel());
} else {
String genericFieldLabel = messageService.getMessageText(GENERIC_FIELD_MSG_KEY);
message = MessageFormat.format(message, genericFieldLabel);
}
}
// field occurs before case
String methodName = "prConstraint-"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ methodKey;
String addClass = "jQuery('[name=\""
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "\"]').addClass('"
+ methodName
+ "');\n";
String method = "\njQuery.validator.addMethod(\"" + methodName + "\", function(value, element) {\n" +
" if(" + booleanStatement + "){ return ((this.optional(element) !== false) || (coerceValue('" + ScriptUtils
.escapeName(constraint.getPropertyName()) + "')));}else{return true;} " +
"}, \"" + message + "\");";
String ifStatement = "if(occursBefore('"
+ ScriptUtils.escapeName(constraint.getPropertyName())
+ "','"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+
"')){"
+ addClass
+ method
+ "}";
return ifStatement;
}
示例13: getPostrequisiteStatement
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* This method creates the script necessary for executing a prerequisite rule in which this
* field occurs before the field specified in the prerequisite rule - since it requires a
* specific set of UI logic. Builds an if statement containing an addMethod jquery validator
* call.
*
* @param constraint prerequisiteConstraint
* @param booleanStatement the booleanstatement in js - should return true when the validation
* rule should be applied
* @return statement derived from the constraint
*/
private static String getPostrequisiteStatement(InputField field, PrerequisiteConstraint constraint,
String booleanStatement) {
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
// field occurs after case
String message = "";
if (StringUtils.isEmpty(constraint.getMessageKey())) {
message = messageService.getMessageText(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "postrequisite");
message = MessageStructureUtils.translateStringMessage(message);
} else {
message = generateMessageText(constraint.getMessageNamespaceCode(), constraint.getMessageComponentCode(),
constraint.getMessageKey(), constraint.getValidationMessageParams());
}
if (StringUtils.isEmpty(constraint.getMessageKey())) {
if (StringUtils.isNotEmpty(field.getLabel())) {
message = MessageFormat.format(message, field.getLabel());
} else {
String genericFieldLabel = messageService.getMessageText(GENERIC_FIELD_MSG_KEY);
message = MessageFormat.format(message, genericFieldLabel);
}
}
String function = "function(element){\n" +
"return (coerceValue('"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "') && "
+ booleanStatement
+ ");}";
String postStatement = "\nelse if(occursBefore('"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "','"
+ ScriptUtils.escapeName(constraint.getPropertyName())
+
"')){\njQuery('[name=\""
+ ScriptUtils.escapeName(constraint.getPropertyName())
+
"\"]').rules(\"add\", { required: \n"
+ function
+ ", \nmessages: {\nrequired: \""
+ message
+ "\"}});}\n";
return postStatement;
}
示例14: ViewAttributeValueReader
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的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);
}
}
示例15: getPrerequisiteConstraints
import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<PrerequisiteConstraint> getPrerequisiteConstraints() {
return prerequisiteConstraints;
}