-package org.simantics.modeling.ui.scl.imports;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.layer0.Layer0;\r
-\r
-public enum OntologiesQuery implements Read<Collection<String>> {\r
- INSTANCE;\r
-\r
- @Override\r
- public Collection<String> perform(ReadGraph graph) throws DatabaseException {\r
- ArrayList<String> result = new ArrayList<String>(); \r
- \r
- Layer0 L0 = Layer0.getInstance(graph);\r
- browse(graph, L0, graph.getRootLibrary(), result);\r
- \r
- return result;\r
- }\r
-\r
- private static void browse(ReadGraph graph, Layer0 L0, Resource current,\r
- ArrayList<String> result) throws DatabaseException {\r
- if(graph.isInstanceOf(current, L0.Ontology))\r
- result.add(graph.getURI(current));\r
- else if(graph.isInstanceOf(current, L0.Library)) {\r
- for(Resource child : graph.getObjects(current, L0.ConsistsOf))\r
- browse(graph, L0, child, result);\r
- }\r
- }\r
-\r
-}\r
+package org.simantics.modeling.ui.scl.imports;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.request.Read;
+import org.simantics.layer0.Layer0;
+
+public enum OntologiesQuery implements Read<Collection<String>> {
+ INSTANCE;
+
+ @Override
+ public Collection<String> perform(ReadGraph graph) throws DatabaseException {
+ ArrayList<String> result = new ArrayList<String>();
+
+ Layer0 L0 = Layer0.getInstance(graph);
+ browse(graph, L0, graph.getRootLibrary(), result);
+
+ return result;
+ }
+
+ private static void browse(ReadGraph graph, Layer0 L0, Resource current,
+ ArrayList<String> result) throws DatabaseException {
+ if(graph.isInstanceOf(current, L0.Ontology))
+ result.add(graph.getURI(current));
+ else if(graph.isInstanceOf(current, L0.Library)) {
+ for(Resource child : graph.getObjects(current, L0.ConsistsOf))
+ browse(graph, L0, child, result);
+ }
+ }
+
+}