]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.db/scl/Simantics/DB.scl
Listenable queries in SCL
[simantics/platform.git] / bundles / org.simantics.scl.db / scl / Simantics / DB.scl
index b24df17f8639c40cb2a020f130a911e8bf547912..ec9cc2671e3294f5f5335bf1c252f6653d0ffebc 100644 (file)
@@ -20,6 +20,8 @@ importJava "org.simantics.db.Resource" where
     @JavaName getResourceId
     resourceId :: Resource -> Long
     
+    isPersistent :: Resource -> Boolean
+    
 importJava "org.simantics.db.ReadGraph" where
     data ReadGraphX
     
@@ -58,6 +60,10 @@ importJava "org.simantics.db.ReadGraph" where
     @private
     @JavaName getURI
     uriOfResource :: Resource -> <ReadGraph> String
+
+    @private
+    @JavaName getPossibleURI
+    possibleUriOfResource :: Resource -> <ReadGraph> Maybe String
     
     @JavaName getObjects
     objects_ :: Resource -> Resource -> <ReadGraph> Collection Resource
@@ -167,7 +173,10 @@ class Browsable a where
 
     "Returns the URI of the given value."
     uriOf :: a -> <ReadGraph> String
-  
+    
+    "Returns the URI of the given value if it exists or Nothing."
+    possibleUriOf :: a -> <ReadGraph> Maybe String
+    
     "Reads the name of the value."
     nameOf :: a -> <ReadGraph> String
     possibleNameOf :: a -> <ReadGraph> Maybe String
@@ -186,6 +195,7 @@ class Browsable a where
 instance Browsable Resource where
     fromUri = resource
     uriOf = uriOfResource
+    possibleUriOf = possibleUriOfResource
     nameOf r = relatedValue r L0.HasName
     possibleNameOf r = possibleRelatedValue r L0.HasName
     @inline
@@ -334,6 +344,8 @@ importJava "org.simantics.scl.db.SCLFunctions" where
     subquery :: (<ReadGraph,Proc> a) -> <ReadGraph,Proc> a
     "Makes a new read request with given procedure for calculating the result. The request is always cached."
     subqueryC :: (<ReadGraph,Proc> a) -> <ReadGraph,Proc> a
+    "Makes a new read asynchronous request with function to handle the request result. The last `isDisposed` function parameter is used to determine if the listener is still alive or not."
+    subqueryL :: (<ReadGraph,Proc> a) -> (a -> <ReadGraph, e> ()) -> (Throwable -> <ReadGraph, e> ()) -> (<e> Boolean) -> <ReadGraph, Proc, e> ()
     "Tries to convert the given Dynamic value to a value with the inferred type"
     possibleFromDynamic :: Typeable a => String -> Dynamic -> Maybe a
 
@@ -356,6 +368,11 @@ importJava "org.simantics.db.layer0.util.Layer0Utils" where
     copyTo_ :: Resource -> Resource -> <WriteGraph> Collection Resource
     @JavaName getPossiblePredicateByName
     possiblePredicateByName :: Resource -> String -> <ReadGraph> Maybe Resource
+    @JavaName getPossiblePredicateByNameFromType
+    possiblePredicateByNameFromType :: Resource -> String -> <ReadGraph> Maybe Resource
+    
+    addMetadataListener :: ChangeListener -> <Proc> ()
+    removeMetadataListener :: ChangeListener -> <Proc> ()
 
 copyTo :: Resource -> Resource -> <WriteGraph> Resource
 copyTo targetContainer source = do
@@ -484,4 +501,13 @@ possibleChildWithPath parent path =
               Just c -> possibleChild c name
               Nothing -> Nothing 
           ) 
-          (Just parent) path
\ No newline at end of file
+          (Just parent) path
+
+importJava "org.simantics.db.MetadataI" where
+    data MetadataI
+
+importJava "org.simantics.db.event.ChangeListener" where
+    data ChangeListener
+
+importJava "org.simantics.db.layer0.genericrelation.DependencyChanges" where
+    data DependencyChanges