]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Support for UpdateOps that are not adds or deletes. 81/3581/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 20 Nov 2019 13:00:57 +0000 (15:00 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 20 Nov 2019 13:00:57 +0000 (15:00 +0200)
gitlab #16

Change-Id: Idac97fbf7bb86c320fca3b242116f62e4f687228

org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateTree.java

index a2066f4108c33e35a92d10b28ab9314c2153c34f..aa6d7a3f65226a63344c9884bef9a481ab08a50f 100644 (file)
@@ -51,7 +51,13 @@ public class UpdateTree {
        private UpdateNode createNode(ReadGraph g, Resource r1, Resource r2) throws DatabaseException {
                UpdateNode node = null;
                if (r1 != null && r2 != null) {
-                       node =  createNode(g, UpdateStatus.EXIST, r1);
+                   UpdateOp op = updateOps.getUpdateOp(r1);
+                   if (op == null)
+                       op = updateOps.getUpdateOp(r2);
+            if (op == null)                    
+                node = createNode(g, UpdateStatus.EXIST, r1);
+            else
+                node = createNode(g, UpdateStatus.EXIST, op);
                        nodes.put(r1, node);
                        nodes.put(r2, node);
                } else if (r1 != null) {
@@ -65,9 +71,6 @@ public class UpdateTree {
        }
        
        public UpdateNode addNode(ReadGraph g, Resource r1, Resource r2) throws DatabaseException {
-               if (r1 != null && r2 != null) {
-                       return null;
-               }
                if (nodes.containsKey(r1))
                        return nodes.get(r1);
                if (nodes.containsKey(r2))
@@ -130,8 +133,12 @@ public class UpdateTree {
                        if (!handleCustom(g, op)) {
                                if (op.isAdd()) {
                                        addNode(g, null,op.getResource());
-                               } else {
+                               } else if (op.isDelete()){
                                        addNode(g, op.getResource(), null);
+                               } else if (op.isChange()) {
+                                   Resource l = getChanges().getComparable().containsLeft(op.getResource()) ? op.getResource() :getChanges().getComparable().getLeft(op.getResource());
+                                   Resource r = getChanges().getComparable().containsRight(op.getResource()) ? op.getResource() :getChanges().getComparable().getRight(op.getResource());
+                                   addNode(g, l, r);
                                }
                        }
                }