]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Applying enumeration (or SCL value) with model specific relation. 37/4637/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 27 Jan 2021 13:19:46 +0000 (15:19 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 27 Jan 2021 13:19:46 +0000 (15:19 +0200)
Some properties (Especially UC properties) are model/instance specific.

gitlab #25

Change-Id: I66b1b7c848220054d3a8724521024f6ff47b3634

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

index d1a64afb9843a71bd5cba32edcbc815ac16ead21..772289f2478f80570a28f23cbde1adacc0b8e325 100644 (file)
@@ -110,10 +110,8 @@ public class PropertyChange {
                                value = graph.getValue(pair.second.getObject());
                        }
                        type = graph.getPossibleType(pair.second.getObject(), L0.Literal);
-                       Resource pred = pair.second.getPredicate();
-                       if (getChanges().getComparable().containsRight(pred))
-                               pred = getChanges().getComparable().getLeft(pred);
                        
+                       Resource pred = _getPredicate();
                        if (value != null) {
                                graph.deny(s, pred);
                                if (type != null) {
@@ -126,7 +124,7 @@ public class PropertyChange {
                        }
                        applied = true;
                } else if (graph.isInstanceOf(pair.second.getObject(), L0.SCLValue)) {
-                       Resource pred = pair.second.getPredicate();
+                       Resource pred = _getPredicate();
                        graph.deny(s, pred);
                        Resource valueResource = graph.newResource();
                        graph.claim(valueResource, L0.InstanceOf, graph.getSingleObject(pair.second.getObject(), L0.InstanceOf));
@@ -136,7 +134,7 @@ public class PropertyChange {
                } else {
                        Resource type = graph.getPossibleType(pair.second.getObject(), L0.Value);
                        if (type != null && graph.hasStatement(type, L0.Enumeration, type)) {
-                               Resource pred = pair.second.getPredicate();
+                               Resource pred = _getPredicate();
                                graph.deny(s, pred);
                                graph.claim(s, pred, pair.second.getObject());
                                applied = true;
@@ -146,6 +144,13 @@ public class PropertyChange {
                
        }
        
+       private Resource _getPredicate() {
+               Resource pred = pair.second.getPredicate();
+               if (getChanges().getComparable().containsRight(pred))
+                       pred = getChanges().getComparable().getLeft(pred);
+               return pred;
+       }
+       
        /**
         * Sets selected state. 
         * @param select
index aa6d7a3f65226a63344c9884bef9a481ab08a50f..a971da4f41234690724961a9fc1137e13192ffe3 100644 (file)
@@ -136,8 +136,9 @@ public class UpdateTree {
                                } 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());
+                                       Resource o = op.getResource();
+                                   Resource l = getChanges().getComparable().containsLeft(o) ? o :getChanges().getComparable().getLeft(o);
+                                   Resource r = getChanges().getComparable().containsRight(o) ? o :getChanges().getComparable().getRight(o);
                                    addNode(g, l, r);
                                }
                        }