1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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.db.layer0.request;
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.common.ResourceArray;
17 import org.simantics.db.common.exception.DebugException;
18 import org.simantics.db.common.request.BinaryRead;
19 import org.simantics.db.exception.AdaptionException;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.db.exception.ResourceNotFoundException;
22 import org.simantics.db.layer0.exception.MissingVariableException;
23 import org.simantics.db.layer0.variable.Variable;
24 import org.simantics.db.layer0.variable.VariableInterface;
26 public class PossibleExperimentVariable extends BinaryRead<String, ResourceArray, Variable> {
28 public PossibleExperimentVariable(String experiment, ResourceArray resource) {
29 super(experiment, resource);
33 public Variable perform(ReadGraph graph) throws DatabaseException {
37 Resource tail = parameter2.tail();
38 Resource head = parameter2.head();
40 if(!graph.hasStatement(tail)) return null;
42 String valuationName = parameter;
44 Resource model = graph.syncRequest(new PossibleModel(head));
45 if (model == null) return null;
47 VariableInterface variableInterface = graph.adapt(model, VariableInterface.class);
48 Variable modelVariable = graph.adapt(model, Variable.class);
49 Variable experimentVariable = modelVariable.browse(graph, valuationName);
50 return variableInterface.getVariable(graph, experimentVariable, parameter2);
52 } catch (MissingVariableException e) {
53 if (DebugException.DEBUG)
56 } catch (ResourceNotFoundException e) {
57 if (DebugException.DEBUG)
60 } catch (AdaptionException e) {
61 if (DebugException.DEBUG)
64 } catch (Throwable e) {
65 if (DebugException.DEBUG)