[rules-users] How to retrieve the Rule names in the drools rule file

Amila Silva amilac at hsenidmobile.com
Tue Jun 30 06:19:23 EDT 2009


hi Laun,
   I tries with your solutions but i couldn't find the way to configure the
meta - data part in rule file to read.
   I came across with following issues when trying to read it from a given
code.

  [12,2]: [ERR 102] Line 12:2 mismatched input 'AT' expecting 'then' in rule
"create new Instance"
   Exception in thread "main" java.lang.IllegalArgumentException: Could not
parse knowledge.

 i think this might be a issue with  a @ sign in the rule file but i think i
this kinda of annotations will help to specify the
 main rule name. Or is there any way to identify or filter out the main rule
name from file.

BTW your this solution help me a lot.
thanks






On Tue, Jun 30, 2009 at 2:44 PM, Wolfgang Laun <wolfgang.laun at gmail.com>wrote:

> You might use the API to retrieve all rules in your KnowledgeBase
>
> KnowledgeBase kBase = ...;
>
> for( KnowledgePackage kp: kBase.getKnowledgePackages() ){
>       for( Rule r: kp.getRules() ){
>             String name = r.getName();
>             String purpose = r.getMetaAttribute( "Purpose" );  // or
> similar - see below
>             System.out.println( "Rule " + name + ", purpose: " + purpose );
>       }
> }
>
> Rule names may not provide sufficient information. You could add arbitrary
> metadata to your rules, e.g.,
>
> rule "pqx"
>    @Purpose( "locates very interesting facts" )
>    when
>    ...
> end
>
> -W
>
>
>
> 2009/6/30 Amila Silva <amilac at hsenidmobile.com>
>
>>
>> hi everyone,
>>    I have requirement like to retrieve the RULE names in a given rule
>> files. and also is there a way to map a rule names from a multiple rule
>> files.
>>    i want to load the or show the available rules and system user to
>> select the required rule for his program.
>>    let me know the possible way of doing this.
>>
>>
>> --
>> Thanks,
>> Regrads,
>>
>> Amila Silva,
>> Associate Software Engineer
>>
>> hSenid Mobile Solutions
>>
>> Phone :
>> +94-77-9983894
>> Fax     :
>> +94-11-2673 845
>>
>> Web:
>> http://www.hSenid.com
>>
>> Make it Happen
>>
>>
>> http://www.hSenidMobile.com
>>
>> Enabling the Mobile World
>>
>>
>> Disclaimer: This email and any files transmitted with it are confidential
>> and intended solely for the use of the individual or entity to which they
>> are addressed. The content and opinions contained in this email are not
>> necessarily those of hSenid Software International. If you have received
>> this email in error please contact the sender.
>>
>>
>> _______________________________________________
>> 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/20090630/ee3a3000/attachment.html 


More information about the rules-users mailing list