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