X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.db%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fdb%2FSCLFunctions.java;h=09022d543c1aba3e9101028c88ed939b72759963;hp=e20dfc471ad9ea28831463f00bc9bfc220d8704a;hb=b000e272429e157638c0384878b07b8dcd758472;hpb=159d04234f7fbf7554910a154b29a5dd7bbc6068 diff --git a/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java b/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java index e20dfc471..09022d543 100644 --- a/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java +++ b/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2019 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.scl.db; import java.io.IOException; @@ -112,7 +123,7 @@ public class SCLFunctions { } private static T evaluate(RuntimeModule rm, String function, Object ... args) throws ValueNotFound { - return evaluate(resolveFunction(rm, function)); + return evaluate(resolveFunction(rm, function), args); } public static T evaluate(String module, String function, Object ... args) throws ValueNotFound { @@ -140,7 +151,7 @@ public class SCLFunctions { } } - public static T evaluateGraph(String module, String function, Object graph, Object ... args) throws DatabaseException { + public static T evaluateGraph(String module, String function, ReadGraph graph, Object ... args) throws DatabaseException { final SCLContext context = SCLContext.getCurrent(); SCLContext.push(context); Object oldGraph = context.put(GRAPH, graph); @@ -152,6 +163,18 @@ public class SCLFunctions { } } + public static void runWithGraph(ReadGraph graph, Runnable r) { + final SCLContext context = SCLContext.getCurrent(); + SCLContext.push(context); + Object oldGraph = context.put(GRAPH, graph); + try { + r.run(); + } finally { + context.put(GRAPH, oldGraph); + SCLContext.pop(); + } + } + private static Object[] NO_ARGS = new Object[] { Tuple0.INSTANCE }; public static void asyncRead(final Function f) throws DatabaseException {