rulebook icon indicating copy to clipboard operation
rulebook copied to clipboard

Help : How to execute CoRRuleBook rules using SpringAwareRuleBookRunner

Open asasisekar opened this issue 5 years ago • 2 comments

Hi,

We have defined the rules by extending the CoRRuleBook as below and created the bean using SpringAwareRuleBookRunner. When executing the rule, results are set as null. Within the CoRRuleBook, results was set as expected but AbstractRuleBookRunner was not considering the results.

public class TestRuleBook extends CoRRuleBook<String> {
  @Override
  public void defineRules() {
    addRule(
        RuleBuilder.create()
            .withFactType(ValidationRequest.class)
            .withResultType(String.class)
            .when(InsertIdRuleBook::isInvalid)
            .then((facts, result) -> result.setValue("Invalid")))
            .build());
  }
}
@Configuration
public class ApplicationConfig {
  @Bean
  RuleBook testRuleBook() {
    return new SpringAwareRuleBookRunner(
        TestRuleBook.class, "package name");
  }
}

Is SpringAwareRuleBookRunner only supports the POJO rules? Is there a way to execute the CoRRuleBook rules using runner class?

asasisekar avatar Jan 01 '20 22:01 asasisekar

Not with the runner class. The runner's function is to create a RuleBook from annotated pojo rules.

Clayton7510 avatar Jan 22 '20 21:01 Clayton7510

Did that response answer your question?

Clayton7510 avatar Feb 04 '20 16:02 Clayton7510