X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fadapter%2FSCLExternalValue.java;fp=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fadapter%2FSCLExternalValue.java;h=12e950c87b32af060701a94ee4c291966798941f;hb=3850fec72035293b9a4ede780d01aedc5fbc9056;hp=0000000000000000000000000000000000000000;hpb=1e957fc9da518f3bef8a2c19cad72772087e1b6a;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/SCLExternalValue.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/SCLExternalValue.java new file mode 100644 index 000000000..12e950c87 --- /dev/null +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/SCLExternalValue.java @@ -0,0 +1,29 @@ +package org.simantics.db.layer0.adapter; + +import org.simantics.db.ConverterExternalValue; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.scl.CompileValueRequest; +import org.simantics.layer0.Layer0; +import org.simantics.scl.reflection.ReflectionUtils; +import org.simantics.scl.reflection.ValueNotFoundException; +import org.simantics.scl.runtime.function.Function1; + +public class SCLExternalValue implements ConverterExternalValue { + + @Override + public T getValue(ReadGraph graph, Resource resource) throws DatabaseException { + try { + return (T)ReflectionUtils.getValue(Layer0.URIs.Functions_computeExpression).getValue(); + } catch (ValueNotFoundException e) { + throw new DatabaseException(e); + } + } + + @Override + public Function1 getFunction(ReadGraph graph, Resource s, Resource o, Resource p) throws DatabaseException { + return CompileValueRequest.compile(graph, s, o, p); + } + +}