ALF-10771: adding validation to schema compare tool

Added support to DbObjects to accept visitors
Added ValidatingVisitor to invoke suitable validator on each DbObject
Added NameValidator and NullValidator to operate on DbObject types
Added test suites



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31494 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2011-10-26 16:01:38 +00:00
parent 7764900451
commit ec302df6ed
33 changed files with 896 additions and 30 deletions

View File

@@ -18,6 +18,9 @@
*/
package org.alfresco.util.schemacomp;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.util.schemacomp.Result.Strength;
import org.alfresco.util.schemacomp.model.Schema;
import org.hibernate.dialect.Dialect;
@@ -44,22 +47,51 @@ public class SchemaComparator
{
this.leftSchema = left;
this.rightSchema = right;
this.ctx = new DiffContext(dialect, new Differences());
this.ctx = new DiffContext(dialect, new Differences(), new ArrayList<ValidationResult>());
}
public void compare()
public void validateAndCompare()
{
validate();
compare();
}
/**
* Check the left schema against the right schema and record any differences.
*/
private void compare()
{
// Check the left schema against the right schema and record any differences.
leftSchema.diff(rightSchema, ctx, Strength.ERROR);
}
/**
* Validate both schemas.
*/
private void validate()
{
ValidatingVisitor validatingVisitor = new ValidatingVisitor(ctx);
leftSchema.accept(validatingVisitor);
rightSchema.accept(validatingVisitor);
}
/**
* @return the differences
*/
public Differences getDifferences()
{
return this.ctx.getDifferences();
return ctx.getDifferences();
}
/**
* @return the validation results.
*/
public List<ValidationResult> getValidationResults()
{
return ctx.getValidationResults();
}
}