From: Marko Luukkainen Date: Wed, 27 Jan 2021 13:19:46 +0000 (+0200) Subject: Applying enumeration (or SCL value) with model specific relation. X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=311d93d874e43c880c0890ff91249914aaeb7ae1;p=simantics%2Finterop.git Applying enumeration (or SCL value) with model specific relation. Some properties (Especially UC properties) are model/instance specific. gitlab #25 Change-Id: I66b1b7c848220054d3a8724521024f6ff47b3634 --- diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java index d1a64af..772289f 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java @@ -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 diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateTree.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateTree.java index aa6d7a3..a971da4 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateTree.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateTree.java @@ -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); } }