X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2Frequest%2FServerSCLValueRequest.java;fp=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2Frequest%2FServerSCLValueRequest.java;h=7f9473861708decb38097a0ee5530657956820a1;hb=63369acd7e6020a2148f40f6bab96b0b2ba392d8;hp=adff8dab5b9ec87d1271e1ca02d1d3bea58e49a3;hpb=89539b3b9d550028d15c6abcc9ecee3423d5a4a7;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java index adff8dab5..7f9473861 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java @@ -45,7 +45,7 @@ import org.simantics.utils.datastructures.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest { +public class ServerSCLValueRequest extends ServerSCLValueRequestBase { private final Pair componentTypeAndRoot; private final Resource literal; @@ -91,39 +91,9 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< return Pair.make(parent.getType(graph), root); } - private static Pair 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 exp = compile(graph, context); sclContext.put("graph", graph); @@ -133,7 +103,7 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< } catch (Throwable t) { throw new DatabaseException(t); } finally { - sclContext.put("graph", oldGraph); + sclContext.put("graph", oldGraph); } }