Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.xbase.interpreter.IEvaluationContext;
import org.openhab.core.model.rule.RulesStandaloneSetup;
import org.openhab.core.model.rule.rules.RuleModel;
Expand Down Expand Up @@ -61,7 +60,7 @@ public static synchronized IEvaluationContext getContext(RuleModel ruleModel) {
for (VariableDeclaration var : ruleModel.getVariables()) {
try {
Object initialValue = var.getRight() == null ? null
: scriptEngine.newScriptFromXExpression(var.getRight()).execute();
: scriptEngine.newScriptFromXExpression(var.getRight()).execute(evaluationContext);
evaluationContext.newValue(QualifiedName.create(var.getName()), initialValue);
} catch (ScriptExecutionException e) {
logger.warn("Variable '{}' on rule file '{}' cannot be initialized with value '{}': {}", var.getName(),
Expand All @@ -72,14 +71,6 @@ public static synchronized IEvaluationContext getContext(RuleModel ruleModel) {
return evaluationContext;
}

public static synchronized String getVariableDeclaration(RuleModel ruleModel) {
StringBuilder vars = new StringBuilder();
for (VariableDeclaration var : ruleModel.getVariables()) {
vars.append(NodeModelUtils.findActualNodeFor(var).getText());
}
return vars.toString();
}

/**
* Inner class that wraps an evaluation context into an EMF adapters
*/
Expand Down