1 package org.simantics.db.layer0.variable;
3 import org.simantics.databoard.util.Bean;
4 import org.simantics.db.ReadGraph;
5 import org.simantics.db.Resource;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.service.SerialisationSupport;
9 public class VariableBean extends Bean {
11 final public long context;
12 final public String rvi;
13 final transient public Variable variable;
15 public VariableBean(ReadGraph graph, Variable variable) throws DatabaseException {
17 Variable context = Variables.getPossibleContext(graph, variable);
19 RVI rvi = variable.getRVI(graph);
20 Resource contextResource = context.getRepresents(graph);
21 this.context = contextResource.getResourceId();
22 this.rvi = rvi.toString();
25 this.rvi = variable.getURI(graph);
28 this.variable = variable;
32 public Variable getVariable(ReadGraph graph) throws DatabaseException {
34 Resource contextResource = graph.getService(SerialisationSupport.class).getResource(context);
35 Variable context = Variables.getVariable(graph, contextResource);
36 RVI rvi = RVI.fromResourceFormat(graph, this.rvi);
37 return rvi.resolve(graph, context);
39 return Variables.getVariable(graph, rvi);
43 public Variable getVariable() {