]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java
Multiple reader thread support for db client
[simantics/platform.git] / bundles / org.simantics.document.server / src / org / simantics / document / server / Functions.java
index 0a7e004f7dcab5e75740d176100c78d59c3dfb47..aabe7b29ffd04dbcdff684dc899f11f2bde8c19f 100644 (file)
@@ -68,9 +68,10 @@ import org.simantics.document.server.request.ServerSCLHandlerValueRequest;
 import org.simantics.document.server.request.ServerSCLValueRequest;
 import org.simantics.document.server.serverResponse.ServerResponse;
 import org.simantics.document.server.serverResponse.SuccessResponse;
+import org.simantics.document.server.state.StateNodeManager;
+import org.simantics.document.server.state.StateRealm;
+import org.simantics.document.server.state.StateSessionManager;
 import org.simantics.modeling.ModelingResources;
-import org.simantics.modeling.scl.SCLRealm;
-import org.simantics.modeling.scl.SCLSessionManager;
 import org.simantics.modeling.services.CaseInsensitiveComponentFunctionNamingStrategy;
 import org.simantics.modeling.services.ComponentNamingStrategy;
 import org.simantics.operation.Layer0X;
@@ -201,11 +202,11 @@ public class Functions {
                 }
                 
                 DirectQuerySupport dqs = graph.getService(DirectQuerySupport.class);
-                PrimitivePropertyStatementsProcedure foo = new PrimitivePropertyStatementsProcedure();
+                //PrimitivePropertyStatementsProcedure foo = new PrimitivePropertyStatementsProcedure();
 
-                dqs.forEachDirectPersistentStatement(graph, parentRes, foo);
+                DirectStatements ds = dqs.getDirectPersistentStatements(graph, parentRes);
 
-                for(Statement stm : foo.result) {
+                for(Statement stm : ds) {
                     Resource predicate = stm.getPredicate();
                     PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(predicate));
 
@@ -756,12 +757,12 @@ public class Functions {
 
         final List<TCon> effects = ServerSCLHandlerValueRequest.getEffects(graph, anyFunction);
 
-       final Function1<CommandContext, CommandResult> fn = anyFunction.getValue(graph);
-        String expression = anyFunction.getPropertyValue(graph, "expression");
+       Function1<CommandContext, CommandResult> fn = anyFunction.getValue(graph);
+        //String expression = anyFunction.getPropertyValue(graph, "expression");
 
        final Session session = graph.getSession();
 
-        return new AbstractResponseHandler(expression) {
+        return new AbstractResponseHandler(fn) {
 
                private String formatError(RequestProcessor proc, Throwable t) {
 
@@ -1147,11 +1148,6 @@ public class Functions {
 
        } else {
 
-               String id = sclStateKey(graph, base, self, ref);
-
-               SCLRealm realm = SCLSessionManager.getOrCreateSCLRealm(base.getURI(graph) + "/__scl__");
-               realm.getConnection().setVariable(id, getSCLType(defaultValue), defaultValue);
-
                return defaultValue;
 
        }
@@ -1161,9 +1157,9 @@ public class Functions {
 
        String id = sclStateKey(graph, base, self, ref);
 
-       SCLRealm realm = SCLSessionManager.getOrCreateSCLRealm(base.getURI(graph)+"/__scl__");
-       realm.getConnection().setVariable(id, getSCLType(value), value);
-       realm.refreshVariablesSync();
+               StateRealm realm = (StateRealm) StateSessionManager.getInstance().getOrCreateRealm(graph, base.getURI(graph)+"/__scl__");
+               StateNodeManager nodeManager = (StateNodeManager) realm.getNodeManager();
+               nodeManager.setState(id, value);
 
     }