]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.server/src/org/simantics/document/server/request/DocumentRequest.java
Generate parts of db client query code
[simantics/platform.git] / bundles / org.simantics.document.server / src / org / simantics / document / server / request / DocumentRequest.java
index 1726887cb359d8f92acafb3bb34be41dbd693165..779cf4fe1381acb5979e541d54fce12047115103 100644 (file)
@@ -9,9 +9,11 @@ import java.util.Set;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 
+import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.common.GraphSemaphore;
 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
+import org.simantics.db.common.request.AsyncReadRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.VariableRead;
 import org.simantics.db.layer0.variable.Variable;
@@ -80,6 +82,7 @@ public class DocumentRequest extends VariableRead<List<JSONObject>> {
                        System.out.println("               " + node.getURI(graph));
                }*/
 
+<<<<<<< Upstream, based on branch 'private/antti_threads' of ssh://villberg@gerrit.simantics.org:29418/simantics/platform.git
                GraphSemaphore done = new GraphSemaphore(graph, 0);
                
                for(Variable node : nodes) {
@@ -116,6 +119,41 @@ public class DocumentRequest extends VariableRead<List<JSONObject>> {
                        } catch (InterruptedException e) {
                                e.printStackTrace();
                        }
+=======
+               graph.syncRequest(new AsyncReadRequest() {
+                               
+                               @Override
+                               public void run(AsyncReadGraph graph) {
+                                       
+                               for(Variable node : nodes) {
+                                       
+                                       graph.asyncRequest(new NodeRequestE(node), new Listener<JSONObject>() {
+
+                                                       @Override
+                                                       public void execute(JSONObject result) {
+                                                               synchronized(rs) {
+                                                                       rs.add(result);
+                                                               }
+                                                       }
+
+                                                       @Override
+                                                       public void exception(Throwable t) {
+                                                               t.printStackTrace();
+                                                       }
+
+                                                       @Override
+                                                       public boolean isDisposed() {
+                                                               return true;
+                                                       }
+                                                       
+                                               });
+                                       
+                               }
+                                       
+                               }
+                               
+                       });
+>>>>>>> 82fa68e Generate parts of db client query code
        
                        ArrayList<JSONObject> result = new ArrayList<JSONObject>(rs);
                        Collections.sort(result, new Comparator<JSONObject>() {