Nj, The approach David is suggesting using the descriptors is a higher level approach where anything that is written in DRL language is mapped one-to-one in Descr classes, but as you already realized, Descr classes have most data as non-compiled text. It is simpler, if working with text is ok for you.
If you want to dig deeper and use compiled stuff, keep in mind that you will be using internal APIs, subject to change. Having said that, the Rule object has a method getLHS() that will return the compiled LHS of a rule. It is a logical tree, with nested objects. You need to walk this tree looking for Pattern objects. Each Pattern object will have an Object Type that is what you are looking for. []s Edson 2009/2/24 nopea joki <[email protected]> > David, > Thank you for the reply. > I checked the PackageDescr and RuleDescr classes, but there seems no > direct methods which would return the fact classes used in the rule. > > for instance if we have a rule like: > > rule rule1 > when > Person(name = "qq") > Driver(name = "aa") > then ... end > > from this rule, I want to get [Person, Fact]. > In org.drools.rule.Rule class, there is a getDeclaration(), this returns > some type information if variable is associated with Fact class, e.g, $p: > Person. > But in the above case, we just get empty list of declarations. > > This kind of information is useful when we need to provide a GUI for given > rules. > > Do you have more specific suggestion for this? > > Regards, > nj > > > > On Tue, Feb 24, 2009 at 12:04 PM, David Sinclair < > [email protected]> wrote: > >> This should probably be in the users list, not dev. All of that >> information is available in the PackageDesc object. For example, >> >> DrlParser parser = new DrlParser(); >> InputStreamReader reader = new InputStreamReader( >> this.getClass().getResourceAsStream( "Misc3.drl" ) ); >> PackageDescr pkg = parser .parse( reader ); >> >> pkg.getGlobals(); >> pkg.getRules(); >> >> etc. >> >> On Mon, Feb 23, 2009 at 9:44 PM, nopea joki <[email protected]> wrote: >> >>> Hi, >>> I would like to get all the classes used for Facts in the rules from >>> Package like getting global variable information from package. >>> Is it possible to have such information? >>> >>> Regards, >>> nj >>> >>> _______________________________________________ >>> rules-dev mailing list >>> [email protected] >>> https://lists.jboss.org/mailman/listinfo/rules-dev >>> >>> >> > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > > -- Edson Tirelli JBoss Drools Core Development JBoss, a division of Red Hat @ www.jboss.com
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
