- }
-
- @Override
- public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
-
- DocumentationResource DOC = DocumentationResource.getInstance(graph);
-
- Resource type = variable.getPossibleType(graph);
- if(type == null) return Collections.emptySet();
-
- if(!graph.isInheritedFrom(type, DOC.Components_Component)) return Collections.emptySet();
-
- Boolean pathExists = variable.getPossiblePropertyValue(graph, DOC.Properties_pathExists, Bindings.BOOLEAN);
- if(pathExists != null && !pathExists) return Collections.emptySet();
-
- if(graph.isInheritedFrom(type, DOC.Components_PrimitiveComponent)) {
- return Collections.singleton(variable);
- } else {
- Set<Variable> result = new THashSet<Variable>();
- for(Variable child : variable.getChildren(graph)) {
- Set<Variable> nodes = graph.syncRequest(new NodesRequest2(child));
- result.addAll(nodes);
- }
-
- return result;
- }
-
- }
+ }
+
+ @Override
+ public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
+
+ ITask task = DocumentRequest.PROFILE ? ThreadLogger.task(this) : null;
+
+ DocumentationResource DOC = DocumentationResource.getInstance(graph);
+
+ Resource type = variable.getPossibleType(graph);
+ if(type == null) {
+ if(DocumentRequest.PROFILE) task.finish();
+ return Collections.emptySet();
+ }
+
+ if(!graph.isInheritedFrom(type, DOC.Components_Component)) {
+ if(DocumentRequest.PROFILE) task.finish();
+ return Collections.emptySet();
+ }
+
+ Boolean pathExists = variable.getPossiblePropertyValue(graph, DOC.Properties_pathExists, Bindings.BOOLEAN);
+ if(pathExists != null && !pathExists) {
+ if(DocumentRequest.PROFILE) task.finish();
+ return Collections.emptySet();
+ }
+
+ if(graph.isInheritedFrom(type, DOC.Components_PrimitiveComponent)) {
+ if(DocumentRequest.PROFILE) task.finish();
+ return Collections.singleton(variable);
+ } else {
+ Set<Variable> result = new THashSet<Variable>();
+ Collection<Variable> children = graph.syncRequest(new VariableChildren(variable));
+ graph.syncRequest(new AsyncReadRequest() {
+
+ @Override
+ public void run(AsyncReadGraph graph) throws DatabaseException {
+
+ for(Variable child : children) {
+ graph.asyncRequest(new NodesRequest2(child), new AsyncProcedure<Set<Variable>>() {
+
+ @Override
+ public void execute(AsyncReadGraph graph, Set<Variable> vars) {
+ synchronized(result) {
+ result.addAll(vars);
+ }
+ }
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ }
+
+ });
+ }
+
+ }
+
+ });
+
+ if(DocumentRequest.PROFILE) task.finish();
+ return result;
+
+ }
+
+ }