+
+ public static Function1<Object, Object> validate(ReadGraph graph, Variable context) throws DatabaseException {
+ return graph.syncRequest(new ServerSCLValueValidationRequest(graph, context), TransientCacheListener.instance());
+ }
+
+ @Override
+ protected String getContextDescription(ReadGraph graph) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ Statement possibleOwner = graph.getPossibleStatement(literal, L0.IsOwnedBy);
+ if(possibleOwner != null) {
+ String uri = graph.getPossibleURI(possibleOwner.getObject());
+ if(uri != null) {
+ String propertyName = NameUtils.getSafeName(graph, graph.getInverse(possibleOwner.getPredicate()));
+ return uri + "#" + propertyName;
+ }
+ }
+ return super.getContextDescription(graph);
+ }
+
+ 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);
+ }
+ }