I am trying to define the conditions of my Drools rules in configuration (as a JSON) so that they can be easily parsed. For example, one of my Drools rules currently looks like this:
rule "Rule 1"
salience 100
activation-group "xxx"
when
key1( key1() == "value1" )
key2( key2() == "value2" )
key3( List.of("value3a", "value3b").contains(key3()) )
then
...
Instead of this I want to define the condition for each rule in a JSON file. Example:
{
"key1": ["value1"],
"key2": ["value2"],
"key3": ["value3a", "value3b"],
"returnValue": "Rule1Result"
}
I would want to be able to iterate through the objects in the JSON file and match the request against each of key/value pairs, and return whatever is in the "returnValue" field. Although hardcoding the rule conditions in code satisfies my business requirements, I am looking at moving the conditions into a JSON file for better testability, and to make it easier to parse the conditions for display on a UI.
Is there any easy way through Drools to accomplish this? Or are there any other rule engine solutions which may be better suited? Thanks!