X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop.update%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fupdate%2Fmodel%2FUpdateTree.java;h=739667228a01291bea2cdf07789e719b72624672;hb=930c049303df44922114e177e174a3c94d423b7f;hp=de5ea90e48a94af527c240dd90778ba5493efaaa;hpb=2de9ca9c20cbb4dca4ae274547d65ec6f1cbc893;p=simantics%2Finterop.git diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateTree.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateTree.java index de5ea90..7396672 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateTree.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateTree.java @@ -21,7 +21,7 @@ public class UpdateTree { public UpdateTree(ReadGraph g, GraphChanges changes, UpdateOperations updateOps) throws DatabaseException { this.changes = changes; this.nodes = new HashMap(); - this.rootNode = createNode(Status.EXIST, changes.getResource1()); + this.rootNode = createNode(g, Status.EXIST, changes.getResource1()); nodes.put(changes.getResource1(), rootNode); nodes.put(changes.getResource2(), rootNode); this.updateOps = updateOps; @@ -37,25 +37,29 @@ public class UpdateTree { return rootNode; } - protected UpdateNode createNode(Status status, Resource r) { - return new UpdateNode(status, r); + public GraphChanges getChanges() { + return changes; } - protected UpdateNode createNode(Status status, UpdateOp op) { - return new UpdateNode(status, op); + protected UpdateNode createNode(ReadGraph g, Status status, Resource r) throws DatabaseException { + return new UpdateNode(g,status, r); } - private UpdateNode createNode(Resource r1, Resource r2) { + protected UpdateNode createNode(ReadGraph g, Status status, UpdateOp op) throws DatabaseException{ + return new UpdateNode(g,status, op); + } + + private UpdateNode createNode(ReadGraph g, Resource r1, Resource r2) throws DatabaseException { UpdateNode node = null; if (r1 != null && r2 != null) { - node = createNode(Status.EXIST, r1); + node = createNode(g, Status.EXIST, r1); nodes.put(r1, node); nodes.put(r2, node); } else if (r1 != null) { - node = createNode(Status.DELETED ,updateOps.getUpdateOp(r1)); + node = createNode(g,Status.DELETED ,updateOps.getUpdateOp(r1)); nodes.put(r1, node); } else if (r2 != null) { - node = createNode(Status.NEW, updateOps.getUpdateOp(r2)); + node = createNode(g,Status.NEW, updateOps.getUpdateOp(r2)); nodes.put(r2, node); } return node; @@ -70,7 +74,7 @@ public class UpdateTree { if (nodes.containsKey(r2)) return nodes.get(r2); - UpdateNode node = createNode(r1, r2); + UpdateNode node = createNode(g, r1, r2); connectParent(g,node); return node; } @@ -104,9 +108,9 @@ public class UpdateTree { UpdateNode parent = nodes.get(parentResource); if (parent == null) { if (changes.getComparable().containsLeft(parentResource)) { - parent = createNode(parentResource, changes.getComparable().getRight(parentResource)); + parent = createNode(g, parentResource, changes.getComparable().getRight(parentResource)); } else if (changes.getComparable().containsRight(parentResource)) { - parent = createNode(changes.getComparable().getLeft(parentResource) ,parentResource); + parent = createNode(g, changes.getComparable().getLeft(parentResource) ,parentResource); } else { return null; }