X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop.update%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fupdate%2Fmodel%2FPropertyChange.java;h=be6e5e0bbda38498fd22388d6dc6e2ed31dd4b45;hb=37acf1273cdf0be148b22625db2baa15a4077d0b;hp=9a95984ed76986707b4991d18f2301d451c7f647;hpb=c201a20a77db051116870d6c7eece50374293824;p=simantics%2Finterop.git 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 9a95984..be6e5e0 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 @@ -81,7 +81,15 @@ public class PropertyChange { if (obj.getClass() != this.getClass()) return false; PropertyChange c = (PropertyChange)obj; - return pair.equals(c.pair); + if (!leftSubject.equals(c.leftSubject)) + return false; + if (!rightSubject.equals(c.rightSubject)) + return false; + if (pair.first != null && pair.first.equals(c.pair.first)) + return true; + if (pair.second != null && pair.second.equals(c.pair.second)) + return true; + return false; } public void apply(WriteGraph graph) throws DatabaseException { @@ -101,12 +109,16 @@ public class PropertyChange { value = graph.getValue(pair.second.getObject()); } Resource pred = pair.second.getPredicate(); + if (getChanges().getComparable().containsRight(pred)) + pred = getChanges().getComparable().getLeft(pred); + if (value != null) { graph.deny(s, pred); graph.claimLiteral(s, pred, value); } else { graph.deny(s,pred); } + applied = true; } else if (graph.isInstanceOf(pair.second.getObject(), L0.SCLValue)) { Resource pred = pair.second.getPredicate(); graph.deny(s, pred); @@ -114,8 +126,18 @@ public class PropertyChange { graph.claim(valueResource, L0.InstanceOf, graph.getSingleObject(pair.second.getObject(), L0.InstanceOf)); AddDeleteUpdateOp.copyProperties(graph, pair.second.getObject(), valueResource); graph.claim(s, pred, valueResource); + applied = true; + } else { + Resource type = graph.getPossibleType(pair.second.getObject(), L0.Value); + if (type != null && graph.hasStatement(type, L0.Enumeration, type)) { + Resource pred = pair.second.getPredicate(); + graph.deny(s, pred); + graph.claim(s, pred, pair.second.getObject()); + applied = true; + } + } - applied = true; + } /** @@ -195,6 +217,9 @@ public class PropertyChange { } public void setCustomValue(Object customValue) { + if (applied) { + throw new RuntimeException("Cannot change already applied value"); + } this.customValue = customValue; }