import org.simantics.db.Statement;
import org.simantics.db.common.procedure.adapter.TransientCacheListener;
import org.simantics.db.common.request.IndexRoot;
-import org.simantics.db.common.request.PossibleTypedParent;
import org.simantics.db.common.request.UnaryRead;
import org.simantics.db.common.utils.NameUtils;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.scl.AbstractExpressionCompilationContext;
-import org.simantics.db.layer0.scl.AbstractExpressionCompilationRequest;
import org.simantics.db.layer0.util.RuntimeEnvironmentRequest2;
import org.simantics.db.layer0.variable.Variable;
-import org.simantics.document.base.ontology.DocumentationResource;
-import org.simantics.document.server.request.ServerSCLValueRequest.CompilationContext;
import org.simantics.layer0.Layer0;
import org.simantics.scl.compiler.common.names.Name;
import org.simantics.scl.compiler.constants.StringConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest<CompilationContext, Object> {
+public class ServerSCLValueRequest extends ServerSCLValueRequestBase<org.simantics.document.server.request.ServerSCLValueRequest.CompilationContext> {
private final Pair<Resource,Resource> componentTypeAndRoot;
private final Resource literal;
return Pair.make(parent.getType(graph), root);
}
- private static Pair<Resource,Resource> getComponentTypeAndRoot(ReadGraph graph, Resource component, Resource literal) throws DatabaseException {
- if(component != null) {
- Resource type = graph.syncRequest(new FindPossibleComponentTypeRequest(component));
- if(type != null) {
- Resource root = graph.syncRequest(new IndexRoot(type));
- // System.err.println("getComponentTypeAndRoot3 " + graph.getPossibleURI(component) + " => " + graph.getPossibleURI(type) + " " + graph.getPossibleURI(root));
- return Pair.make(type, root);
- } else {
- Resource doc = graph.syncRequest(new PossibleTypedParent(component, DocumentationResource.getInstance(graph).Document));
- if(doc != null) {
- Resource componentType = graph.getSingleType(doc);
- Resource root = graph.syncRequest(new IndexRoot(doc));
- return Pair.make(componentType, root);
- } else {
- //System.err.println("component = " + component);
- Resource root = graph.syncRequest(new IndexRoot(component));
-// Resource componentType = graph.getSingleType(doc);
- return Pair.make(null, root);
- }
- }
- // TODO: For Antti to consider and fix later
- // Introduced to handle procedural user components where component == null
- } else if (literal != null) {
- Resource root = graph.syncRequest(new IndexRoot(literal));
- return Pair.make(null, root);
- } else {
- throw new DatabaseException("Couldn't resolve component type and root for component == null && literal == null");
- }
- }
-
public static Object compileAndEvaluate(ReadGraph graph, Variable context) throws DatabaseException {
SCLContext sclContext = SCLContext.getCurrent();
- Object oldGraph = sclContext.get("graph");
+ Object oldGraph = sclContext.get("graph");
try {
Function1<Object,Object> exp = compile(graph, context);
sclContext.put("graph", graph);
} catch (Throwable t) {
throw new DatabaseException(t);
} finally {
- sclContext.put("graph", oldGraph);
+ sclContext.put("graph", oldGraph);
}
}