1 package org.simantics.document.linking.report.evaluator;
5 import org.eclipse.jface.resource.ImageDescriptor;
6 import org.simantics.db.ReadGraph;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.document.linking.Activator;
9 import org.simantics.document.linking.ontology.DocumentLink;
10 import org.simantics.document.linking.utils.SourceLinkUtil;
11 import org.simantics.objmap.graph.annotations.GraphType;
12 import org.simantics.objmap.graph.annotations.RelatedGetValue;
13 import org.simantics.objmap.graph.annotations.RelatedSetValue;
16 @GraphType(DocumentLink.URIs.EvaluatorTree_Variable)
17 public class Variable extends EvaluatorLeaf implements StringEditableNode{
19 String variableRef = "#HasName";
25 public Variable(String variableRef) {
26 this.variableRef = variableRef;
29 public void setVariableRef(String variableRef) {
30 this.variableRef = variableRef;
33 public String getVariableRef() {
38 public String getValue(ReadGraph graph, org.simantics.db.layer0.variable.Variable variable, Map<Object, Object> context) throws DatabaseException {
39 if (context.containsKey(variableRef))
40 return SourceLinkUtil.getValueString(context.get(variableRef));
42 org.simantics.db.layer0.variable.Variable propertyVar = PredefinedVariables.getInstance().getVariable(graph, variableRef, null, variable);
43 if (propertyVar.getRepresents(graph) == null)
45 return SourceLinkUtil.getValueString(propertyVar.getValue(graph));
46 } catch (Exception e) {
55 public String toString() {
59 @RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
61 public String getValue() {
67 public String setValue(String value) {
68 if (value.length() == 0)
69 return "Variable reference cannot be empty";
74 @RelatedSetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
75 public void _setValue(String value) {
81 public EvaluatorItem copy() {
82 return new Variable(variableRef);
86 public ImageDescriptor getImage() {
87 return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/database_go.png");