<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Here is how I have solved it..&nbsp;<div><br></div><div>




<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
x\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->





<table border="0" cellpadding="0" cellspacing="0" width="86" style="border-collapse: collapse; width: 86pt; position: static; z-index: auto; ">
<!--StartFragment-->
 <colgroup><col width="86" style="mso-width-source:userset;mso-width-alt:3669;width:86pt">
 </colgroup><tbody><tr height="15" style="mso-height-source:userset;height:15.0pt">
  <td height="15" class="xl67" width="86" style="height:15.0pt;width:86pt"><font face="Menlo">CONDITION</font></td>
 </tr>
 <tr height="15" style="mso-height-source:userset;height:15.0pt">
  <td height="15" class="xl68" width="86" style="height:15.0pt;border-top:none;
  width:86pt"><font face="Menlo">$c: ConditionObject</font></td>
 </tr>
 <tr height="15" style="mso-height-source:userset;height:15.0pt">
  <td height="15" class="xl68" width="86" style="height:15.0pt;border-top:none;
  width:86pt"><font face="Menlo">/* $1 */</font></td>
 </tr>
 <tr height="15" style="mso-height-source:userset;height:15.0pt">
  <td height="15" class="xl69" style="height:15.0pt"><font face="Menlo">Got Object</font></td>
 </tr>
 <tr height="15" style="mso-height-source:userset;height:15.0pt">
  <td height="15" class="xl66" style="height:15.0pt"><font face="Menlo">YES</font></td>
 </tr>
 <tr height="15" style="height:15.0pt">
  <td height="15" class="xl66" style="height:15.0pt;border-top:none"><font face="Menlo">YES</font></td>
 </tr>
 <tr height="15" style="height:15.0pt">
  <td height="15" class="xl66" style="height:15.0pt;border-top:none"><font face="Menlo">YES</font></td>
 </tr>
 <tr height="15" style="height:15.0pt">
  <td height="15" class="xl66" style="height:15.0pt;border-top:none"><font face="Menlo">YES</font></td>
 </tr>
<!--EndFragment-->
</tbody></table><div><br class="webkit-block-placeholder"></div><div><br></div><div>and that produces ..&nbsp;</div><div><br></div><div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>when</font></div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>$c: ConditionObject(/* YES */)</font></div></div><div><br></div><div>for every rule where there is a "YES". I didn't want to overcomplicate the test for Drools .. i.e. : Object() is sufficient</div><div><br></div><div>-== Some other things I found ==-</div><div><br></div><div>I found a behaviour about rule generation which was not expected.&nbsp;</div><div>a CONDITION can have nothing in the "Object row" (the first row down).. that is good.</div><div>and the code in the "code" row, (next row after) will be put in the When .. nice.</div><div>ie:&nbsp;</div><div><br></div><div><font face="Monaco">CONDITION</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">$c : ConditionObject(&nbsp;</font><span style="font-family: Monaco; ">&nbsp;</span><span style="font-family: Monaco; ">/* $1 */</span><span style="font-family: Monaco; ">&nbsp;)</span></div><div><font face="Monaco">Description</font></div><div><font face="Monaco">YES</font></div><div><font face="Monaco">YES</font></div><div><br class="webkit-block-placeholder"></div><div><br></div><div>What is unexpected is that .. these "rules" get reordered such that, if they are at the from (column A) and there is a CONDITION in column B that looks like</div><div><br></div><div><font face="Monaco">CONDITION</font></div><div><font face="Monaco">$e: FieldObject( ) from $c.field</font></div><div><font face="Monaco">aField</font></div><div><font face="Monaco">Description</font></div><div><font face="Monaco">A</font></div><div><font face="Monaco">B</font></div><div><br></div><div><br></div><div>the rule will look like&nbsp;</div><div><br></div><div><font face="Monaco">when&nbsp;</font></div><div><font face="Monaco">&nbsp; &nbsp;$e: FieldObject( aField == "A" ) from $c.field</font></div><div><font face="Monaco">&nbsp; &nbsp;$c: ConditionObject( /* YES */ )</font></div><div><br></div><div><br></div><div>This occurs (looking at the source code :&nbsp;<a href="https://github.com/droolsjbpm/drools/blob/master/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java">https://github.com/droolsjbpm/drools/blob/master/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java</a>)</div><div>because it adds each "CONDITION" into a list on a row by row basis; It will add the CONDITION in column B first, before the Condition in Column A because there is no data in Column "A",first cell.</div><div><br></div><div>hope that helps someone somewhere&nbsp;</div><div><br></div><div><br></div><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div>Ramon Buckland</div><div><a href="mailto:ramon@thebuckland.com">ramon@thebuckland.com</a></div><div><br></div></span><br class="Apple-interchange-newline">

</div>
<br><div><div>On 22 May 2013, at 12:18, Ramon Buckland &lt;<a href="mailto:ramon@thebuckland.com">ramon@thebuckland.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,&nbsp;<div><br></div><div>Thanks for the response.&nbsp;</div><div><br></div><div>That doesn't seem to be right - this is what is produced from the Compiler.</div><div><br></div><div><div><font face="Monaco">// rule values at A9, header at A3</font></div><div><font face="Monaco">rule "Test rule_9"</font></div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>when</font></div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>$c : ConditionObject(somefield)</font></div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>$a : ActionObject(this != null == "X")</font></div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>EmbeddedObject(myField == AnEnum.SomeOtherValue) from $c.embedded</font></div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>then</font></div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>ActionObject.someMethod2(50);</font></div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>$a.someMethod("someOtherValue")</font></div><div><font face="Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>$a.someMethod3(B)</font></div><div><font face="Monaco">end</font></div><div><br></div><div>Is there a way to have a "when" rule produced where the data table row, for that CONDITION is empty ?&nbsp;</div><div>The hack version I can work out is</div><div><br></div><div><blockquote type="cite"><div dir="ltr"><div><div><div>CONDITION<br>$a : ActionObject<br></div>$param != null<br></div>this</div>this</div></blockquote></div><div><br></div><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div>Ramon Buckland</div><div><a href="mailto:ramon@thebuckland.com">ramon@thebuckland.com</a></div><div><br></div></span><br class="Apple-interchange-newline">

</div>
<br><div><div>On 22 May 2013, at 10:33, Michael Anstis &lt;<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div><div><div>Add an additional CONDITION for ActionObject.<br><br>You'll need to probably add a constraint for "this != null" 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><br></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.&nbsp;<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 "does exist" 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 "Test rule_11"</font></div><div><font face="Monaco">when</font></div>
<div><font face="Monaco">&nbsp; &nbsp; $c : ConditionObject( somefield )</font></div><div><font face="Monaco">&nbsp; &nbsp;&nbsp;EmbeddedObject(myField == AnEnum.SomeValue) from $c.embedded</font></div><div><font face="Monaco">&nbsp; &nbsp; $a : ActionObject( )</font></div>
<div><font face="Monaco">then&nbsp;</font></div><div><font face="Monaco">&nbsp; &nbsp; $a.someMethod("value")</font></div><div><font face="Monaco">&nbsp; &nbsp; $a.someMethod2(10)</font></div><div><font face="Monaco">&nbsp; &nbsp; $a.someMethod3("A")</font></div>
<div><font face="Monaco">end</font></div><div><br></div><div><font face="Monaco">rule "Test rule_12"</font></div><div><font face="Monaco">// some other AnEnum checks.</font></div><div><br></div><div>What I can't work out is how I get the test of "existence" of the Action Object into the "when" for the rule, so that I can "use" the Object in the ACTION.</div>
<div>In addition, is there a away that I can avoid needing a whole column just for "existence of an object with a field.. collect as a variable $c : (ConditionObject( somefield )" ?</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("$param")<span style="white-space:pre-wrap">        </span>$a.someMethod2($param)<span style="white-space:pre-wrap">        </span>$a.someMethod3($param)</div>
<div>"Description"<span style="white-space:pre-wrap">                        </span>"Description"<span style="white-space:pre-wrap">                                                </span>"Description"<span style="white-space:pre-wrap">                                </span>"Description"<span style="white-space:pre-wrap">                        </span>"Description"</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 "condition" 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 "Test rule_8"</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("value")</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 "Test rule_9"</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("someOtherValue")</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"><br></font></span></div><span class="HOEnZb"><font color="#888888">
<br></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>
_______________________________________________<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">https://lists.jboss.org/mailman/listinfo/rules-users</a></blockquote></div><br></div></div></blockquote></div><br></div></body></html>