This is true, but be aware that if a cell value in the Template data is empty the whole Fact Pattern is omitted.<br><br>For example:-<br><br><span style="font-family:courier new,monospace">rule "Discount @{row.rowNumber}"</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> when</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> Account( $v : @{field} != null )</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> $c : Customer( @{field} == $v , accno == @{accno} )</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> then</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> $c.setDiscount(1);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">end</span><br style="font-family:courier new,monospace">
<br>If "field" is empty neither "Account" or "Customer" will be included in the generated DRL.<br><br>If "accno" is empty "Customer" will not be included in the generated DRL.<br>
<br>This may have an impact on what you want to achieve.<br><br>With kind regards,<br><br>Mike<br><br><div class="gmail_quote">On 19 March 2012 21:29, Vincent LEGENDRE <span dir="ltr"><<a href="mailto:vincent.legendre@eurodecision.com">vincent.legendre@eurodecision.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
<br>
Instead of using a workaround, did you have a look to rule templates ?<br>
- under guvnor : <a href="http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-guvnor-docs/html_single/index.html#d0e1143" target="_blank">http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-guvnor-docs/html_single/index.html#d0e1143</a><br>
- drl : <a href="http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-expert-docs/html_single/index.html#d0e7501" target="_blank">http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-expert-docs/html_single/index.html#d0e7501</a><br>
<br>
You should be able to do exactly what you are trying to do, but properly, like that :<br>
<br>
template header<br>
field<br>
accno<br>
<br>
package range;<br>
<br>
template "Discount"<br>
rule "Discount @{row.rowNumber}"<br>
when<br>
Account( $v : @{field} != null )<br>
$c : Customer( @{field} == $v , accno == @{accno} )<br>
then<br>
$c.setDiscount(1);<br>
end<br>
end template<br>
<br>
<br>
----- Mail original -----<br>
De: "Sumeet Karawal" <<a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a>><br>
À: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
Envoyé: Jeudi 15 Mars 2012 14:20:01<br>
Objet: Re: [rules-users] Data comparing in CONDITION column decision table<br>
<div class="HOEnZb"><div class="h5"><br>
I inserted Account column with values that are always true.<br>
<br>
Works fine. :)<br>
<br>
Will try the same with 5.3 .<br>
<br>
Thanks & Regards,<br>
Sumeet<br>
<br>
<br>
<br>
<br>
From: Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
<br>
To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
<br>
Date: 03/15/2012 05:30 PM<br>
<br>
Subject: Re: [rules-users] Data comparing in CONDITION column decision table<br>
<br>
Sent by: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
The documentation for 5.3.0 says<br>
<quote><br>
To include a pattern without constraints, you can write the pattern in<br>
front of the text for another pattern.<br>
</quote><br>
but it does not work with 5.2.0 and (likely) later versions.<br>
<br>
As a workaround, re-insert the Account column and use a redundant<br>
condition that is certainly true for all facts.<br>
<br>
I'll have to look into this.<br>
<br>
-W<br>
<br>
<br>
On 15/03/2012, Sumeet Karawal <<a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a>> wrote:<br>
> Hi Wolfgang<br>
><br>
> any other way to achieve this. I have tried many times, but no success<br>
till<br>
> now :(<br>
><br>
> Thanks,<br>
> Sumeet<br>
><br>
><br>
><br>
><br>
> From: Sumeet Karawal <<a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a>><br>
><br>
><br>
> To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
><br>
><br>
> Date: 03/15/2012 04:24 PM<br>
><br>
><br>
> Subject: Re: [rules-users] Data comparing in CONDITION column<br>
decision<br>
> table<br>
><br>
> Sent by: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> After doing the changes, its taking the rules as:<br>
><br>
> rule "Discount_10"<br>
> when<br>
> $a:Account(type ==<br>
$a.getType(), accno == 1001)<br>
> $c:Customer<br>
> then<br>
> $c.setDiscount(1);<br>
> end<br>
><br>
><br>
> and if I put it as $a: Account() $c: Customer(), it takes the rules as:<br>
><br>
> rule "Discount_10"<br>
> when<br>
> $a:Account(type ==<br>
$a.getType(), accno == 1001)<br>
> $c:Customer()<br>
> then<br>
> $c.setDiscount(1);<br>
> end<br>
><br>
> Both these throw error..<br>
><br>
><br>
><br>
> neither putting the $c:Customer before $a:Account is getting executed.<br>
><br>
><br>
> Thanks & Regards,<br>
> Sumeet<br>
> Mailto: <a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a><br>
><br>
><br>
><br>
> From: Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
><br>
><br>
> To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
><br>
><br>
> Date: 03/15/2012 04:06 PM<br>
><br>
><br>
> Subject: Re: [rules-users] Data comparing in CONDITION column<br>
decision<br>
> table<br>
><br>
> Sent by: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> On 15/03/2012, Sumeet Karawal <<a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a>> wrote:<br>
>><br>
>> How to make changes to the decision table entries to get a drl of this<br>
>> kind:<br>
>><br>
><br>
> Put<br>
> $a: Account() $c: Customer<br>
> into the cell where you now have $c : Customer and delete the Account<br>
> column.<br>
> -W<br>
><br>
>><br>
>> rule "Discount_10"<br>
>> when<br>
>><br>
$a : Account()<br>
>><br>
$c : Customer(type ==<br>
> $a.getType(), accno == 1001)<br>
>> then<br>
>><br>
$c.setDiscount(1);<br>
>> end<br>
>><br>
>><br>
>> Thanks,<br>
>> Sumeet<br>
>> Mailto: <a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a><br>
>><br>
>><br>
>><br>
>> From: Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
>><br>
>><br>
>> To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
>><br>
>><br>
>> Date: 03/15/2012 02:47 PM<br>
>><br>
>><br>
>> Subject: Re: [rules-users] Data comparing in CONDITION column<br>
> decision<br>
>> table<br>
>><br>
>> Sent by: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> Line breaks were lost in transit, but I think that you should remove<br>
>> the quotes from<br>
>><br>
>> type == "$param"<br>
>><br>
>> if you insert an expression $a.getType().<br>
>><br>
>> -W<br>
>><br>
>><br>
>> On 15/03/2012, Sumeet Karawal <<a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a>> wrote:<br>
>>><br>
>>> Hi,<br>
>>><br>
>>> Can we use a data value of another object in the condition column of a<br>
>>> Spreadsheet.<br>
>>><br>
>>> For example: I have two data types(POJOs) one com.bank.Customer and<br>
> other<br>
>>> com.bank.Account<br>
>>><br>
>>> in the rules I want to check whether the value entered for a particular<br>
>>> field in Customer class is equal to the value entered for the<br>
>> corresponding<br>
>>> field in the Account class. eg Customer.accType = Account.accType()<br>
>>><br>
>>><br>
>>> How can we achieve this using Decision table (CONDITION Column). I have<br>
>>> tried this:<br>
>>><br>
>>> --------------------------------------------<br>
>>> |RuleTable<br>
>>> |Discount<br>
>>> --------------------------------------------<br>
>>> |CONDITION |CONDITION |<br>
>>> ---------------+----------------------------|<br>
>>> |$a : Account |$c : Customer |<br>
>>> ---------------+----------------------------|<br>
>>> | |type == "$param"<br>
>>> ----------+---------------+----------------------------<br>
>>> | Discount | Account | Type |<br>
>>> | Rules | | |<br>
>>> |----------+---------------+----------------------------|<br>
>>> | 1 | | $a.getType() |<br>
>>> |----------+---------------+----------------------------|<br>
>>> | 2 | | $a.getType() |<br>
>>> |----------+---------------+----------------------------|<br>
>>> | 3 | | $a.getType() |<br>
>>> |----------+---------------+----------------------------|<br>
>>> | 4 | | $a.getType() |<br>
>>> |----------+---------------+----------------------------|<br>
>>> | 5 | | $a.getType() |<br>
>>> |----------+---------------+----------------------------|<br>
>>> | 6 | | $a.getType() |<br>
>>> |----------+---------------+----------------------------|<br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> But it won't work. It would be great if somebody could help me on this.<br>
>>><br>
>>> Thanks & Regards,<br>
>>> Sumeet Karawal<br>
>>> Mailto: <a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a><br>
>>><br>
>>> =====-----=====-----=====<br>
>>> Notice: The information contained in this e-mail<br>
>>> message and/or attachments to it may contain<br>
>>> confidential or privileged information. If you are<br>
>>> not the intended recipient, any dissemination, use,<br>
>>> review, distribution, printing or copying of the<br>
>>> information contained in this e-mail message<br>
>>> and/or attachments to it are strictly prohibited. If<br>
>>> you have received this communication in error,<br>
>>> please notify us by reply e-mail or telephone and<br>
>>> immediately and permanently delete the message<br>
>>> and any attachments. Thank you<br>
>>><br>
>>><br>
>>><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>
>> _______________________________________________<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>
>><br>
>><br>
>><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>
> _______________________________________________<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>
><br>
><br>
><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>
><br>
><br>
><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>
_______________________________________________<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>
<br>
<br>
<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>
_______________________________________________<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>
</div></div></blockquote></div><br>