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

Wolfgang Laun wolfgang.laun at gmail.com
Tue Jun 30 05:14:02 EDT 2009


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/02bd7d65/attachment.html 


More information about the rules-users mailing list