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
import org.simantics.db.Resource;
import org.simantics.db.VirtualGraph;
import org.simantics.db.WriteGraph;
+import org.simantics.db.common.procedure.adapter.SyncListenerAdapter;
import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
import org.simantics.db.common.request.BinaryRead;
import org.simantics.db.common.request.DelayedWriteRequest;
import org.simantics.scl.runtime.SCLContext;
import org.simantics.scl.runtime.function.Function;
import org.simantics.scl.runtime.function.Function1;
+import org.simantics.scl.runtime.tuple.Tuple;
import org.simantics.scl.runtime.tuple.Tuple0;
import org.simantics.utils.DataContainer;
public static Object subqueryC(ReadGraph graph, Function q) throws DatabaseException {
return graph.syncRequest(new Subquery(q), TransientCacheAsyncListener.<Object>instance());
}
+
+ public static void subqueryL(ReadGraph graph, Function query, Function executeCallback, Function1<Throwable, Tuple> exceptionCallback, Function1<Tuple0, Boolean> isDisposedCallback) throws DatabaseException {
+ graph.asyncRequest(new Subquery(query), new SyncListenerAdapter<Object>() {
+
+ @Override
+ public void execute(ReadGraph graph, Object result) {
+ executeCallback.apply(result);
+ }
+
+ @Override
+ public void exception(ReadGraph graph, Throwable t) {
+ exceptionCallback.apply(t);
+ }
+
+ @Override
+ public boolean isDisposed() {
+ return isDisposedCallback.apply(Tuple0.INSTANCE);
+ }
+ });
+ }
public static Object possibleFromDynamic(Type expectedType, String moduleName, Object value) {