<div dir="ltr"><br> Yes, it is a new feature on Drools 4. Please note that Drools 4 has a huge amount of improvements in comparison to Drools 3, and we strongly advise the upgrade.<br> If you really want to stay on Drools 3, you should contact Red Hat for support. Not sure it is possible, but you may try.<br>
<br> []s<br> Edson<br><br><div class="gmail_quote">2008/8/21 Maxim Veksler <span dir="ltr"><<a href="mailto:maxim.veksler@gmail.com">maxim.veksler@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr"><br><div class="gmail_quote"><div class="Ih2E3d">On Wed, Aug 20, 2008 at 8:57 PM, Edson Tirelli <span dir="ltr"><<a href="mailto:tirelli@post.com" target="_blank">tirelli@post.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr"><br> You are using variables (like $nissan) before binding them. Remember you can only use a variable "after" binding it.<br><br> []s<br> Edson</div></blockquote></div><div><br>Please allow me to a related question, regarding drools 3.0.x<br>
<br>In this LHS example, mentioned in this thread :<br><br>"""<br> $fred : Golfer( name == "Fred")<div class="Ih2E3d"><br> $bob : Golfer( name == "Bob",<br>
position != $fred.position,<br></div>
color == "plaid",<br>
color != $fred.color)<br>"""<br><br>$fred is a bind variable, but how is it possible to use a data member from this variable inside another node's ruling ? <br><br>Judging from Drools 3, this should have failed with compilation errors, assuming that it's a new feature of Drools 4, is there a possibility to implement this behavior in drools3? as it would be great help for me in my rules.<br>
<br>// Just for reference, the way I would implement the above logic in Drools 3 is :<br><br>
"""<br>
$fred : Golfer( name == "Fred", $fredPosition : position, $fredColor : color)<br>
$bob : Golfer( name == "Bob",<br>
position != $fredPosition,<br>
color == "plaid",<br>
color != $fredColor)<br>
"""<br>
<br><br>Thank you,<br>Maxim.<br></div><div><div></div><div class="Wj3C7c"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr"><br>
<br><div class="gmail_quote">2008/8/20 Marcin Krol <span dir="ltr"><<a href="mailto:mrkafk@gmail.com" target="_blank">mrkafk@gmail.com</a>></span><div>
<div></div><div><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello everyone,<br>
<br>
I managed to produce my first example of Drools rules. However, I am having problems with some field restrictions:<br>
<br>
Racing order:Unable to create restriction '[QualifiedIndentifierRestr: != $nissan.pos ]' for field 'pos' in the rule 'Racing order'<br>
<br>
The problem is only SOME field restrictions produce this error. Other field restrictions don't!<br>
<br>
If anybody has a hint or knows why this is not working, please let me know, I would greatly appreciate it.<br>
<br>
<br>
<br>
The rules are:<br>
<br>
<br>
#created on: 2008-08-20<br>
package com.sample<br>
<br>
#list any import classes here.<br>
<br>
#declare any global variables here<br>
<br>
dialect "mvel"<br>
<br>
import com.sample.Car;<br>
<br>
rule "Racing order"<br>
when<br>
<br>
// Porsche was not red<br>
$porsche : Car( manufacturer == "Porsche",<br>
pos != $nissan.pos,<br>
pos != $subaru.pos,<br>
color != "red"<br>
//color != "blue",<br>
//color != $nissan.color,<br>
//color != $subaru.color<br>
)<br>
<br>
<br>
// First car was Nissan<br>
$nissan : Car( manufacturer == "Nissan",<br>
pos == 1,<br>
color != $subaru.color,<br>
color != $porsche.color )<br>
<br>
// Subaru was blue<br>
$subaru : Car( manufacturer == "Subaru",<br>
//pos == 2,<br>
pos != $nissan.pos,<br>
pos != $porsche.pos,<br>
color == "blue" )<br>
<br>
// 2nd car was silver<br>
Car( pos == 2,<br>
color == "silver",<br>
this in ( $nissan, $subaru, $porsche ) )<br>
<br>
then<br>
System.out.println( "Nissan " + $nissan.getPos() + " " + $nissan.getColor() );<br>
System.out.println( "Subaru " + $subaru.getPos() + " " + $subaru.getColor() );<br>
System.out.println( "Porsche " + $porsche.getPos() + " " + $porsche.getColor() );<br>
<br>
end<br>
<br>
<br>
<br>
<br>
<br>
The Car.java file:<br>
<br>
<br>
package com.sample;<br>
<br>
public class Car {<br>
private String manufacturer;<br>
private String color;<br>
private int pos;<br>
<br>
public Car() {<br>
<br>
}<br>
<br>
public Car(String manufacturer, String color, int pos) {<br>
super();<br>
this.color = color;<br>
this.pos = pos;<br>
this.manufacturer = manufacturer;<br>
}<br>
<br>
public String getManufacturer() {<br>
return this.manufacturer;<br>
}<br>
<br>
public float getPos() {<br>
return this.pos;<br>
}<br>
<br>
public String getColor() {<br>
return this.color;<br>
}<br>
}<br>
<br>
<br>
<br>
<br>
The CarExample.java file, which is the main app:<br>
<br>
<br>
<br>
package com.sample;<br>
<br>
import java.io.InputStreamReader;<br>
<br>
import org.drools.RuleBase;<br>
import org.drools.RuleBaseFactory;<br>
import org.drools.StatefulSession;<br>
import org.drools.compiler.PackageBuilder;<br>
import com.sample.Car;<br>
<br>
public class CarExample {<br>
<br>
public static void main(String[] args) throws Exception {<br>
<br>
final PackageBuilder builder = new PackageBuilder();<br>
builder.addPackageFromDrl( new InputStreamReader( CarExample.class.getResourceAsStream( "CarExample.drl" ) ) );<br>
<br>
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br>
ruleBase.addPackage( builder.getPackage() );<br>
<br>
final StatefulSession session = ruleBase.newStatefulSession();<br>
<br>
String[] names = new String[] { "Nissan", "Subaru", "Porsche"};<br>
String[] colors = new String[] { "red", "blue", "silver"};<br>
int[] positions = new int[] { 1, 2, 3 };<br>
<br>
for ( int n = 0; n < names.length; n++ ) {<br>
for ( int c = 0; c < colors.length; c++ ) {<br>
for ( int p = 0; p < positions.length; p++ ) {<br>
session.insert( new Car( names[n], colors[c], positions[p]) );<br>
}<br>
}<br>
}<br>
<br>
session.fireAllRules();<br>
session.dispose();<br>
}<br>
<br>
<br>
<br>
}<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></div></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
</div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></div></div><br><br clear="all"><br>-- <br>Cheers, <br>Maxim Veksler<br><br>"Free as in Freedom" - Do u GNU ?<br>
</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><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>