Skip to content

Commit 8250f25

Browse files
Textual Rules: evaluate global variables in the context of previous variables
1 parent 2c6fdb3 commit 8250f25

File tree

1 file changed

+1
-9
lines changed
  • bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal

1 file changed

+1
-9
lines changed

bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleContextHelper.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static synchronized IEvaluationContext getContext(RuleModel ruleModel) {
6161
for (VariableDeclaration var : ruleModel.getVariables()) {
6262
try {
6363
Object initialValue = var.getRight() == null ? null
64-
: scriptEngine.newScriptFromXExpression(var.getRight()).execute();
64+
: scriptEngine.newScriptFromXExpression(var.getRight()).execute(evaluationContext);
6565
evaluationContext.newValue(QualifiedName.create(var.getName()), initialValue);
6666
} catch (ScriptExecutionException e) {
6767
logger.warn("Variable '{}' on rule file '{}' cannot be initialized with value '{}': {}", var.getName(),
@@ -72,14 +72,6 @@ public static synchronized IEvaluationContext getContext(RuleModel ruleModel) {
7272
return evaluationContext;
7373
}
7474

75-
public static synchronized String getVariableDeclaration(RuleModel ruleModel) {
76-
StringBuilder vars = new StringBuilder();
77-
for (VariableDeclaration var : ruleModel.getVariables()) {
78-
vars.append(NodeModelUtils.findActualNodeFor(var).getText());
79-
}
80-
return vars.toString();
81-
}
82-
8375
/**
8476
* Inner class that wraps an evaluation context into an EMF adapters
8577
*/

0 commit comments

Comments
 (0)