[rules-users] Drools 5.5 Decision Tables - Add check without requiring user input

Stephen Masters stephen.masters at me.com
Mon Aug 5 12:31:10 EDT 2013


I'm not aware of an 'out of the box' mechanism for this. However, my own preference for doing this is to get the RHS insert a restriction fact. Essentially, you have no LHS, so that that all rules in the decision table will fire after creating a session, inserting something like:

Customer :: id = 1, active = true
Customer :: id = 2, active = false

As long as you hare setting a value on a boolean field you will see a tick box. That way, you have a pretty decision table with tick boxes to turn things off and on. You then just need a simple technical rule, which matches on those restriction facts. i.e. 

rule "Only permit active customers"
when
	$tran : TransactionRequest()
	Customer ( id == $tran.customerId, !active )
then
	insert(new TransactionRejection("Customer is not active.")) 
end

There is however, a performance issue with this technique. If you have a lot of such tables, then when you fire rules at the start of a session, a rule will activate for every row, and a series of insertions will occur. If you don't have many such insertions, then this may not take very long, but it's something to be aware of. This can be mitigated if you have a long running session, as there will be an impact during startup, but subsequently it should be fast.

It's a little bit fiddly, but can be well worth it to ensure that your Guvnor users have readable tables of rules.

Steve



On 5 Aug 2013, at 16:53, gboro54 <gboro54 at gmail.com> wrote:

> Hi!,
> 
>  For a decision table is there a way to have a condition column for which
> the user just specifies weather the condition is active or deactivate(i.e
> specify true or false) but which they only specify active or not.
> 
> Thanks,
> Mike
> 
> 
> 
> 
> --
> View this message in context: http://drools.46999.n3.nabble.com/Drools-5-5-Decision-Tables-Add-check-without-requiring-user-input-tp4025346.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list