]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Copying tags and type information. 32/3732/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 20 Dec 2019 13:53:00 +0000 (15:53 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 20 Dec 2019 13:53:00 +0000 (15:53 +0200)
gitlab #20

Change-Id: I127386789bc3d071c53c0874e074fb834c1b3075

org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java
org.simantics.interop.update/src/org/simantics/interop/update/model/SimpleObjectUpdateOp.java

index f270d46e87df8f169e47c2dd4339063cdcc54ae1..3bd21b05a92208620dfec0e2f7b27e5e24fdaccd 100644 (file)
@@ -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);
index 9f2f41af1f26569488a1d27e2875185f2c42240a..110ea45eb832440d0d2ed45767521ced5dfba1ca 100644 (file)
@@ -78,5 +78,10 @@ public class SimpleObjectUpdateOp extends AddDeleteUpdateOp {
                return copyObj;
        }
        
+       @Override
+    public String toString() {
+        return super.toString() + " " + r.getSubject() + " " + r.getPredicate() + " " + r.getObject();
+    }
+       
 
 }