1 package org.simantics.db.common.request;
\r
3 import java.util.Collection;
\r
4 import java.util.Collections;
\r
6 import org.simantics.db.ReadGraph;
\r
7 import org.simantics.db.Resource;
\r
8 import org.simantics.db.ResourceSet;
\r
9 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
\r
10 import org.simantics.db.exception.DatabaseException;
\r
11 import org.simantics.db.service.CollectionSupport;
\r
12 import org.simantics.layer0.Layer0;
\r
14 public class IndexRoots extends ResourceRead<Collection<Resource>> {
\r
16 public IndexRoots(Resource r) {
\r
21 public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
\r
22 Layer0 L0 = Layer0.getInstance(graph);
\r
23 if (graph.isInstanceOf(resource, L0.IndexRoot))
\r
24 return Collections.singletonList(resource);
\r
25 CollectionSupport cs = graph.getService(CollectionSupport.class);
\r
26 ResourceSet types = cs.getResourceSet(graph, L0.IndexRoot);
\r
27 ResourceSetGraph rsg = graph.syncRequest(new DependentInstances3(resource), TransientCacheAsyncListener.<ResourceSetGraph>instance());
\r
28 return rsg.resolve(graph, types);
\r