ALF-10771: DiffContext is now passed around to provide the DB Dialect.

Instead of the Differences being passed around on their own, the DiffContext is able to provide more information -- at present just the Dialect. The dialect can be used to change the way database objects are validated or differenced.





git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31466 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2011-10-25 16:03:31 +00:00
parent 4ef52e4e72
commit 9b4cd0ab0e
23 changed files with 183 additions and 76 deletions

View File

@@ -19,6 +19,7 @@
package org.alfresco.util.schemacomp.model;
import org.alfresco.util.schemacomp.ComparisonUtils;
import org.alfresco.util.schemacomp.DiffContext;
import org.alfresco.util.schemacomp.Differences;
import org.alfresco.util.schemacomp.Result.Strength;
import org.alfresco.util.schemacomp.DefaultComparisonUtils;
@@ -154,8 +155,10 @@ public abstract class AbstractDbObject implements DbObject
* its diff correctly.
*/
@Override
public void diff(DbObject right, Differences differences, Strength strength)
public void diff(DbObject right, DiffContext ctx, Strength strength)
{
Differences differences = ctx.getDifferences();
if (name != null && StringUtils.hasText(name))
{
differences.pushPath(name);
@@ -164,10 +167,11 @@ public abstract class AbstractDbObject implements DbObject
{
differences.pushPath("<" + getClass().getSimpleName() + ">");
}
comparisonUtils.compareSimple(name, right.getName(), differences, getNameStrength());
doDiff(right, differences, strength);
comparisonUtils.compareSimple(name, right.getName(), ctx, getNameStrength());
doDiff(right, ctx, strength);
differences.popPath();
}
/**
* Override this method to provide subclass specific diffing logic.
@@ -176,9 +180,10 @@ public abstract class AbstractDbObject implements DbObject
* @param differences
* @param strength
*/
protected void doDiff(DbObject right, Differences differences, Strength strength)
protected void doDiff(DbObject right, DiffContext ctx, Strength strength)
{
}
/**
* If a ComparisonUtils other than the default is required, then this setter can be used.