2011/9/28 matvey1414 <span dir="ltr">&lt;<a href="mailto:matvey1414@gmail.com">matvey1414@gmail.com</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Hi,</div><div><br></div><div>Thank you for your reply. I will use the Knowledge API going forward.</div><div><br></div><div>Can you please explain what you mean by &quot;deviate from the constraint syntax as defined with 5.1.1&quot;? What&#39;s an example of 5.1.1 syntax, </div>
</blockquote><div><br>For a complete picture, get the Expert manual of 5.1.1. Most constraint have to be written as <br>   &lt;field&gt; &lt;comp-op&gt; &lt;value&gt;<br>and there&#39;s a restrictive list of what is permitted as a &lt;value&gt;, e.g.<br>
   field == (one + 2) // parens are required<br>or<br>   field &gt; 42  // OK<br>and so on. <br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>and what&#39;s an example of a deviation?</div></blockquote><div><br>For instance:<br>   42 &lt; field<br>or<br>  field == one + 2<br>and so on.<br><br>HTH<br>-W<br>   <br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><br></div><div>-Matt</div><br><div class="gmail_quote"><div class="im">On Tue, Sep 27, 2011 at 5:12 AM, laune [via Drools] <span dir="ltr">&lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=3376645&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt;</span> wrote:<br>

</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">

        Please use the new &quot;knowledge&quot; API for compiling and building a knowledge (not: rule) base.<br><br>This bug has been fixed for 5.3.0. It is one of several that may occur when you use 5.2.0 and deviate from the constraint syntax as defined with 5.1.1.<br>


<br>-W<br><br><br></div><div class="gmail_quote"><div><div></div><div class="h5">On 26 September 2011 22:51, matvey1414 <span dir="ltr">&lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=3372058&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt;</span> wrote:<br>

</div></div><blockquote style="border-left: 2px solid rgb(204, 204, 204); padding: 0pt 1em;" class="gmail_quote"><div><div></div><div class="h5">
Hi,<br>
<br>
I am working with Drools to implement a high-profile rules-engine. I have<br>
two rules defined. Clearly, only the first should fire, but both do. Here is<br>
my DRL:<br>
<br>
<br>
package com.sample<br>
<br>
import com.sample.DroolsTest.Request;<br>
<br>
rule &quot;ExpensiveCanonShopper0&quot;<br>
when<br>
        Request( attributeMap[&quot;camera0&quot;] == &quot;canon&quot; &amp;&amp;<br>
attributeMap[&quot;price0&quot;] &gt;= 500 )<br>
then<br>
        System.out.println(&quot;ExpensiveCanonShopper0&quot;);<br>
end<br>
<br>
rule &quot;ExpensiveCanonShopper1&quot;<br>
when<br>
        Request( attributeMap[&quot;camera1&quot;] == &quot;canon&quot; &amp;&amp;<br>
attributeMap[&quot;price1&quot;] &gt;= 500 )<br>
then<br>
        System.out.println(&quot;ExpensiveCanonShopper1&quot;);<br>
end<br>
<br>
And the Java class to execute it:<br>
<br>
public class DroolsTest {<br>
<br>
        @SuppressWarnings({ &quot;rawtypes&quot;, &quot;unchecked&quot; })<br>
        public static final void main(String[] args) {<br>
                try {<br>
                        //Loading the Rules<br>
                        System.out.println(&quot;Loading rules&quot;);<br>
                        RuleBase ruleBase = readRule();<br>
                        StatelessSession workingMemory =<br>
ruleBase.newStatelessSession();<br>
<br>
                        System.out.println(&quot;Firing rules&quot;);<br>
<br>
                        Map map = new HashMap();<br>
                        map.put(&quot;camera0&quot;, &quot;canon&quot;);<br>
                        map.put(&quot;price0&quot;, 600);<br>
<br>
                        Request request = new Request();<br>
                        request.setAttributeMap(map);<br>
                        workingMemory.execute(request);<br>
<br>
                } catch (Throwable t) {<br>
                        t.printStackTrace();<br>
                }<br>
        }<br>
<br>
        /**<br>
         * Please note that this is the “low level” rule assembly API.<br>
         */<br>
        private static RuleBase readRule() throws Exception {<br>
                //read in the source<br>
                Reader source = new FileReader(new File(&quot;drl&quot;,<br>
&quot;Generated.drl&quot;));<br>
<br>
                //optionally read in the DSL (if you are using it).<br>
                //Reader dsl = new InputStreamReader(<br>
DroolsTest.class.getResourceAsStream( “/mylang.dsl” ) );<br>
<br>
                //Use package builder to build up a rule package.<br>
                //An alternative lower level class called “DrlParser” can<br>
also be used…<br>
<br>
                PackageBuilder builder = new PackageBuilder();<br>
<br>
                //this wil parse and compile in one step<br>
                //NOTE: There are 2 methods here, the one argument one is<br>
for normal DRL.<br>
                builder.addPackageFromDrl( source );<br>
                if (builder.hasErrors()) {<br>
                        PackageBuilderErrors errors = builder.getErrors();<br>
                        throw new RuntimeException(&quot;Error adding package to<br>
builder: &quot; + errors.toString());<br>
                }<br>
<br>
                //Use the following instead of above if you are using a DSL:<br>
                //builder.addPackageFromDrl( source, dsl );<br>
<br>
                //get the compiled package (which is serializable)<br>
                Package pkg = builder.getPackage();<br>
<br>
                //add the package to a rulebase (deploy the rule package).<br>
                RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br>
                ruleBase.addPackage( pkg );<br>
                return ruleBase;<br>
        }<br>
<br>
        public static class Request {<br>
                private Map attributeMap;<br>
<br>
                public Map getAttributeMap() {<br>
                        return attributeMap;<br>
                }<br>
<br>
                public void setAttributeMap(Map attributeMap) {<br>
                        this.attributeMap = attributeMap;<br>
                }<br>
        }<br>
}<br>
<br>
The output is this, meaning both rules fired:<br>
Loading rules<br>
Firing rules<br>
ExpensiveCanonShopper1<br>
ExpensiveCanonShopper0<br>
<br>
I have two questions:<br>
<br>
1. Is this a bug, or am I doing something wrong? Only<br>
&quot;ExpensiveCanonShopper0&quot; should fire.<br>
<br>
2. I am pretty sure this is somehow related to the fact that I&#39;m using Map<br>
attributes, and not POJO to get &quot;price0&quot; and &quot;camera0&quot;. My issue is that I<br>
won&#39;t know the parameters in advance (they are coming in a URL), so I can&#39;t<br>
pre-declare them, and thus need something dynamic like a Map. Is this how<br>
Drools is intended to be used? The documentation appears very POJO-centric.<br>
<br>
I am using Drools 5.2<br>
<br>
Thank you!<br>
-Matt<br>
</div></div><font color="#888888"><div><div></div><div class="h5"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3370653.html" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3370653.html</a><br>



Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
</div></div><a href="http://user/SendEmail.jtp?type=node&amp;node=3372058&amp;i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a><div class="im"><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></font></blockquote></div><br>
<br>_______________________________________________
<br>rules-users mailing list
<br><a href="http://user/SendEmail.jtp?type=node&amp;node=3372058&amp;i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><div class="im"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
        
        <br>
        <br>
        </div><hr noshade size="1" color="#cccccc">
        <div style="color: rgb(68, 68, 68); font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal;">

                <div style="font-weight: bold;">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3372058.html" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3372058.html</a>
        </div>
        <div style="color: rgb(102, 102, 102); font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; margin-top: 0.4em;">

                
                To unsubscribe from Unsatisfied rule fires - Drools bug?, <a rel="nofollow" link="external">click here</a>.
        </div></blockquote></div><br><font color="#888888"><br clear="all"><div><br></div>-- <br><a href="http://www.calcmachine.com" rel="nofollow" link="external" target="_blank">www.calcmachine.com</a> - easy online calculator.<br>


        
<br><hr width="300" align="left">
View this message in context: <a href="http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3376645.html" target="_blank">Re: [rules-users] Unsatisfied rule fires - Drools bug?</a></font><div><div>
</div><div class="h5"><br>
Sent from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html" target="_blank">Drools: User forum mailing list archive</a> at Nabble.com.<br></div></div><br>_______________________________________________<br>

rules-users mailing list<br>
<a href="mailto: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>
<br></blockquote></div><br>