1 package org.simantics.document.server.request;
3 import gnu.trove.set.hash.THashSet;
5 import java.util.Collection;
6 import java.util.Collections;
9 import org.simantics.db.ReadGraph;
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.structural.stubs.StructuralResource2;
16 public class NodesRequest extends VariableRead<Set<Variable>> {
18 public NodesRequest(Variable var) {
23 public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
25 long s = System.nanoTime();
27 StructuralResource2.getInstance(graph);
29 return Collections.emptySet();
31 Set<Variable> nodes = new THashSet<Variable>();
32 Collection<Variable> children = graph.syncRequest(new VariableChildren(variable));
33 for(Variable child : children) {
34 Set<Variable> childNodes = graph.syncRequest(new NodesRequest2(child));
35 nodes.addAll(childNodes);
38 if(DocumentRequest.PROFILE) {
39 long dura = System.nanoTime()-s;
40 System.err.println("NodesRequest " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. " + variable.getURI(graph));