Skip to content

Commit

Permalink
[DROOLS-7635] ansible-rulebook : Raise an error when a condition comp…
Browse files Browse the repository at this point in the history
…ares incompatible types (kiegroup#123)

- don't miss to populate ruleSetName when runtime is used
  • Loading branch information
tkobayas committed Oct 29, 2024
1 parent 0985888 commit 16c648b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class Rule {

private final RuleGenerationContext ruleGenerationContext = new RuleGenerationContext();

private String ruleSetName;

private String name;

private Action action;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,23 @@ List<Rule> toExecModelRules(RulesSet rulesSet, org.drools.ansible.rulebook.integ
if (getRuleName() == null) {
setRuleName("r_" + ruleCounter.getAndIncrement());
}
setRuleSetName(rulesSet.getName());


List<org.drools.model.Rule> rules = createRules(rulesExecutionController);
if (hasTemporalConstraint(ansibleRule)) {
rulesSet.withOptions(RuleConfigurationOption.EVENTS_PROCESSING);
}
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<K, V> {
private final Deque<Map<K, V>> stack = new ArrayDeque<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public List<RuleContainer> getRules() {

public void setRules(List<RuleContainer> rules) {
this.rules = rules;
rules.forEach(ruleContainer -> ruleContainer.getRule().setRuleSetName(name));
}

public Rule addRule() {
Expand Down

0 comments on commit 16c648b

Please sign in to comment.