1 package org.simantics.document.server.request;
3 import java.util.Collection;
4 import java.util.Collections;
7 import org.simantics.db.AsyncReadGraph;
8 import org.simantics.db.ReadGraph;
9 import org.simantics.db.common.request.AsyncReadRequest;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.db.layer0.request.VariableChildren;
12 import org.simantics.db.layer0.request.VariableRead;
13 import org.simantics.db.layer0.variable.Variable;
14 import org.simantics.db.procedure.AsyncProcedure;
15 import org.simantics.structural.stubs.StructuralResource2;
16 import org.simantics.utils.threads.logger.ITask;
17 import org.simantics.utils.threads.logger.ThreadLogger;
19 import gnu.trove.set.hash.THashSet;
21 public class NodesRequest extends VariableRead<Set<Variable>> {
23 public NodesRequest(Variable var) {
28 public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
30 ITask task = DocumentRequest.PROFILE ? ThreadLogger.task(this) : null;
32 StructuralResource2.getInstance(graph);
34 return Collections.emptySet();
36 Set<Variable> nodes = new THashSet<Variable>();
38 Collection<Variable> children = graph.syncRequest(new VariableChildren(variable));
40 graph.syncRequest(new AsyncReadRequest() {
43 public void run(AsyncReadGraph graph) throws DatabaseException {
45 for(Variable child : children) {
46 graph.asyncRequest(new NodesRequest2(child), new AsyncProcedure<Set<Variable>>() {
49 public void execute(AsyncReadGraph graph, Set<Variable> result) {
56 public void exception(AsyncReadGraph graph, Throwable throwable) {
66 if(DocumentRequest.PROFILE) task.finish();