From dc5ff213540b06b8cb88222837d573bff80abb3d Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Tue, 1 Dec 2020 19:36:43 +0200 Subject: [PATCH] Accessing UpdateOperations with SCL. Accessing Graph Comparator changed statements Fixed potential NPE in floating point value filter. gitlab #28 Change-Id: I6f17ed281cb33855c5f5ca0fd7e480de43be77d9 --- org.simantics.interop.update/scl/Interop/Update.scl | 12 ++++++++++++ .../simantics/interop/update/model/ModelUpdate.java | 2 ++ .../org/simantics/interop/test/GraphComparator.java | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/org.simantics.interop.update/scl/Interop/Update.scl b/org.simantics.interop.update/scl/Interop/Update.scl index 2c91248..9badee2 100644 --- a/org.simantics.interop.update/scl/Interop/Update.scl +++ b/org.simantics.interop.update/scl/Interop/Update.scl @@ -43,6 +43,15 @@ importJava "org.simantics.interop.update.model.ModelUpdate" where @JavaName defaultSelections setDefaultSelections :: ModelUpdate -> () + +importJava "org.simantics.interop.update.model.UpdateOperations" where + data UpdateOperations + + @JavaName getUpdateOp + getUpdateOpWithResource :: UpdateOperations -> Resource -> Maybe UpdateOp + + @JavaName getUpdateOp + getUpdateOpWithStatement :: UpdateOperations -> Statement -> Maybe UpdateOp importJava "org.simantics.interop.update.model.UpdateTree" where data UpdateTree @@ -53,6 +62,9 @@ importJava "org.simantics.interop.update.model.UpdateTree" where @JavaName getNode getNode :: UpdateTree -> Resource -> Maybe UpdateNode + @JavaName getUpdateOps + getUpdateOps :: UpdateTree -> UpdateOperations + importJava "org.simantics.interop.update.model.UpdateList" where data UpdateList diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/ModelUpdate.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/ModelUpdate.java index ff56d43..aabe29d 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/ModelUpdate.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/ModelUpdate.java @@ -491,6 +491,8 @@ public abstract class ModelUpdate { @Override public boolean accept(ReadGraph g, Modification change) throws DatabaseException { //filter floating point values that have less than 1% difference. + if (change.getLeftStm() == null || change.getRightStm() == null) + return true; if (!g.hasValue(change.getLeftStm().getObject()) || !g.hasValue(change.getRightStm().getObject())) return true; Object v1 = g.getValue(change.getLeftStm().getObject()); diff --git a/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java b/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java index aae895b..3b7bb31 100644 --- a/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java +++ b/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java @@ -790,6 +790,14 @@ public class GraphComparator { return new GraphChanges(r1,r2,changes1,changes2,modifications,comparableResources); } + public List getChanges1() { + return changes1; + } + + public List getChanges2() { + return changes2; + } + private void addComparable(Statement left, Statement right) throws DatabaseException { addComparable(left.getObject(), right.getObject()); comparableStatements.map(left, right); -- 2.47.1