import org.simantics.db.common.request.ReadRequest;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.DoesNotContainValueException;\r
-import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
-import org.simantics.db.exception.ServiceException;\r
-import org.simantics.db.exception.ValidationException;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.utils.datastructures.BijectionMap;\r
import org.simantics.utils.datastructures.MapList;\r
\r
comparator.setComparator(this);\r
\r
- comparableResources.map(r1, r2);\r
+ addComparable(r1, r2, false);\r
\r
final Stack<Resource> objectsLeft = new Stack<Resource>();\r
final Stack<Resource> objectsRight = new Stack<Resource>();\r
processedResources.add(r1);\r
\r
\r
- if(!comparableResources.contains(r1, r2) && (comparableResources.containsLeft(r1)||comparableResources.containsRight(r2))) {\r
+ if((comparableResources.containsLeft(r1)||comparableResources.containsRight(r2)) && !comparableResources.contains(r1, r2)) {\r
throw new DatabaseException("Comparator error: Trying to map " + r1 + " to " + r2 + " while mappings " + r1 + " to " + comparableResources.getRight(r1) + " and " + comparableResources.getLeft(r2) + " to " + r2 + " exist.");\r
}\r
+ addComparable(r1, r2, false);\r
\r
//System.out.println("test " + NameUtils.getSafeName(g, r1) + " " + NameUtils.getSafeName(g, r2));\r
compareProps(r1, r2);\r
ss1 = filterNonTested(ss1);\r
ss2 = filterNonTested(ss2);\r
\r
+ \r
compareStatements(ss1, ss2, null, null,null,null);\r
ss1.clear();\r
ss2.clear();\r
ss2.addAll(g.getStatements(r2, rel));\r
ss1 = filterAsserted(r1, ss1);\r
ss2 = filterAsserted(r2, ss2);\r
+ ss1 = filterNonTraversed(ss1);\r
+ ss2 = filterNonTraversed(ss2);\r
compareStatements(ss1, ss2, objectsLeft, objectsRight,unreliableLeft,unreliableRight);\r
ss1.clear();\r
ss2.clear();\r
return false;\r
BijectionMap<Path,Path> map = getMatchingPaths(leftPaths, rightPaths);\r
return map.size() == leftPaths.size();\r
- \r
}\r
\r
private BijectionMap<Path,Path> getMatchingPaths(Set<Path> leftPaths, Set<Path> rightPaths) {\r
return map;\r
}\r
\r
- private void expand(Set<Path> paths) throws ManyObjectsForFunctionalRelationException, ServiceException {\r
+ private void expand(Set<Path> paths) throws DatabaseException {\r
Set<Path> stepPathsLeft = new HashSet<Path>();\r
if (paths.size() == 0)\r
return;\r
}\r
}\r
\r
- private Collection<Path> findComparableRight(Path leftPath, Resource beginRight) throws ManyObjectsForFunctionalRelationException, ServiceException {\r
+ private Collection<Path> findComparableRight(Path leftPath, Resource beginRight) throws DatabaseException {\r
Set<Path> rightPaths = new HashSet<Path>();\r
rightPaths.addAll(Path.create(g.getStatements(beginRight, getRight(leftPath.getStatements().get(0).getPredicate()))));\r
for (int i = 1; i < leftPath.getLength(); i++) {\r
return comparableStatements;\r
}\r
\r
+ public BijectionMap<Resource, Resource> getComparableResources() {\r
+ return comparableResources;\r
+ }\r
+ \r
public GraphChanges getChanges() {\r
return new GraphChanges(r1,r2,changes1,changes2,modifications,comparableResources);\r
}\r
private void addComparable(Statement left, Statement right, boolean process) throws DatabaseException {\r
addComparable(left.getObject(), right.getObject(), process);\r
comparableStatements.map(left, right);\r
- comparableResources.map(left.getObject(), right.getObject());\r
+ //comparableResources.map(left.getObject(), right.getObject());\r
}\r
\r
private void addComparable(Resource left, Resource right, boolean process) throws DatabaseException {\r
- if(!comparableResources.contains(r1, r2)) {\r
- if (comparableResources.containsLeft(r1)||comparableResources.containsRight(r2)) {\r
- throw new DatabaseException("Comparator error: Trying to map " + r1 + " to " + r2 + " while mappings " + r1 + " to " + comparableResources.getRight(r1) + " and " + comparableResources.getLeft(r2) + " to " + r2 + " exist.");\r
+ if(!comparableResources.contains(left, right)) {\r
+ if (comparableResources.containsLeft(left)||comparableResources.containsRight(right)) {\r
+ throw new DatabaseException("Comparator error: Trying to map " + left + " to " + right + " while mappings " + left + " to " + comparableResources.getRight(left) + " and " + comparableResources.getLeft(right) + " to " + right + " exist.");\r
} else {\r
+ if (DEBUG) System.out.println(left + " = " + right);\r
comparableResources.map(left, right); \r
}\r
}\r
\r
}\r
\r
- public List<Statement> filterAsserted(Resource r, Collection<Statement> in) throws ServiceException {\r
+ public List<Statement> filterAsserted(Resource r, Collection<Statement> in) throws DatabaseException {\r
List<Statement> out = new ArrayList<Statement>();\r
for (Statement s : in) {\r
if (!s.isAsserted(r))\r
}\r
return out;\r
}\r
+ \r
+ \r
\r
- private String printStatement(ReadGraph graph, Statement s) throws ValidationException, ServiceException {\r
+ private String printStatement(ReadGraph graph, Statement s) throws DatabaseException {\r
return NameUtils.getSafeName(graph, s.getSubject()) + " " + NameUtils.getSafeName(graph, s.getPredicate()) + " " + NameUtils.getSafeName(graph, s.getObject());\r
}\r
\r
- private List<Statement> filterTraversed(List<Statement> in) throws ServiceException {\r
+ private List<Statement> filterTraversed(List<Statement> in) throws DatabaseException {\r
return filter(traversed, in);\r
}\r
\r
- private List<Statement> filterNonTested(List<Statement> in) throws ServiceException {\r
+ private List<Statement> filterNonTested(List<Statement> in) throws DatabaseException {\r
return filter(nonTested, in);\r
}\r
\r
- private List<Statement> filter(Collection<Resource> toFilter, List<Statement> in) throws ServiceException {\r
+ private List<Statement> filterNonTraversed(List<Statement> in) throws DatabaseException {\r
+ return filter(nonTraversed, in);\r
+ }\r
+ \r
+ private List<Statement> filter(Collection<Resource> toFilter, List<Statement> in) throws DatabaseException {\r
if (toFilter.size() == 0)\r
return in;\r
List<Statement> out = new ArrayList<Statement>();\r