mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-10771: schema validation and differences rules
Laying some groundwork for the main code. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31921 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,10 +21,12 @@ package org.alfresco.util.schemacomp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.util.schemacomp.Result.Strength;
|
||||
import org.alfresco.util.schemacomp.Difference.Where;
|
||||
import org.alfresco.util.schemacomp.Result.Strength;
|
||||
import org.alfresco.util.schemacomp.model.DbObject;
|
||||
import org.alfresco.util.schemacomp.model.Schema;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.Predicate;
|
||||
|
||||
@@ -54,6 +56,18 @@ public class DefaultComparisonUtils implements ComparisonUtils
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<DbObject> findEquivalentObjects(Schema schema, DbObject objToMatch)
|
||||
{
|
||||
EquivalentObjectSeeker objectSeeker = new EquivalentObjectSeeker(objToMatch);
|
||||
schema.accept(objectSeeker);
|
||||
|
||||
return objectSeeker.getMatches();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void compareSimpleCollections(DbProperty leftProp,
|
||||
DbProperty rightProp, DiffContext ctx, Strength strength)
|
||||
@@ -235,4 +249,33 @@ public class DefaultComparisonUtils implements ComparisonUtils
|
||||
"Property value is a DbObject - this method shouldn't be used to compare this type: " + obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class EquivalentObjectSeeker implements DbObjectVisitor
|
||||
{
|
||||
private final List<DbObject> matches = new ArrayList<DbObject>();
|
||||
private final DbObject objToMatch;
|
||||
|
||||
public EquivalentObjectSeeker(DbObject objToMatch)
|
||||
{
|
||||
this.objToMatch = objToMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DbObject dbObject)
|
||||
{
|
||||
if (objToMatch.sameAs(dbObject))
|
||||
{
|
||||
matches.add(dbObject);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the matches
|
||||
*/
|
||||
public List<DbObject> getMatches()
|
||||
{
|
||||
return this.matches;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user