1 /*******************************************************************************
2 * Copyright (c) 2018 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.layer0.adapter;
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.layer0.scl.CompileResourceValueRequest;
18 import org.simantics.db.layer0.scl.CompileValueRequest;
19 import org.simantics.scl.runtime.function.Function1;
22 * @author Antti Villberg
25 public class SCLComputationalValue extends ContextualRelatedValue {
27 // TODO: unify and merge CompileValueRequest and CompileResourceValueRequest as one
29 public Function1<Object,Object> getFunction(ReadGraph graph, Resource s, Resource o, Resource p) throws DatabaseException {
30 if (p != null && o != null) {
31 // we are now at Variable context
32 return CompileValueRequest.compile(graph, o, p);
33 } else if (o != null) {
34 // we are now at Resource context
35 return CompileResourceValueRequest.compile(graph, o);
37 throw new DatabaseException("Could not compile SCL expression: s=" + s + " p=" + p + " o=" + o);