import org.simantics.scl.osgi.SCLOsgi;
import org.simantics.scl.runtime.SCLContext;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Finds the environment of a model or other index root.
*/
public abstract class EnvironmentRequest extends UnaryRead<Resource, Pair<EnvironmentSpecification, Environment>> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(EnvironmentRequest.class);
public EnvironmentRequest(Resource parameter) {
super(parameter);
}
});
} catch (DatabaseException e) {
+ LOGGER.error("Finding environment failed", e);
callback.exception(e);
return;
}
environmentSpecification, listener);
callback.execute(env);
} catch (ImportFailureException e) {
+ LOGGER.error("Finding environment failed", e);
callback.exception(new DatabaseException(e));
}
else
mainModuleUri = graph.getURI(parameter) + "/#"; // Add something dummy to the model uri that cannot be in a real URI
- return Pair.make(environmentSpecification, graph.syncRequest(new ParametrizedPrimitiveRead<String, Environment>(mainModuleUri) {
-
- UpdateListenerImpl sclListener;
-
- @Override
- public void register(ReadGraph graph, Listener<Environment> procedure) {
-
- SCLContext context = SCLContext.getCurrent();
- Object oldGraph = context.put("graph", graph);
- try {
-
- if(procedure.isDisposed()) {
- getEnvironment(environmentSpecification, procedure, null);
- } else {
- sclListener = new UpdateListenerImpl(environmentSpecification, procedure);
- sclListener.notifyAboutUpdate();
+ try {
+ return Pair.make(environmentSpecification, graph.syncRequest(new ParametrizedPrimitiveRead<String, Environment>(mainModuleUri) {
+
+ UpdateListenerImpl sclListener;
+
+ @Override
+ public void register(ReadGraph graph, Listener<Environment> procedure) {
+
+ SCLContext context = SCLContext.getCurrent();
+ Object oldGraph = context.put("graph", graph);
+ try {
+
+ if(procedure.isDisposed()) {
+ getEnvironment(environmentSpecification, procedure, null);
+ } else {
+ sclListener = new UpdateListenerImpl(environmentSpecification, procedure);
+ sclListener.notifyAboutUpdate();
+ }
+
+ } finally {
+ context.put("graph", oldGraph);
}
-
- } finally {
- context.put("graph", oldGraph);
+
}
-
- }
-
- @Override
- public void unregistered() {
- if(sclListener != null)
- sclListener.stopListening();
- }
-
- }));
+
+ @Override
+ public void unregistered() {
+ if(sclListener != null)
+ sclListener.stopListening();
+ }
+
+ }));
+ } catch(DatabaseException e) {
+ LOGGER.error("Environment request failed", e);
+ throw e;
+ }
}
@Override
package org.simantics.modeling.scl.ontologymodule;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import org.simantics.db.common.uri.UnescapedChildMapOfResource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.util.EnvironmentRequest;
-import org.simantics.db.layer0.util.RuntimeEnvironmentRequest;
import org.simantics.db.request.Read;
import org.simantics.layer0.Layer0;
import org.simantics.scl.compiler.common.names.Name;
public static final String SCL_TYPES_NAME = "SCLTypes";
private static final String DB_MODULE = "Simantics/DB";
private static final String VARIABLE_MODULE = "Simantics/Variable";
- private static final Collection<ImportDeclaration> DEPENDENCIES = Arrays.asList(
- new ImportDeclaration(DB_MODULE, null),
- new ImportDeclaration(VARIABLE_MODULE, null)
- );
private static final TCon RESOURCE = Types.con(DB_MODULE, "Resource");
private static final TCon BROWSABLE = Types.con(DB_MODULE, "Browsable");
private static final TCon VARIABLE = Types.con(VARIABLE_MODULE, "Variable");
private Resource ontology;
private String defaultLocalName;
- private THashMap<Resource,Map<String,Resource>> childMaps = new THashMap<Resource,Map<String,Resource>>();
- private List<ImportDeclaration> importDeclarations;
+ private THashMap<Resource,Map<String,Resource>> childMaps = new THashMap<>();
+ private ArrayList<ImportDeclaration> importDeclarations = new ArrayList<>();
private Environment environment;
public OntologyModule(ReadGraph graph, String moduleName) throws DatabaseException {
});
}
});
- this.importDeclarations = pair.first.imports;
+ for(ImportDeclaration decl : pair.first.imports)
+ importDeclarations.add(decl.hidden());
this.environment = pair.second;
}
public final Resource resource;
public JustResource(Resource resource) {
this.resource = resource;
- }
+ }
+ @Override
+ public String toString() {
+ return "JustResource(" + resource + ")";
+ }
}
private static class ResourceAndSuffix implements ResourceSearchResult {
public final Resource resource;
public ResourceAndSuffix(Resource resource, String suffix) {
this.resource = resource;
this.suffix = suffix;
- }
+ }
+ @Override
+ public String toString() {
+ return "ResourceAndSuffix(" + resource + ", " + suffix + ")";
+ }
}
private ResourceSearchResult getResourceOrSuffixedResource(String name) {