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.exception.DebugException;
17 import org.simantics.db.common.request.BinaryRead;
18 import org.simantics.db.exception.AdaptionException;
19 import org.simantics.db.exception.DatabaseException;
20 import org.simantics.db.exception.ResourceNotFoundException;
21 import org.simantics.db.layer0.exception.MissingVariableException;
22 import org.simantics.db.layer0.variable.Variable;
24 public class PossibleActiveVariableFromURI extends BinaryRead<Resource, String, Variable> {
26 public PossibleActiveVariableFromURI(Resource model, String uri) {
31 public Variable perform(ReadGraph graph) throws DatabaseException {
33 String valuationName = null;
35 Resource model = parameter;
36 if (model == null) return null;
38 String valuation = graph.syncRequest(new PossibleActiveExperimentPath(model));
39 if(valuation != null) valuationName = valuation;
41 if (valuationName == null) {
42 valuationName = "/BaseRealization";
45 Variable modelVariable = graph.adapt(model, Variable.class);
46 Variable experimentVariable = modelVariable.browse(graph, valuationName+parameter2);
47 return experimentVariable;
48 } catch (MissingVariableException e) {
49 if (DebugException.DEBUG)
52 } catch (ResourceNotFoundException e) {
53 if (DebugException.DEBUG)
56 } catch (AdaptionException e) {
57 if (DebugException.DEBUG)
60 } catch (Throwable e) {
61 if (DebugException.DEBUG)