<div dir="ltr"><div><div><div><div>Add an additional CONDITION for ActionObject.<br><br>You&#39;ll need to probably add a constraint for &quot;this != null&quot; and put an X in the rows; e.g.<br><br></div>CONDITION<br>$a : ActionObject<br>
</div>this != null<br></div>X<br></div>X<br><br><div><div><div><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 22 May 2013 09:55, Ramon Buckland <span dir="ltr">&lt;<a href="mailto:ramon@thebuckland.com" target="_blank">ramon@thebuckland.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi. <div><br></div><div>I am working on Drools 5.5.0.Final and have a question regarding XLS and a Decision Table structure,</div>
<div><br></div><div>I have a ConditionObject and an ActionObject and wanted to know or see an example for XLS that produces a &quot;does exist&quot; for the ActionObject</div><div>in the when.</div><div><br></div><div>I can simply write the rule in a DRL, but translating how to make the XLS compiler create the same is proving challenging.</div>
<div><br></div><div>An example:</div><div><br></div><div>I want to produce a set of rules like below</div><div><br></div><div><font face="Monaco">rule &quot;Test rule_11&quot;</font></div><div><font face="Monaco">when</font></div>
<div><font face="Monaco">    $c : ConditionObject( somefield )</font></div><div><font face="Monaco">    EmbeddedObject(myField == AnEnum.SomeValue) from $c.embedded</font></div><div><font face="Monaco">    $a : ActionObject( )</font></div>
<div><font face="Monaco">then </font></div><div><font face="Monaco">    $a.someMethod(&quot;value&quot;)</font></div><div><font face="Monaco">    $a.someMethod2(10)</font></div><div><font face="Monaco">    $a.someMethod3(&quot;A&quot;)</font></div>
<div><font face="Monaco">end</font></div><div><br></div><div><div><font face="Monaco">rule &quot;Test rule_12&quot;</font></div></div><div><font face="Monaco">// some other AnEnum checks.</font></div><div><br></div><div>What I can&#39;t work out is how I get the test of &quot;existence&quot; of the Action Object into the &quot;when&quot; for the rule, so that I can &quot;use&quot; the Object in the ACTION.</div>
<div>In addition, is there a away that I can avoid needing a whole column just for &quot;existence of an object with a field.. collect as a variable $c : (ConditionObject( somefield )&quot; ?</div><div><br></div><div>CONDITION<span style="white-space:pre-wrap">                        </span>CONDITION<span style="white-space:pre-wrap">                                                </span>ACTION<span style="white-space:pre-wrap">                                        </span>ACTION<span style="white-space:pre-wrap">                                </span>ACTION</div>
<div>$c : ConditionObject<span style="white-space:pre-wrap">                </span>EmbeddedObject() from $c.embedded<span style="white-space:pre-wrap">        </span></div><div>$param<span style="white-space:pre-wrap">                                </span>myField == AnEnum.$param<span style="white-space:pre-wrap">                        </span>$a.someMethod(&quot;$param&quot;)<span style="white-space:pre-wrap">        </span>$a.someMethod2($param)<span style="white-space:pre-wrap">        </span>$a.someMethod3($param)</div>
<div>&quot;Description&quot;<span style="white-space:pre-wrap">                        </span>&quot;Description&quot;<span style="white-space:pre-wrap">                                                </span>&quot;Description&quot;<span style="white-space:pre-wrap">                                </span>&quot;Description&quot;<span style="white-space:pre-wrap">                        </span>&quot;Description&quot;</div>
<div>somefield<span style="white-space:pre-wrap">                                </span>SomeValue<span style="white-space:pre-wrap">                                                </span>value<span style="white-space:pre-wrap">                                        </span>10<span style="white-space:pre-wrap">                                        </span>A<span style="white-space:pre-wrap">        </span></div>
<div>somefield<span style="white-space:pre-wrap">                                </span>SomeOtherValue<span style="white-space:pre-wrap">                                        </span>someOtherValue<span style="white-space:pre-wrap">                        </span>50<span style="white-space:pre-wrap">                                        </span>B</div>
<div><br></div><div>This is the XLS of the above.</div><div><br></div><div><a href="https://www.dropbox.com/s/lw3zb5hwtjdbpcm/sample_rules.xls?v=1scns" target="_blank">https://www.dropbox.com/s/lw3zb5hwtjdbpcm/sample_rules.xls?v=1scns</a></div>
<div><br></div><div>When this sheet is compiled, I get the following: How do I setup a &quot;condition&quot; for ActionObject to get in the when ?</div><div><br></div><div><div><div><font face="Monaco">package packageName;</font></div>
<div><font face="Monaco">//generated from Decision Table</font></div><div><font face="Monaco">// rule values at A8, header at A3</font></div><div><font face="Monaco">rule &quot;Test rule_8&quot;</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">        </span>when</font></div>
<div><font face="Monaco"><span style="white-space:pre-wrap">                </span>$c : ConditionObject(somefield)</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">                </span>EmbeddedObject(myField == AnEnum.SomeValue) from $c.embedded</font></div>
<div><font face="Monaco"><span style="white-space:pre-wrap">        </span>then</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">                </span>$a.someMethod(&quot;value&quot;)</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">                </span>$a.someMethod2(10)</font></div>
<div><font face="Monaco"><span style="white-space:pre-wrap">                </span>$a.someMethod3(A)</font></div><div><font face="Monaco">end</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">// rule values at A9, header at A3</font></div>
<div><font face="Monaco">rule &quot;Test rule_9&quot;</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">        </span>when</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">                </span>$c : ConditionObject(somefield)</font></div>
<div><font face="Monaco"><span style="white-space:pre-wrap">                </span>EmbeddedObject(myField == AnEnum.SomeOtherValue) from $c.embedded</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">        </span>then</font></div>
<div><font face="Monaco"><span style="white-space:pre-wrap">                </span>$a.someMethod(&quot;someOtherValue&quot;)</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">                </span>$a.someMethod2(50)</font></div>
<div><font face="Monaco"><span style="white-space:pre-wrap">                </span>$a.someMethod3(B)</font></div><div><font face="Monaco">end</font></div><span class="HOEnZb"><font color="#888888"><div><br></div></font></span></div><span class="HOEnZb"><font color="#888888"><div>
<br></div></font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br></div><div><div>
<span style="border-collapse:separate;border-spacing:0px"><div>Ramon Buckland</div><div><a href="mailto:ramon@thebuckland.com" target="_blank">ramon@thebuckland.com</a></div><div><br></div></span><br>

</div>


<br></div></font></span></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></blockquote></div><br></div>