From 13d28be3d9a98c458da41da1f48130b07c4d3756 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Thu, 3 Jun 2021 15:37:33 +0300 Subject: [PATCH] Add Simantics/Variables/{rviBinding,rviIsEmpty} gitlab #720 --- .../simantics/db/layer0/variable/Variables.java | 10 ++++++++++ .../scl/Simantics/Variables.scl | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java index 5fb0636a0..a35bcd355 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java @@ -814,4 +814,14 @@ final public class Variables { graph.claimLiteral(subject, predicate, L0.RVI, rvi, rviBinding); } + public static Binding rviBinding(ReadGraph graph) throws DatabaseException { + Databoard databoard = graph.getService(Databoard.class); + if (databoard == null) throw new DatabaseException("No databoard support in Session"); //$NON-NLS-1$ + return databoard.getBindingUnchecked(RVI.class); + } + + public static boolean isEmpty(RVI rvi) throws DatabaseException { + return rvi.parts.length == 0; + } + } diff --git a/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl b/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl index 436e0a173..97c5644ac 100644 --- a/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl +++ b/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl @@ -84,7 +84,19 @@ Example: possibleConfigurationContext :: Resource -> Variable setRVIProperty :: Variable -> RVI -> () - + + """ + Returns the Binding needed to read RVI type properties. + """ + rviBinding :: Binding a + + """ + Returns True if the given RVI is empty in which case + `resolvePossible rvi var` would return `Just var`. + """ + @JavaName isEmpty + rviIsEmpty :: RVI -> Boolean + importJava "org.simantics.db.layer0.function.All" where standardGetValue1 :: Variable -> a -- 2.47.1