Skip to content
Merged
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 @@ -163,21 +163,24 @@ protected void setExecutionContext(ScriptEngine engine, Map<String, ?> context)

// Add the rule's UID to the context and make it available as "ctx".
// Note: We don't use "context" here as it doesn't work on all JVM versions!
final Map<String, Object> contextNew = new HashMap<>(context);
contextNew.put("ruleUID", this.ruleUID);
executionContext.setAttribute("ctx", contextNew, ScriptContext.ENGINE_SCOPE);

// Add the rule's UID to the global namespace.
executionContext.setAttribute("ruleUID", this.ruleUID, ScriptContext.ENGINE_SCOPE);

// add the single context entries without their prefix to the scope
final Map<String, Object> contextNew = new HashMap<>();
// add the single context entries without their prefix to contextNew
for (Entry<String, ?> entry : context.entrySet()) {
Object value = entry.getValue();
String key = entry.getKey();
int dotIndex = key.indexOf('.');
if (dotIndex != -1) {
key = key.substring(dotIndex + 1);
}
contextNew.put(key, value);
}
contextNew.put("ruleUID", this.ruleUID);
executionContext.setAttribute("ctx", contextNew, ScriptContext.ENGINE_SCOPE);

// add the single contextNew entries to the scope
for (Entry<String, ?> entry : contextNew.entrySet()) {
Object value = entry.getValue();
String key = entry.getKey();
executionContext.setAttribute(key, value, ScriptContext.ENGINE_SCOPE);
}
}
Expand Down