From: Tuukka Lehtonen Date: Thu, 3 Jun 2021 12:37:33 +0000 (+0300) Subject: Add Simantics/Variables/{rviBinding,rviIsEmpty} X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=13d28be3d9a98c458da41da1f48130b07c4d3756;p=simantics%2Fplatform.git Add Simantics/Variables/{rviBinding,rviIsEmpty} gitlab #720 --- 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