Which version are you using? Latest versions support named consequences,
which allow to rules in a more compact form:
when
A() do[a]
( B() do[b]
or
C() do[c]
)
D() do[d]
then
// main consequence here
then[a]
// this will be executed when A() is matched
then[b]
// A() B()
then[c]
// A() C()
then[d]
// same as main consequence
end
You can then use the main consequence for your normal business logic.
In a rule's consequence you can also use the context variables "drools"
or "kcontext", of type KnowledgeHelper and KnowledgeRuntime respectively.
They expose some context information such as the rule being fired and
the tuple (and thus the chain of facts) that led to the activation.
If this is not enough, you may have to customize the engine and extend
the condition nodes (alpha and beta) to fire events when a fact or a tuple
satisfies the local constraints. It's not terribly difficult to do, but
not immediate either.
Best
Davide
On 11/20/2013 04:40 PM, Isaac Martin wrote:
I preface this with saying that you should be doing what Mark
suggests. If what he suggests is going to create "too many drools" or
"clutter your files" then I'd recommend putting them in a decision
table.
Another way you could get information like this is to use the event
listeners built into drools in order to give you information about
activation events. For example, you could have a listener print out
the antecedents to a drool in the beforeActivationFired method.
On Wed, Nov 20, 2013 at 1:18 PM, Mark Proctor <mproctor(a)codehaus.org
<mailto:mproctor@codehaus.org>> wrote:
create additional rules, with just the patterns you know you want
to match and record the result in the consequence - so you can
check/assert later.
Mark
On 20 Nov 2013, at 20:49, swaroop <swaroop.oggu(a)gmail.com
<mailto:swaroop.oggu@gmail.com>> wrote:
> Hi ,
>
> Is there any way to determine which conditions matched/passed
from list of
> conditions defined for a rule . Also it would be helpful to know
if there is
> any means to relate a fact and the rule fired. In the below
mentioned rule
> can we know which condition passed ?
>
> Eg;
> rule "check which Object matched"
> when
> Any of following conditions are true
> Condition1
> Condition2
> Condition3
> then
> insert(Obj A)
>
>
> Regards
> Oggu
>
>
>
> --
> View this message in context:
http://drools.46999.n3.nabble.com/How-to-know-which-condition-passed-from...
> Sent from the Drools: User forum mailing list archive at
Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org <mailto:rules-users@lists.jboss.org>
>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org <mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users