X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Frequest%2FIndexRoots.java;fp=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Frequest%2FIndexRoots.java;h=e7ea43a9a7549115494f7f42df1eeaab7ace6fec;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/IndexRoots.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/IndexRoots.java new file mode 100644 index 000000000..e7ea43a9a --- /dev/null +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/IndexRoots.java @@ -0,0 +1,31 @@ +package org.simantics.db.common.request; + +import java.util.Collection; +import java.util.Collections; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.ResourceSet; +import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.service.CollectionSupport; +import org.simantics.layer0.Layer0; + +public class IndexRoots extends ResourceRead> { + + public IndexRoots(Resource r) { + super(r); + } + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + if (graph.isInstanceOf(resource, L0.IndexRoot)) + return Collections.singletonList(resource); + CollectionSupport cs = graph.getService(CollectionSupport.class); + ResourceSet types = cs.getResourceSet(graph, L0.IndexRoot); + ResourceSetGraph rsg = graph.syncRequest(new DependentInstances3(resource), TransientCacheAsyncListener.instance()); + return rsg.resolve(graph, types); + } + +} \ No newline at end of file