1 package org.simantics.db.layer0.request;
3 import java.util.Collection;
4 import java.util.Collections;
5 import java.util.HashSet;
9 import org.simantics.db.ReadGraph;
10 import org.simantics.db.Resource;
11 import org.simantics.db.common.request.ResourceRead2;
12 import org.simantics.db.exception.DatabaseException;
13 import org.simantics.layer0.Layer0;
14 import org.simantics.operation.Layer0X;
15 import org.simantics.scl.runtime.function.Function;
17 public class IndexedInstances extends ResourceRead2<Set<Resource>> {
19 public IndexedInstances(Resource type, Resource indexRoot) {
20 super(type, indexRoot);
24 public Set<Resource> perform(ReadGraph graph) throws DatabaseException {
26 Layer0 L0 = Layer0.getInstance(graph);
27 Layer0X L0X = Layer0X.getInstance(graph);
29 String typeName = graph.getRelatedValue(resource, L0.HasName);
31 Function dependencies = graph.adapt(L0X.Dependencies, Function.class);
33 Collection<Map<String, Object>> results = (Collection<Map<String, Object>>)dependencies.apply(graph, resource2, "Types:*" + typeName);
35 return Collections.emptySet();
37 HashSet<Resource> result = new HashSet<Resource>(results.size());
38 for(Map<String, Object> entry : results) {
39 Resource res = (Resource)entry.get("Resource");
41 if (graph.isInstanceOf(res, resource))