public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest<CompilationContext, Variable> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ServerSCLValueRequest.class);
-
private final Pair<Resource,Resource> componentTypeAndRoot;
private final Resource literal;
protected String possibleExpectedValueType;
SCLContext sclContext = SCLContext.getCurrent();
Object oldGraph = sclContext.get("graph");
try {
- Function1<Variable,Object> exp = graph.syncRequest(new ServerSCLValueRequest(graph, context),
- TransientCacheListener.<Function1<Variable,Object>>instance());
+ Function1<Variable,Object> exp = compile(graph, context);
sclContext.put("graph", graph);
return exp.apply(context);
} catch (DatabaseException e) {
sclContext.put("graph", oldGraph);
}
}
+
+ public static Function1<Variable, Object> compile(ReadGraph graph, Variable context) throws DatabaseException {
+ return graph.syncRequest(new ServerSCLValueRequest(graph, context), TransientCacheListener.<Function1<Variable,Object>>instance());
+ }
@Override
protected String getExpressionText(ReadGraph graph)
@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);
}
ServerSCLValueRequest other = (ServerSCLValueRequest)obj;
return literal.equals(other.literal) && componentTypeAndRoot.equals(other.componentTypeAndRoot);
}
+
+ public static Function1<Variable, Object> validate(ReadGraph graph, Variable context) throws DatabaseException {
+ return graph.syncRequest(new ServerSCLValueValidationRequest(graph, context), TransientCacheListener.<Function1<Variable,Object>>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);
+ }
+ }
}