]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Add Simantics/Variables/{rviBinding,rviIsEmpty}
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 3 Jun 2021 12:37:33 +0000 (15:37 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 3 Jun 2021 12:37:33 +0000 (15:37 +0300)
gitlab #720

bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java
bundles/org.simantics.scl.db/scl/Simantics/Variables.scl

index 5fb0636a08dec5e41a616b863c58bbb7fbbaa4df..a35bcd355b0734eb924a05671a7c746f78127cd6 100644 (file)
@@ -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;
+    }
+
 }
index 436e0a17357f32072ec80c2cea18f8f97d3bb734..97c5644acc715d17b113589d9048009515d077e4 100644 (file)
@@ -84,7 +84,19 @@ Example:
     possibleConfigurationContext :: Resource -> <ReadGraph> Variable
 
     setRVIProperty :: Variable -> RVI -> <WriteGraph> ()
-    
+
+    """
+    Returns the Binding needed to read RVI type properties.
+    """
+    rviBinding :: <ReadGraph> 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 -> <ReadGraph> a