diff --git a/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/Rule.java b/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/Rule.java index fd05d16..23c87b8 100644 --- a/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/Rule.java +++ b/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/Rule.java @@ -21,6 +21,8 @@ public class Rule { private final RuleGenerationContext ruleGenerationContext = new RuleGenerationContext(); + private String ruleSetName; + private String name; private Action action; @@ -31,6 +33,14 @@ public class Rule { private Condition condition; + public String getRuleSetName() { + return ruleSetName; + } + + public void setRuleSetName(String ruleSetName) { + this.ruleSetName = ruleSetName; + } + public String getName() { return name; } diff --git a/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/RuleGenerationContext.java b/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/RuleGenerationContext.java index 577a169..51c4fb7 100644 --- a/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/RuleGenerationContext.java +++ b/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/RuleGenerationContext.java @@ -224,8 +224,7 @@ List toExecModelRules(RulesSet rulesSet, org.drools.ansible.rulebook.integ if (getRuleName() == null) { setRuleName("r_" + ruleCounter.getAndIncrement()); } - setRuleSetName(rulesSet.getName()); - + List rules = createRules(rulesExecutionController); if (hasTemporalConstraint(ansibleRule)) { rulesSet.withOptions(RuleConfigurationOption.EVENTS_PROCESSING); @@ -233,14 +232,15 @@ List toExecModelRules(RulesSet rulesSet, org.drools.ansible.rulebook.integ return rules; } - private void updateContextFromRule(org.drools.ansible.rulebook.integration.api.domain.Rule anisbleRule) { - setRuleName(anisbleRule.getName()); - setAction(anisbleRule.getAction()); - if (anisbleRule.getOptions() != null) { - addOptions(anisbleRule.getOptions().getOptions()); - } - setCondition(anisbleRule.getCondition()); - } + private void updateContextFromRule(org.drools.ansible.rulebook.integration.api.domain.Rule anisbleRule) { + setRuleSetName(anisbleRule.getRuleSetName()); + setRuleName(anisbleRule.getName()); + setAction(anisbleRule.getAction()); + if (anisbleRule.getOptions() != null) { + addOptions(anisbleRule.getOptions().getOptions()); + } + setCondition(anisbleRule.getCondition()); + } private static class StackedContext { private final Deque> stack = new ArrayDeque<>(); diff --git a/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/RulesSet.java b/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/RulesSet.java index 4606d6c..a304353 100644 --- a/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/RulesSet.java +++ b/drools-ansible-rulebook-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/domain/RulesSet.java @@ -82,6 +82,7 @@ public List getRules() { public void setRules(List rules) { this.rules = rules; + rules.forEach(ruleContainer -> ruleContainer.getRule().setRuleSetName(name)); } public Rule addRule() {