[rules-users] getting details of facts triggering rules
Mark Proctor
mproctor at codehaus.org
Wed Feb 23 00:09:08 EST 2011
On 16/02/2011 20:47, Archie Russell wrote:
>
> Hi,
>
> I've tried to figure this out but haven't been able to.
>
> How can I, from the RHS, figure out the details of what triggered a rule.
> I can access the facts individually by name, but how do I do it in a
> generic fashion that would work in the RHS of any rule?
Look at RuleContext.getActivation()
You can use either the deprecated "drools" identifier or the new
kcontext to achieve this. getACtivation has the following methods:
/**
*
* @return
* The PropagationContext that created this Activation
*/
PropagationContext getPropagationContext();
/**
*
* @return
* The matched FactHandles for this activation
*/
List< ? extends FactHandle> getFactHandles();
/**
* Returns the list of objects that make the tuple that created
* this activation. The objects are in the proper tuple order.
*
* @return
*/
List< Object > getObjects();
/**
* Returns the list of declaration identifiers that are bound to the
* tuple that created this activation.
*
* @return
*/
List< String > getDeclarationIDs();
/**
* Returns the bound declaration value for the given declaration
identifier.
*
* @param declarationId
* @return
*/
Object getDeclarationValue( String declarationId );
Mark
>
> I am using decisiontables and want to be able to have a function that is
> something like printTriggeringDetails()
>
> I came across drools.getTuple but am not sure if that's the correct path
> to go on. From there I get InternalFactHandles but don't know how to
> turn
> those into human-readable facts.
>
> Thanks for any help,
> Archie
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110223/b2121496/attachment.html
More information about the rules-users
mailing list