From 2c057c11921105f229a7e8214d09bcd82450ac26 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Fri, 20 Dec 2019 15:53:00 +0200 Subject: [PATCH] Copying tags and type information. gitlab #20 Change-Id: I127386789bc3d071c53c0874e074fb834c1b3075 --- .../update/model/AddDeleteUpdateOp.java | 24 +++++++++++++++++++ .../update/model/SimpleObjectUpdateOp.java | 5 ++++ 2 files changed, 29 insertions(+) diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java index f270d46..3bd21b0 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java @@ -24,6 +24,11 @@ public abstract class AddDeleteUpdateOp extends UpdateOp { super(changes); } + public AddDeleteUpdateOp(boolean add, GraphChanges changes) { + super(changes); + this.add = add; + } + @Override public boolean isAdd() { return add; @@ -87,6 +92,25 @@ public abstract class AddDeleteUpdateOp extends UpdateOp { } } + public static void copyTags(WriteGraph g, Resource source, Resource destination) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(g); + for (Statement s : g.getStatements(source, L0.IsWeaklyRelatedTo)) { + if (s.getObject().equals(source)) { + g.claim(destination, s.getPredicate(), destination); + } + } + } + + public static void copyTypes(WriteGraph g, Resource source, Resource destination) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(g); + for (Resource r : g.getObjects(source, L0.InstanceOf)) + g.claim(destination, L0.InstanceOf, r); + for (Resource r : g.getObjects(source, L0.Inherits)) + g.claim(destination, L0.Inherits, r); + for (Resource r : g.getObjects(source, L0.SubrelationOf)) + g.claim(destination, L0.SubrelationOf, r); + } + protected void copyIssues(WriteGraph g, Resource source, Resource destination) throws DatabaseException { Layer0 l0 = Layer0.getInstance(g); IssueResource ir = IssueResource.getInstance(g); diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/SimpleObjectUpdateOp.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/SimpleObjectUpdateOp.java index 9f2f41a..110ea45 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/SimpleObjectUpdateOp.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/SimpleObjectUpdateOp.java @@ -78,5 +78,10 @@ public class SimpleObjectUpdateOp extends AddDeleteUpdateOp { return copyObj; } + @Override + public String toString() { + return super.toString() + " " + r.getSubject() + " " + r.getPredicate() + " " + r.getObject(); + } + } -- 2.47.1