mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user