You can use an event listener for grabbing the
org.drools.runtime.rule.Activation from a BeforeActivationFiredEvent and
store it in a global for access by RHS code. Activation's List<String>
getDeclarationIDs() and Object getDeclarationValue(String name) provide
access to variables and what's bound to them.
-W
2011/9/19 Isaac Pereira <pereira.zc(a)gmail.com>
Sorry for not explaining it before, Mauricio. My intent is to
abstract the
attribute's setting of a class. I'll try to explain the context:
On a defined class i've got certain fields which I tagged with
annotations. I want to automate the setting of these fields from certain
objects matched by a rule, the matching between the class fields and the
objects would be the identifiers. The field annotation holds the expected
identifier to match. Thus, a general method would be capable to set the
fields of any class just passing to it the class fields and the identifiers
metadata.
What i've been developing is related with situation detection. The 'class'
I refer above is a situation type and the attributes are roles that an
entity can play in a situation. Each situation type has a rule that defines
when it is active and must instantiate a new situation and set the
participant entities.
I''ll talk more about what i'm working on as soon as i get time to write.
Thanks for the help,
2011/9/19 Mauricio Salatino <salaboy(a)gmail.com>
> You can get metadata using the kcontext variable but I'm not sure if you
> can get the information about the identifiers.
> Can you describe what are you looking to achieve? because the rule is
> fixed and the identifiers as well. Why do you want to do reflection like
> stuff in the RHS? I'm just curious..
> Cheers
>
> 2011/9/19 Isaac Pereira <pereira.zc(a)gmail.com>
>
>> Hi Mauricio,
>>
>> I mean a metadata structure that I can iterate on, then I wouldn't need
>> to explicitely know the identifiers declared into a rule. Analogous to
>> getting fields from a class using reflection.
>>
>> Thanks,
>>
>>
>> 2011/9/19 Mauricio Salatino <salaboy(a)gmail.com>
>>
>>> What do you mean with a mapping between identifiers?
>>> If you define an identifier and bind a property or an object reference
>>> to it you can access it in the RHS directly.
>>> Cheers
>>>
>>> 2011/9/19 Isaac Pereira <pereira.zc(a)gmail.com>
>>>
>>>> Hi,
>>>>
>>>> Is there a way to get, on the RHS, a mapping between
>>>> identifiers, declared on the LHS, and its respectives objects?
>>>>
>>>>
>>>> I would appreciate any help.
>>>>
>>>> --
>>>> Isaac Pereira
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>
>>>
>>> --
>>> - CTO @
http://www.plugtree.com
>>> - MyJourney @
http://salaboy.wordpress.com
>>> - Co-Founder @
http://www.jugargentina.org
>>> - Co-Founder @
http://www.jbug.com.ar
>>>
>>> - Salatino "Salaboy" Mauricio -
>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>> --
>> Isaac Pereira
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> - CTO @
http://www.plugtree.com
> - MyJourney @
http://salaboy.wordpress.com
> - Co-Founder @
http://www.jugargentina.org
> - Co-Founder @
http://www.jbug.com.ar
>
> - Salatino "Salaboy" Mauricio -
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
Isaac Pereira
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users