X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Frequest%2FAdaptValue.java;h=02877596b00d4423fac8387a31bdc73cdde76e87;hb=d0e8f57df83c175bac2098412ee71646fb9ff0e9;hp=c8bd03257f5783f0300ff08f1714069406bc48b1;hpb=ded784594eb0e1fb318fbb931135288152691cf2;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/AdaptValue.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/AdaptValue.java index c8bd03257..02877596b 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/AdaptValue.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/AdaptValue.java @@ -1,12 +1,13 @@ package org.simantics.db.common.request; -import org.simantics.db.ExternalValue; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.utils.Functions; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.RuntimeDatabaseException; import org.simantics.layer0.Layer0; +import org.simantics.scl.reflection.ReflectionUtils; +import org.simantics.scl.reflection.ValueNotFoundException; import org.simantics.scl.runtime.function.FunctionImpl3; /** @@ -19,7 +20,7 @@ public class AdaptValue extends ResourceRead { super(resource); } - public static final FunctionImpl3 functionApplication = new FunctionImpl3() { + private static final FunctionImpl3 functionApplication = new FunctionImpl3() { @Override public Object apply(ReadGraph graph, Resource resource, Object context) { @@ -35,11 +36,12 @@ public class AdaptValue extends ResourceRead { @Override public Object perform(ReadGraph graph) throws DatabaseException { String uri = graph.getURI(resource); - if(Layer0.URIs.Functions_functionApplication.equals(uri)) return functionApplication; - - ExternalValue ev = graph.adapt(resource, ExternalValue.class); - return ev.getValue(graph, resource); - + try { + if(Layer0.URIs.Functions_functionApplication.equals(uri)) return functionApplication; + return ReflectionUtils.getValue(uri).getValue(); + } catch (ValueNotFoundException e) { + throw new DatabaseException("Couldn't adapt the value " + uri, e); + } } }