import java.util.concurrent.CopyOnWriteArrayList;\r
\r
import org.simantics.Simantics;\r
+import org.simantics.databoard.Bindings;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.Session;\r
+import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
import org.simantics.db.request.Read;\r
import org.simantics.db.service.VirtualGraphSupport;\r
import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
import org.simantics.objmap.IMapping;\r
import org.simantics.objmap.IMappingListener;\r
import org.simantics.objmap.MappingException;\r
import org.simantics.objmap.Mappings;\r
import org.simantics.project.IProject;\r
+import org.simantics.scl.runtime.function.Function2;\r
+import org.simantics.scl.runtime.function.FunctionImpl2;\r
import org.simantics.simulation.experiment.IExperiment;\r
import org.simantics.simulation.model.IModel;\r
import org.simantics.simulation.ontology.SimulationResource;\r
\r
exp.init(g);\r
\r
+ Function2<WriteGraph, Resource, Object> scl = new FunctionImpl2<WriteGraph, Resource, Object>() {\r
+\r
+ @Override\r
+ public Object apply(WriteGraph graph, Resource run) {\r
+ try {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ ModelingResources MOD = ModelingResources.getInstance(graph);\r
+ Resource session = graph.newResource();\r
+ graph.claim(session, L0.InstanceOf, MOD.SCLCommandSession);\r
+ graph.addLiteral(session, L0.HasName, L0.NameOf, L0.String, "__scl__", Bindings.STRING);\r
+ graph.claim(run, L0.ConsistsOf, session);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ };\r
+ \r
VirtualGraphSupport support = g.getSession().getService(VirtualGraphSupport.class);\r
- ExperimentRuns.createRun(g.getSession(), support.getWorkspacePersistent("experiments"), experiment, exp, SysdynResource.URIs.Experiment_Run, listener, null);\r
+ ExperimentRuns.createRun(g.getSession(), support.getWorkspacePersistent("experiments"), experiment, exp, SysdynResource.URIs.Experiment_Run, listener, scl, null);\r
if(listener != null)\r
listener.onExperimentActivated(exp);\r
return exp;\r