X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop%2Fsrc%2Forg%2Fsimantics%2Finterop%2Ftest%2FGraphChanges.java;h=f9065070fe095f8e3c247c12bf03011f8db811cd;hb=a43434a612fa0aafd0d4f17ebed2b770c4b1d585;hp=e52ad97924aff74d121ad27d6453fca44393f73d;hpb=d990eb34629f49c2c3fe6ecb9819d5c44ae19303;p=simantics%2Finterop.git diff --git a/org.simantics.interop/src/org/simantics/interop/test/GraphChanges.java b/org.simantics.interop/src/org/simantics/interop/test/GraphChanges.java index e52ad97..f906507 100644 --- a/org.simantics.interop/src/org/simantics/interop/test/GraphChanges.java +++ b/org.simantics.interop/src/org/simantics/interop/test/GraphChanges.java @@ -47,11 +47,11 @@ public class GraphChanges { } public boolean isLeftAsserted() { - return !leftSub.equals(leftStm.getSubject()); + return leftStm != null && !leftSub.equals(leftStm.getSubject()); } public boolean isRightAsserted() { - return !rightSub.equals(rightStm.getSubject()); + return rightStm != null && !rightSub.equals(rightStm.getSubject()); } public Resource getLeftSub() { @@ -301,49 +301,54 @@ public class GraphChanges { Statement del = mod.leftStm; Resource sub1 = mod.getLeftSub(); Resource sub2 = bijection.getComparable().getRight(sub1); - if (sub2 == null) { - throw new DatabaseException("Did not find matching resource from bijection for " + sub1); - } - Resource s1 = del.getSubject(); - Resource s2 = bijection.getComparable().getRight(s1); - Resource p1 = del.getPredicate(); + Resource p1 = del != null ? del.getPredicate() : mod.getPredicate(); Resource p2 = bijection.getComparable().getRight(p1); if (p2 == null) p2 = p1; - Resource o1 = del.getObject(); + Resource o1 = del != null ? del.getObject() : null; Resource o2 = bijection.getComparable().getRight(o1); + + if (mod.isLeftAsserted()) { + if (sub2 == null) + sub2 = sub1; + + } + if (o2 == null && p2 != null) + o2 = graph.getPossibleObject(sub2, p2); if (mod.isLeftAsserted()) { - if (s2 == null) - s2 = s1; if (o2 == null) o2 = o1; - } - - if (s2 == null || p2 == null) { - throw new DatabaseException("Did not find matching statement from bijection for (" + s1 +","+p1+","+o1+"), got (" + s2 +","+p2+","+o2+")"); } - Collection stms = graph.getStatements(s2, p2); - Statement stm2 = null; - if (o2 == null) { - // Matching literal resources are not included in bijection map. - if (stms.size() == 1) { - stm2 = stms.iterator().next(); - } else { - throw new DatabaseException("Did not find matching statement from bijection for (" + s1 +","+p1+","+o1+"), got (" + s2 +","+p2+","+o2+")"); - } + if (sub2 == null || p2 == null) { + throw new DatabaseException("Did not find matching statement from bijection for (" + sub1 +","+p1+","+o1+"), got (" + sub2 +","+p2+","+o2+")"); + } + if (del == null) { + Modification mod2 = new Modification(sub2, mod.rightSub, null, mod.rightStm); + modifications.add(mod2); } else { - for (Statement s : stms) { - if (s.getObject().equals(o2)) { - stm2 = s; - break; + Collection stms = graph.getStatements(sub2, p2); + Statement stm2 = null; + if (o2 == null) { + // Matching literal resources are not included in bijection map. + if (stms.size() == 1) { + stm2 = stms.iterator().next(); + } else { + throw new DatabaseException("Did not find matching statement from bijection for (" + sub1 +","+p1+","+o1+"), got (" + sub2 +","+p2+","+o2+")"); + } + } else { + for (Statement s : stms) { + if (s.getObject().equals(o2)) { + stm2 = s; + break; + } } } + if (stm2 == null) { + throw new DatabaseException("Did not find matching statement from bijection for (" + sub1 +","+p1+","+o1+"), got (" + sub2 +","+p2+","+o2+"), but it is not in DB!"); + } + Modification mod2 = new Modification(sub2, mod.rightSub, stm2, mod.rightStm); + modifications.add(mod2); } - if (stm2 == null) { - throw new DatabaseException("Did not find matching statement from bijection for (" + s1 +","+p1+","+o1+"), got (" + s2 +","+p2+","+o2+"), but it is not in DB!"); - } - Modification mod2 = new Modification(sub2, mod.rightSub, stm2, mod.rightStm); - modifications.add(mod2); } }