]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java
Copying tags and type information.
[simantics/interop.git] / org.simantics.interop.update / src / org / simantics / interop / update / model / AddDeleteUpdateOp.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);