X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fadapter%2FSCLComputationalValue.java;fp=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fadapter%2FSCLComputationalValue.java;h=83382adb3325eaa128087ff3161c44f18755b54c;hb=15f274a205dabc11df9bf880291320fa5274e535;hp=0000000000000000000000000000000000000000;hpb=9c7a45d78da0d2b99f3a365c39dfc3f2e7221e24;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/SCLComputationalValue.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/SCLComputationalValue.java new file mode 100644 index 000000000..83382adb3 --- /dev/null +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/SCLComputationalValue.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2018 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.db.layer0.adapter; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.scl.CompileResourceValueRequest; +import org.simantics.db.layer0.scl.CompileValueRequest; +import org.simantics.scl.runtime.function.Function1; + +/** + * @author Antti Villberg + * @since 1.36.0 + */ +public class SCLComputationalValue extends ContextualRelatedValue { + + @Override + public Function1 getFunction(ReadGraph graph, Resource s, Resource o, Resource p) throws DatabaseException { + if (s != null && p != null && o != null) { + return CompileValueRequest.compile(graph, s, o, p); + } else if (o != null) { + return CompileResourceValueRequest.compile(graph, o); + } else { + throw new DatabaseException("Could not compile SCL expression: s=" + s + " p=" + p + " o=" + o); + } + } + +}