if(modelRepository!=null && scriptEngine!=null) {
EObject model = modelRepository.getModel(modelName);
if (model instanceof RuleModel) {
RuleModel ruleModel = (RuleModel) model;
Rule rule = getRule(ruleModel, ruleName);
if(rule!=null) {
Script script = scriptEngine.newScriptFromXExpression(rule.getScript());
logger.debug("Executing scheduled rule '{}'", rule.getName());
try {
script.execute(RuleContextHelper.getContext(rule));
} catch (ScriptExecutionException e) {
logger.error("Error during the execution of rule {}", rule.getName(), e.getCause());
}
} else {
logger.debug("Scheduled rule '{}' does not exist", ruleName);
}
} else {