mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ALF-7260: schema comparator
* replace path/push/pop mechanism as it doesn't work well at reporting where differences/validation errors occur. * add getParent() to DbObject - so that a path-style identifier can be deduced for a DbObject when needed * add DbProperty to specify a specific DbObject's property and value -- acts as a schema location pointer * refactored Result code (need difference result and validation error result) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31527 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,7 +22,9 @@ import org.alfresco.util.schemacomp.DiffContext;
|
||||
import org.alfresco.util.schemacomp.model.DbObject;
|
||||
|
||||
/**
|
||||
* TODO: comment me!
|
||||
* DbObject validators must implement this interface. DbValidator instances
|
||||
* are used by the ValidatingVisitor class.
|
||||
*
|
||||
* @author Matt Ward
|
||||
*/
|
||||
public interface DbValidator
|
||||
|
@@ -22,6 +22,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.alfresco.util.schemacomp.DbProperty;
|
||||
import org.alfresco.util.schemacomp.DiffContext;
|
||||
import org.alfresco.util.schemacomp.ValidationResult;
|
||||
import org.alfresco.util.schemacomp.model.DbObject;
|
||||
@@ -47,7 +48,7 @@ public class NameValidator implements DbValidator
|
||||
|
||||
Pattern pattern = namePatterns.get(ctx.getDialect().getClass());
|
||||
|
||||
ValidationResult result = new ValidationResult(name);
|
||||
ValidationResult result = new ValidationResult(new DbProperty(dbo, "name"));
|
||||
|
||||
if (pattern != null && !pattern.matcher(name).matches())
|
||||
{
|
||||
|
@@ -19,15 +19,16 @@
|
||||
package org.alfresco.util.schemacomp.validator;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.alfresco.util.schemacomp.DiffContext;
|
||||
import org.alfresco.util.schemacomp.Differences;
|
||||
import org.alfresco.util.schemacomp.Results;
|
||||
import org.alfresco.util.schemacomp.ValidationResult;
|
||||
import org.alfresco.util.schemacomp.model.DbObject;
|
||||
import org.alfresco.util.schemacomp.model.Index;
|
||||
@@ -36,8 +37,6 @@ import org.hibernate.dialect.Oracle10gDialect;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Tests for the NameValidator class.
|
||||
*
|
||||
@@ -54,7 +53,7 @@ public class NameValidatorTest
|
||||
{
|
||||
validator = new NameValidator();
|
||||
validationResults = new ArrayList<ValidationResult>();
|
||||
ctx = new DiffContext(new Oracle10gDialect(), new Differences(), validationResults);
|
||||
ctx = new DiffContext(new Oracle10gDialect(), new Results(), validationResults);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,6 +87,6 @@ public class NameValidatorTest
|
||||
|
||||
private DbObject indexForName(String name)
|
||||
{
|
||||
return new Index(name, new ArrayList<String>());
|
||||
return new Index(null, name, new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,8 @@ import org.alfresco.util.schemacomp.DiffContext;
|
||||
import org.alfresco.util.schemacomp.model.DbObject;
|
||||
|
||||
/**
|
||||
* TODO: comment me!
|
||||
* A 'do nothing' validator
|
||||
*
|
||||
* @author Matt Ward
|
||||
*/
|
||||
public class NullValidator implements DbValidator
|
||||
|
Reference in New Issue
Block a user