1 package org.simantics.modeling.ui.scl.imports;
3 import java.util.ArrayList;
4 import java.util.Collection;
6 import org.simantics.db.ReadGraph;
7 import org.simantics.db.Resource;
8 import org.simantics.db.common.request.UnaryRead;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.layer0.Layer0;
12 public class SCLModulesQuery extends UnaryRead<Resource, Collection<String>> {
14 public SCLModulesQuery(Resource parameter) {
19 public Collection<String> perform(ReadGraph graph) throws DatabaseException {
20 ArrayList<String> result = new ArrayList<String>();
22 Layer0 L0 = Layer0.getInstance(graph);
23 browse(graph, L0, parameter, result);
28 private static void browse(ReadGraph graph, Layer0 L0, Resource current,
29 ArrayList<String> result) throws DatabaseException {
30 if(graph.isInstanceOf(current, L0.SCLModule))
31 result.add(graph.getURI(current));
32 else if(graph.isInstanceOf(current, L0.Library)
33 || graph.isInstanceOf(current, L0.IndexRoot)) {
34 for(Resource child : graph.getObjects(current, L0.ConsistsOf))
35 browse(graph, L0, child, result);