--- /dev/null
+package org.simantics.db.common.request;\r
+\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.ResourceSet;\r
+import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.service.CollectionSupport;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class IndexRoots extends ResourceRead<Collection<Resource>> {\r
+\r
+ public IndexRoots(Resource r) {\r
+ super(r);\r
+ }\r
+\r
+ @Override\r
+ public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ if (graph.isInstanceOf(resource, L0.IndexRoot))\r
+ return Collections.singletonList(resource);\r
+ CollectionSupport cs = graph.getService(CollectionSupport.class);\r
+ ResourceSet types = cs.getResourceSet(graph, L0.IndexRoot);\r
+ ResourceSetGraph rsg = graph.syncRequest(new DependentInstances3(resource), TransientCacheAsyncListener.<ResourceSetGraph>instance());\r
+ return rsg.resolve(graph, types);\r
+ }\r
+\r
+}
\ No newline at end of file