1 /*******************************************************************************
2 * Copyright (c) 2012 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 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.modeling.adapters;
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.common.utils.Logger;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.db.layer0.request.PossibleActiveExperimentPath;
19 import org.simantics.db.layer0.variable.Variable;
20 import org.simantics.db.layer0.variable.Variables;
21 import org.simantics.scl.runtime.function.FunctionImpl2;
24 * f: (ReadGraph, Resource model) -> Variable activeExperiment
26 * @author Tuukka Lehtonen
28 public class ActiveExperiment extends FunctionImpl2<ReadGraph, Resource, Variable> {
31 public Variable apply(ReadGraph p0, Resource p1) {
33 ReadGraph graph = (ReadGraph) p0;
34 Resource model = (Resource) p1;
36 String activeExperimentPath = graph.syncRequest(new PossibleActiveExperimentPath(model));
37 if (activeExperimentPath == null)
40 Variable var = Variables.getPossibleVariable(graph, model);
43 Variable run = var.browsePossible(graph, activeExperimentPath);
45 } catch (DatabaseException e) {
46 Logger.defaultLogError(e);