[rules-users] From RuleAgent to KnowledgeAgent

Luiz Eduardo Guida Valmont legvalmont at gmail.com
Fri Apr 16 11:41:48 EDT 2010


Esteban,

That worked just as we wanted. Thank you very much!

Regards,
Luiz Eduardo

2010/4/14 Esteban Aliverti <esteban.aliverti at gmail.com>

> The runtime type of the objects returned by KnowledgePackageImp.getRules()
> is org.drools.definitions.rule.impl.RuleImpl. RuleImpl implements
> org.drools.definition.rule.Rule and contains a org.drools.rule.Rule as
> attribute. The thing is that it is not exposing all
> the org.drools.rule.Rule's attributes. I really don't know why these two
> different Rule classes exists. It would be nice if someone could clarify
> this.
> As a workaround you can cast agent.getKnowledgeBase().getKnowledgePackage(
> /* ... */ ) to KnowledgePackageImpl and use its public attribute pkg to
> get the rules you want. Remember that this is just a workaround. It would be
> better to use the standard APIs.
>
> 2010/4/13 Luiz Eduardo Guida Valmont <legvalmont at gmail.com>
>
>>  a less critical part of that code
>>>
>>
>> I meant a part of the application I'm working on, not the one that'll
>> generate the DRL files.
>>
>> Mea culpa
>>
>>
>> On 13 April 2010 17:30, Luiz Eduardo Guida Valmont <legvalmont at gmail.com>wrote:
>>
>>> Hi all,
>>>
>>> Recently I had to update part of the application I'm working so it would
>>> use KnowledgeAgent instead of RuleAgent. The later restricts scanned DRL
>>> files so that all rules from any given package must be written into only one
>>> file), whereas the former does not. Long story made short: an external
>>> application will feed my application with generated DRL's and it cannot (aka
>>> will not) managed a single monolithic DRL or even regenerate it every now
>>> and then.
>>>
>>> What happens is that I have to update (re-write?) a less critical part of
>>> that code which generates a list of all rules contained within a certain
>>> package. It has to print rules' attibutes like name, salience,
>>> date-effective and date-expires. On the one hand, the old code imports *
>>> org.drools.rule.Rule* (1), which provides getters for such properties;
>>> that Rule class is accessed through a chain of method calls starting at
>>> RuleAgent, for example:
>>>
>>> agent.getRuleBase().getPackage( /* ... */ ).getRules()[ /* ... */
>>>> ].getDateEffective()
>>>>
>>>
>>> On the other hand, when using KnowledgeAgent's, I can fetch instances of
>>> *org.drools.definition.rule.Rule* through a
>>> similar-but-effectivelly-different chain of method calls, like so:
>>>
>>> agent.getKnowledgeBase().getKnowledgePackage( /* ... */ ).getRules()
>>>>
>>>
>>> This one getRules returns a *Collection* of *
>>> org.drools.definition.rule.Rule* (2). Finally, this class does not
>>> provide similar methods:
>>>
>>> String getPackageName
>>>
>>> String getName
>>>
>>> Collection listMetaAttributes
>>>
>>> String getMetaAttribute
>>>>
>>>
>>> Hoping I've made myself clear up to this point, I ask: is it posible to
>>> convert an instance of (1) into an instance of (2) or is it possible to get
>>> instances of (1) through getters starting at KnowledgeAgent?
>>>
>>> Thanks in advance,
>>> Luiz Valmont
>>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
>
> _______________________________________________
> 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/20100416/b1685b79/attachment.html 


More information about the rules-users mailing list