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.db.layer0.genericrelation.IndexQueries;
14 import org.simantics.layer0.Layer0;
15 import org.simantics.operation.Layer0X;
16 import org.simantics.scl.runtime.function.Function;
18 public class IndexedInstances extends ResourceRead2<Set<Resource>> {
20 public IndexedInstances(Resource type, Resource indexRoot) {
21 super(type, indexRoot);
25 public Set<Resource> perform(ReadGraph graph) throws DatabaseException {
27 Layer0 L0 = Layer0.getInstance(graph);
28 Layer0X L0X = Layer0X.getInstance(graph);
30 String typeName = graph.getRelatedValue(resource, L0.HasName);
32 Function dependencies = graph.adapt(L0X.Dependencies, Function.class);
34 Collection<Map<String, Object>> results = (Collection<Map<String, Object>>)dependencies.apply(graph, resource2, "Types:" + IndexQueries.quoteTerm(typeName));
36 return Collections.emptySet();
38 HashSet<Resource> result = new HashSet<Resource>(results.size());
39 for(Map<String, Object> entry : results) {
40 Resource res = (Resource)entry.get("Resource");
42 if (graph.isInstanceOf(res, resource))