X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2Frequest%2FServerSCLValueRequest.java;h=f9181d271073964b6082fef5119a679e8c371075;hp=5013f88146bbb232d48d8f27e8883df40fd81421;hb=7fe2a02ad295ec7406f44e8f86b7d25deedceb8b;hpb=66a5745bfefb159ce9d959bc29cbf148614e6fae 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 5013f8814..f9181d271 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 @@ -42,8 +42,6 @@ import org.slf4j.LoggerFactory; public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest { - private static final Logger LOGGER = LoggerFactory.getLogger(ServerSCLValueRequest.class); - private final Pair componentTypeAndRoot; private final Resource literal; protected String possibleExpectedValueType; @@ -88,8 +86,7 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< SCLContext sclContext = SCLContext.getCurrent(); Object oldGraph = sclContext.get("graph"); try { - Function1 exp = graph.syncRequest(new ServerSCLValueRequest(graph, context), - TransientCacheListener.>instance()); + Function1 exp = compile(graph, context); sclContext.put("graph", graph); return exp.apply(context); } catch (DatabaseException e) { @@ -100,6 +97,10 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< sclContext.put("graph", oldGraph); } } + + public static Function1 compile(ReadGraph graph, Variable context) throws DatabaseException { + return graph.syncRequest(new ServerSCLValueRequest(graph, context), TransientCacheListener.>instance()); + } @Override protected String getExpressionText(ReadGraph graph) @@ -203,13 +204,6 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< @Override protected Type getExpectedType(ReadGraph graph, CompilationContext context) throws DatabaseException { - if(possibleExpectedValueType != null) { - try { - return Environments.getType(context.runtimeEnvironment.getEnvironment(), possibleExpectedValueType); - } catch (SCLExpressionCompilationException e) { - LOGGER.error("Could not get type for " + String.valueOf(possibleExpectedValueType), e); - } - } return super.getExpectedType(graph, context); } @@ -228,4 +222,29 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< ServerSCLValueRequest other = (ServerSCLValueRequest)obj; return literal.equals(other.literal) && componentTypeAndRoot.equals(other.componentTypeAndRoot); } + + public static Function1 validate(ReadGraph graph, Variable context) throws DatabaseException { + return graph.syncRequest(new ServerSCLValueValidationRequest(graph, context), TransientCacheListener.>instance()); + } + + public static class ServerSCLValueValidationRequest extends ServerSCLValueRequest { + + private static final Logger LOGGER = LoggerFactory.getLogger(ServerSCLHandlerValueRequest.class); + + public ServerSCLValueValidationRequest(ReadGraph graph, Variable context) throws DatabaseException { + super(graph, context); + } + + @Override + protected Type getExpectedType(ReadGraph graph, CompilationContext context) throws DatabaseException { + if(possibleExpectedValueType != null) { + try { + return Environments.getType(context.runtimeEnvironment.getEnvironment(), possibleExpectedValueType); + } catch (SCLExpressionCompilationException e) { + LOGGER.error("Could not get type for " + String.valueOf(possibleExpectedValueType), e); + } + } + return super.getExpectedType(graph, context); + } + } }