1 package org.simantics.modeling.scl.ontologymodule;
4 import java.util.Collection;
5 import java.util.Collections;
7 import org.simantics.Simantics;
8 import org.simantics.db.ReadGraph;
9 import org.simantics.db.common.request.UnaryRead;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.scl.compiler.module.repository.UpdateListener;
12 import org.simantics.scl.compiler.source.ModuleSource;
13 import org.simantics.scl.compiler.source.PrecompiledModuleSource;
14 import org.simantics.scl.compiler.source.repository.ModuleSourceRepository;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 import gnu.trove.procedure.TObjectProcedure;
20 public enum OntologyModuleSourceRepository implements ModuleSourceRepository {
23 private static final Logger LOGGER = LoggerFactory.getLogger(OntologyModuleSourceRepository.class);
25 static class ModuleSourceRequest extends UnaryRead<String, ModuleSource> {
27 public ModuleSourceRequest(String moduleName) {
32 public ModuleSource perform(ReadGraph graph) throws DatabaseException {
33 return new PrecompiledModuleSource(new OntologyModule(graph, parameter), -1.0);
39 public ModuleSource getModuleSource(final String moduleName,
40 UpdateListener listener) {
41 if(!moduleName.startsWith("http://"))
42 return null; // Don't do a graph request if this cannot be a resource
45 return Simantics.getAvailableRequestProcessor().syncRequest(new ModuleSourceRequest(moduleName));
46 } catch(DatabaseException e) {
47 LOGGER.error("Failed to read ontology module " + moduleName + ".", e);
53 public void forAllModules(TObjectProcedure<String> procedure) {
57 public Collection<String> getModuleNames() {
58 return Collections.emptyList();