Search in sources :

Example 16 with ValidationFailure

use of org.apache.cayenne.validation.ValidationFailure in project cayenne by apache.

the class ValidationResultBrowser method buildValidationText.

/**
 * Creates validation text for the validation result.
 */
protected String buildValidationText(ValidationResult validationResult) {
    StringBuffer buffer = new StringBuffer();
    String separator = System.getProperty("line.separator");
    for (ValidationFailure failure : validationResult.getFailures()) {
        if (buffer.length() > 0) {
            buffer.append(separator);
        }
        if (failure.getSource() != null) {
            buffer.append("[SQL: ").append(failure.getSource()).append("] - ");
        }
        if (failure.getDescription() != null) {
            buffer.append(failure.getDescription());
        }
    }
    return buffer.toString();
}
Also used : ValidationFailure(org.apache.cayenne.validation.ValidationFailure)

Example 17 with ValidationFailure

use of org.apache.cayenne.validation.ValidationFailure in project cayenne by apache.

the class CodeValidationUtil method validateJavaIdentifier.

public static ValidationFailure validateJavaIdentifier(Object bean, String attribute, String identifier) {
    ValidationFailure emptyFailure = BeanValidationFailure.validateNotEmpty(bean, attribute, identifier);
    if (emptyFailure != null) {
        return emptyFailure;
    }
    char c = identifier.charAt(0);
    if (!Character.isJavaIdentifierStart(c)) {
        return new BeanValidationFailure(bean, attribute, validationMessage(attribute, " starts with invalid character: " + c));
    }
    for (int i = 1; i < identifier.length(); i++) {
        c = identifier.charAt(i);
        if (!Character.isJavaIdentifierPart(c)) {
            return new BeanValidationFailure(bean, attribute, validationMessage(attribute, " contains invalid character: " + c));
        }
    }
    return null;
}
Also used : BeanValidationFailure(org.apache.cayenne.validation.BeanValidationFailure) BeanValidationFailure(org.apache.cayenne.validation.BeanValidationFailure) ValidationFailure(org.apache.cayenne.validation.ValidationFailure)

Aggregations

ValidationFailure (org.apache.cayenne.validation.ValidationFailure)17 BeanValidationFailure (org.apache.cayenne.validation.BeanValidationFailure)11 SimpleValidationFailure (org.apache.cayenne.validation.SimpleValidationFailure)7 ValidationResult (org.apache.cayenne.validation.ValidationResult)6 ObjEntity (org.apache.cayenne.map.ObjEntity)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 DbAttribute (org.apache.cayenne.map.DbAttribute)2 DbEntity (org.apache.cayenne.map.DbEntity)2 DbRelationship (org.apache.cayenne.map.DbRelationship)2 ProjectValidator (org.apache.cayenne.project.validation.ProjectValidator)2 Artist (org.apache.cayenne.testdo.testmap.Artist)2 File (java.io.File)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 MergerContext (org.apache.cayenne.dbsync.merge.context.MergerContext)1 MergerToken (org.apache.cayenne.dbsync.merge.token.MergerToken)1 ObjectNameGenerator (org.apache.cayenne.dbsync.naming.ObjectNameGenerator)1 ModelMergeDelegate (org.apache.cayenne.dbsync.reverse.dbload.ModelMergeDelegate)1