\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
import org.simantics.db.Statement;\r
+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
}\r
\r
\r
+ }\r
+ \r
+ public void test(Session session) throws DatabaseException {\r
+ \r
+ comparator.setComparator(this);\r
+ \r
+ final Stack<Resource> objectsLeft = new Stack<Resource>();\r
+ final Stack<Resource> objectsRight = new Stack<Resource>();\r
+ objectsLeft.push(r1);\r
+ objectsRight.push(r2);\r
+ \r
+ final Set<Statement> unreliableLeft = new HashSet<Statement>();\r
+ final Set<Statement> unreliableRight = new HashSet<Statement>();\r
+ \r
+ while (true) {\r
+ if (objectsLeft.isEmpty())\r
+ break;\r
+ session.syncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ g = graph;\r
+ b = Layer0.getInstance(graph);\r
+ // process compares objects that are identified and searches for more resources to process. \r
+ process(objectsLeft, objectsRight, unreliableLeft, unreliableRight);\r
+ // process unreliable handles cases where unidentified statements subject and object have been identified \r
+ processUnreliable(unreliableLeft, unreliableRight);\r
+ // process unreliable handles cases where unidentified resources have path of length one to identified resource\r
+ processUnreliable(unreliableLeft, unreliableRight,objectsLeft,objectsRight);\r
+ if (objectsLeft.isEmpty() && unreliableLeft.size() > 0 && unreliableRight.size() > 0) {\r
+ // comparison is ending, but we have still unprocessed unidentified resources left.\r
+ // These cases have longer path than one to identified objects.\r
+ processUnreliableDeep(unreliableLeft, unreliableRight, objectsLeft, objectsRight);\r
+ }\r
+ }\r
+ });\r
+ \r
+ \r
+ \r
+ }\r
+ for (Statement s : unreliableLeft) {\r
+ if (!comparableStatements.containsLeft(s))\r
+ addDeletion(s);\r
+ }\r
+ for (Statement s : unreliableRight) {\r
+ if (!comparableStatements.containsRight(s))\r
+ addAddition(s);\r
+ }\r
+ \r
+ \r
}\r
\r
private void process(Stack<Resource> objectsLeft, Stack<Resource> objectsRight, Set<Statement> unreliableLeft, Set<Statement> unreliableRight) throws DatabaseException {\r