I am developing a rating system based on Drool Rules to replace a old one made with ASP and a relational DB.
Everything is running very good as expected, but some rules become very extensive because the rating system needs to compare a lot of constant values with the input - I do not want to back to the solution of using an external database.
A this moment, there is some standard data structure that should be use to persist lot of constant values? I know it is possible to construct a Java structure for that ... but my objective is to give the rules file to the sales team, who barely understand Java but they are very good with ratios.
For example, I want to replace this with something more clean:
if("A".equals($inpt)) { $outpt = 0.1; }
else if("B".equals($inpt)) { $outpt = 0.2; }
else if("C".equals($inpt)) { $outpt = 0.3; }
I'll have to guess a little. Let's say you have
rule "set output"
when
$s: Something( $input: input )
InToOut( input == $input, $output: output )
then
modify( $s ){ setOutput( $output ) }
end
Your sales team members will surely understand if you give them the skeleton
rule "setInToOut"
salience 999999999
when
then
insert( new InToOut( "A", 0.1 ) );
insert( new InToOut( "B", 0.2 ) );
...
end
You can simplify this with a function.