X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop.update%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fupdate%2Fmodel%2FUpdateOp.java;h=2bd3718f6a39cc96d5741611e8cb85f3b5f59771;hb=961c51d828eace5c9ab9db9499f0af9a78f16192;hp=3b633c28cdfd5a017995ff7e2c1a364b9cc4d22f;hpb=7bd962c96d0a43bbc0fca67e87a1bc877a451fe0;p=simantics%2Finterop.git diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java index 3b633c2..2bd3718 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java @@ -4,11 +4,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.Statement; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.interop.test.GraphChanges; +import org.simantics.layer0.Layer0; /** * Base class for update operations (adding and deleting objects) @@ -60,11 +62,15 @@ public abstract class UpdateOp { public void addParentOp(UpdateOp op) { assert (!op.equals(this)); + if (parentOps.contains(op)) + return; parentOps.add(op); } public void addSubOp(UpdateOp op) { assert (!op.equals(this)); + if (subOps.contains(op)) + return; subOps.add(op); } @@ -212,6 +218,12 @@ public abstract class UpdateOp { */ public abstract Resource getCreatedResource(); + public Resource getParentResource(ReadGraph g) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(g); + return g.getPossibleObject(getResource(), l0.PartOf); + } + + @Override public String toString() { String s = this.getClass().getSimpleName();