<HTML><BODY>
Well the problem with the fields of the fact objects is just the same as the one with the fact types.<br>Let me try to explain.<br>The business objects representing the business abstractions in my project are overlaping with the Fact model.<br>I believe that this is the standard case :). Actually we can ignore the technical particularity that we have a Java<div>fact model and another business application model, because the two model will be mirrored. We can think that</div><div>for each business class there is a fact class for Drools to use :).</div><div>The business classes are complex and consist of many fields. For example the biggest contains ovet 450 fields.</div><div>The most common ones to be used as facts consists of 373 and 314 fields.</div><div>If I identify just the <i>Fact Types </i>then I will need to extract all the information that is available for that fact before</div><div>pass it to Drools, then Instantiate a Java instance to represent the Fact and initialize the instance with the information.</div><div>What I am trying to avoid here is the transfer of that many useless information once again.</div><div>In the most common case I will need 1 to 10 fields per Fact Type. So passing the 300 seems redundant.</div><div><br>Best Regards,</div><div>Milen<br><br>




 -------- Original Letter --------
<br>From: Wolfgang Laun wolfgang.laun@gmail.com
<br>About: Re: [rules-users] Is rule introspection available from the Drools
        API?
<br>To: Rules Users List &lt;rules-users@lists.jboss.org&gt;
<br>Sent at: Tuesday, 2014, January7 15:04:21 EET
<br><br>As you describe it, the fields of the fact objects shouldn't matter.<br>
<br>
On 07/01/2014, milen igrachev &lt;<a href="javascript: internSendMess('igrachev@abv.bg')">igrachev@abv.bg</a>&gt; wrote:<br>
&gt;  Hello,  initially i didn't give more details to keep my question short and<br>
&gt; save time to the ppl that read it.  I actually believed that such<br>
&gt; functionality might be covered and available and details would have just<br>
&gt; prolong my question.<br>
&gt;   Here is some additional information on why I am looking for such<br>
&gt; functionality.  In my project I want to use Drools as external rule engine.<br>
&gt; My project is not written in Java and the effort to transfer it is<br>
&gt; inconsiderable.<br>
<br>
I guess you mean "considerable".<br>
<br>
&gt; What I want to start using Drools for is a simple blackbox<br>
&gt; of getting answers from a Stateless Drools  Session, most likely without any<br>
&gt; need of reinference. Simply ask and get answered.  During the runtime of my<br>
&gt; project there is a vast amount of information that can be considered as a<br>
&gt; fact . However in  most of the cases what I need is to invoke a simple<br>
&gt; ruleset that actually need like 1% of the  facts  that I currently know  at<br>
&gt; any particular moment. So what I want to do is ask Drools "Hey I want to<br>
&gt; invoke   ruleset, can you please tell  me what are the facts that it is<br>
&gt; using so I can pass all of them, that I currently have?". Then after<br>
&gt; receiving the answer I will  filter the 1% from the big picture and will<br>
&gt; finally ask Drools to answer my question.<br>
<br>
If these "rule sets" are unrelated with each other, you might put them into<br>
separater DRL files. Then the import list will tell you which facts this<br>
rule set needs, and so all you need is simple text processing...<br>
<br>
-W<br>
<br>
&gt;   What I want to avoid is passing hundreds of instance/facts with hundreds<br>
&gt; of fields that are actually never user.  Of course I realise that the rule<br>
&gt; introspection that I am asking for is not my only option, I can create the<br>
&gt; .drl metadata during  the ruleset definition. Some more ideas poped into my<br>
&gt; head, so far, but the best solution for me seems to be if we can just call<br>
&gt; Drools about that information and it return it as a straight answer.<br>
&gt;<br>
&gt; That is why I am trying to identify if it is possible to recive the rule<br>
&gt; metadata from Drools. At first I thought it could be available in  a snap of<br>
&gt; a finger with some method calls, however now I am interested to see what is<br>
&gt; the effort to make it happen.<br>
&gt;   Hope it helps. Thanks for the support.<br>
&gt;   Best Regards,  Milen<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;  -------- Original Letter --------<br>
&gt;<br>
&gt; From: Stephen Masters <a href="javascript: internSendMess('stephen.masters@me.com')">stephen.masters@me.com</a><br>
&gt;<br>
&gt; About: Re: [rules-users] Is rule introspection available from the<br>
&gt;         Drools        API?<br>
&gt;<br>
&gt; To: Drools List<br>
&gt;<br>
&gt; Sent at: Tuesday, 2014, January 7 12:08:39 EET<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;    It may also be worth explaining exactly what you aim to achieve through<br>
&gt; this and why. From what I have seen, most people who ask about introspecting<br>
&gt; the LHS of rules via the API, don’t actually need to do that.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;    Steve<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     On 7 Jan 2014, at 08:56, Wolfgang Laun &lt;<br>
&gt;      <a href="javascript: internSendMess('wolfgang.laun@gmail.com')">wolfgang.laun@gmail.com</a> &gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;      Hi,<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; while you continue this line of research you might consider possible<br>
&gt;<br>
&gt; ramifications and snags, and be prepared for them.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; The syntax for writing LHS conditions is quite complex - it's more<br>
&gt;<br>
&gt; complex than Java expressions, because the CE eval() alone will give<br>
&gt;<br>
&gt; you (almost) all of that. Rule authors may also use DRL functions,<br>
&gt;<br>
&gt; which could hide field access.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; If *you* author the rules, you may be able to avoid the worst, but it<br>
&gt;<br>
&gt; won't be a piece of cake.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Cheers<br>
&gt;<br>
&gt; -W<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On 07/01/2014, milen igrachev &lt;<br>
&gt;       <a href="javascript: internSendMess('igrachev@abv.bg')">igrachev@abv.bg</a> &gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;       Hello thanks for the quick and precise answer!<br>
&gt;<br>
&gt;<br>
&gt; I believe that the time difference will be a bit of a problem for the IRC<br>
&gt;<br>
&gt; chat , but i will be online (channel: #drools user: igrachev) today and<br>
&gt; will<br>
&gt;<br>
&gt; try to check it often.<br>
&gt; However big thanks for the support and the<br>
&gt;<br>
&gt; willingness to help!<br>
&gt;<br>
&gt;<br>
&gt; You are saying that the code is there, but is not public and documented.<br>
&gt;<br>
&gt; Well being not public seems to be a problem, but do you<br>
&gt; think it is<br>
&gt;<br>
&gt; possible to give me an example with the official Drools "first rule" -<br>
&gt;<br>
&gt; Sample.drl. The one that comes with the first Drools project.<br>
&gt; So do you<br>
&gt;<br>
&gt; believe it will be possible to paste me some code on how to retrieve the<br>
&gt;<br>
&gt; information that this ruleset is using one fact of type Message<br>
&gt; and two of<br>
&gt;<br>
&gt; it's attributes -<br>
&gt; status<br>
&gt; and<br>
&gt; message.<br>
&gt; So just some code in a public<br>
&gt;<br>
&gt; static void main (String [] args) will be great :), or any kind of<br>
&gt;<br>
&gt; explanation :).<br>
&gt;<br>
&gt;<br>
&gt; Once again thank you.<br>
&gt;<br>
&gt;<br>
&gt; Have a nice day,<br>
&gt;<br>
&gt; Milen<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; ----Original Letter----<br>
&gt;<br>
&gt; From: Mark Proctor<br>
&gt;        <a href="javascript: internSendMess('mproctor@codehaus.org')">mproctor@codehaus.org</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; About: Re: [rules-users] Is rule introspection available from the Drools<br>
&gt;<br>
&gt;<br>
&gt;          API?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; To: Rules Users List<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Sent at: Monday, 2014, January 6 16:05:33 EET<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; The code is there, but it’s not public and not documented, and the code can<br>
&gt;<br>
&gt; be a little hard to understand - as it’s grown organically over the years.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; You’ll need to cast and unwrap and look at member vars. Start on the Rule<br>
&gt;<br>
&gt; and the lhs variable. You can always pop onto irc, with live questions,and<br>
&gt;<br>
&gt; we’ll try and respond quickly.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        <a href="http://www.jboss.org/drools/irc" target="_blank">http://www.jboss.org/drools/irc</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Mark<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On 6 Jan 2014, at 09:51, milen igrachev<br>
&gt;<br>
&gt;        <a href="javascript: internSendMess('igrachev@abv.bg')">igrachev@abv.bg</a><br>
&gt;<br>
&gt;  &gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        Hello,<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        is there a way to introspect a Drools file from within java code?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        What I need is to be able to identify the facts and the fact<br>
&gt; attributes<br>
&gt;<br>
&gt; that are used in a given DRL file.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        For example if I have a rule stored in a customer.drl DRL file within<br>
&gt; my<br>
&gt;<br>
&gt; project, containing the following definition:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        package myRulePackage<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        import org.rules.model.Customer<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        import org.rules.model.Mambership<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        rule "is eligible customer"<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;           when<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;           $c:Customer(status == "active")<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;           Membership(customer == $c, type == "premium")<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;           then<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;           $c.setEligibilityStatus(true);<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        end<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        What i need is a way to understand that this ruleset customer.drl is<br>
&gt; using<br>
&gt;<br>
&gt; two fact types - Customer and Membership and three of their attributes -<br>
&gt;<br>
&gt; Customer.status, Membership.customer and Membership.type.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        I found some information on the internet that such functionality is<br>
&gt; not<br>
&gt;<br>
&gt; supported, however the information was a bit too old, so I decided to ask<br>
&gt;<br>
&gt; again.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        Big thanks for the support!<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        Milen<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        _______________________________________________<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        rules-users mailing list<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;         <a href="javascript: internSendMess('rules-users@lists.jboss.org')">rules-users@lists.jboss.org</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;         <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; rules-users mailing list<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;        <a href="javascript: internSendMess('rules-users@lists.jboss.org')">rules-users@lists.jboss.org</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt;<br>
&gt; rules-users mailing list<br>
&gt;<br>
&gt;<br>
&gt;       <a href="javascript: internSendMess('rules-users@lists.jboss.org')">rules-users@lists.jboss.org</a><br>
&gt;<br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="javascript: internSendMess('rules-users@lists.jboss.org')">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></BODY></HTML>