[rules-users] Reusing rules outside a workflow

Gerald Klopp Gerald.Klopp at arhs-developments.com
Mon May 9 13:10:56 EDT 2011


Hello,

- I have a set of rules attached to a workflow using the ruleflow-group
attribute.
I'd like to reuse these rules in another context outside the workflow.
What's the best solution to do this?

- I tried to use rules inheritance with the extends keywords but this
solution is not working as the RHS of the base rule is not executed.
More over, it is not very convenient as new rules have to be created and
maintained.

- Here is a very simple example to illustrate my problem:

I'd like to reuse this rule outside my workflow:
rule "firstNameIsEmpty"
    ruleflow-group "validate-person"    
when
    Person(firstName == null || firstName == "")
then
    System.out.println("ERROR : Empty first name");
end

One possible solution would be to create one base rule that could be reused
outside the workflow:
rule "firstNameIsEmpty"
when
    Person(firstName == null || firstName == "")
then
    System.out.println("ERROR : Empty first name");
end

and another rule for the workflow:
rule "firstNameIsEmptyInRuleFlowGroup" extends "firstNameIsEmpty"
    ruleflow-group "validate-person"    
when
then
end

But, in this case, the RHS of the base class (System.out) is not executed.

Is there another solution to solve this problem?

Thanks

--
View this message in context: http://drools.46999.n3.nabble.com/Reusing-rules-outside-a-workflow-tp2919637p2919637.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list