[jboss-svn-commits] JBL Code SVN: r18849 - in labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main: rules/org/drools/benchmark/manners and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Mar 11 15:50:47 EDT 2008
Author: fmeyer
Date: 2008-03-11 15:50:47 -0400 (Tue, 11 Mar 2008)
New Revision: 18849
Modified:
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/troubleticket/ticketing.dsl
Log:
JBRULES-1502 - update example to use modify block as default
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java 2008-03-11 18:09:18 UTC (rev 18848)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java 2008-03-11 19:50:47 UTC (rev 18849)
@@ -2,6 +2,7 @@
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -16,6 +17,7 @@
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.rule.Package;
public class MannersBenchmark {
@@ -32,7 +34,10 @@
private int maxHobbies = 3;
public static void main(final String[] args) throws Exception {
- PackageBuilder builder = new PackageBuilder();
+ PackageBuilderConfiguration config = new PackageBuilderConfiguration();
+ config.setDumpDir( new File("/stash") );
+
+ PackageBuilder builder = new PackageBuilder(config);
builder.addPackageFromDrl(new InputStreamReader(MannersBenchmark.class
.getResourceAsStream("manners.drl")));
Package pkg = builder.getPackage();
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl 2008-03-11 18:09:18 UTC (rev 18848)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl 2008-03-11 19:50:47 UTC (rev 18849)
@@ -14,13 +14,11 @@
Path path = new Path( count.getValue(), 1, guestName );
insert( path );
- count.setValue( count.getValue() + 1 );
- update( count );
+ modify( count ) { setValue ( count.getValue() + 1 ) }
System.out.println( "assign first seat : " + seating + " : " + path );
- context.setState( Context.ASSIGN_SEATS );
- update( context );
+ modify( context ) { setState( Context.ASSIGN_SEATS ) }
end
rule findSeating
@@ -50,11 +48,8 @@
System.err.println( "find seating : " + seating + " : " + path + " : " + chosen);
- count.setValue( countValue + 1 );
- update( count );
-
- context.setState( Context.MAKE_PATH );
- update( context );
+ modify( count ) {setValue( countValue + 1 )}
+ modify( context ) {setState( Context.MAKE_PATH )}
end
rule makePath
@@ -72,11 +67,9 @@
context : Context( state == Context.MAKE_PATH )
seating : Seating( pathDone == false )
then
- seating.setPathDone( true );
- update( seating );
+ modify( seating ) {setPathDone( true )}
- context.setState( Context.CHECK_DONE );
- update( context );
+ modify( context ) {setState( Context.CHECK_DONE)}
end
@@ -86,16 +79,14 @@
LastSeat( lastSeat: seat )
Seating( rightSeat == lastSeat )
then
- context.setState(Context.PRINT_RESULTS );
- update( context );
+ modify( context ) {setState(Context.PRINT_RESULTS )}
end
rule continue
when
context : Context( state == Context.CHECK_DONE )
then
- context.setState( Context.ASSIGN_SEATS );
- update( context );
+ modify( context ) {setState( Context.ASSIGN_SEATS )}
end
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl 2008-03-11 18:09:18 UTC (rev 18848)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl 2008-03-11 19:50:47 UTC (rev 18849)
@@ -30,8 +30,7 @@
$stage: Stage ( value == Stage.DUPLICATE )
not ( Line() )
then
- $stage.setValue ( Stage.DETECT_JUNCTIONS );
- update($stage);
+ modify($stage) {setValue ( Stage.DETECT_JUNCTIONS )}
long current = System.currentTimeMillis();
System.out.println("reversing done : " + ( current - time ) );
drools.getWorkingMemory().setGlobal( "time", current);
@@ -52,12 +51,9 @@
Junction junction = WaltzUtil.make_3_junction( $basePoint, $edge1P2, $edge2P2, $edge3P2 );
System.out.println( junction );
insert( junction );
- $edge1.setJoined(true);
- $edge2.setJoined(true);
- $edge3.setJoined(true);
- update( $edge1 );
- update( $edge2 );
- update( $edge3 );
+ modify( $edge1 ) {setJoined(true)}
+ modify( $edge2 ) {setJoined(true)}
+ modify( $edge3 ) {setJoined(true)}
end
#If two, and only two, edges meet that have not already been joined, then
@@ -70,10 +66,8 @@
not Edge( p1==$basePoint, p2 != $edge1P2, p2 != $edge2P2 )
then
insert( new Junction($edge1P2, $edge2P2, 0, $basePoint, Junction.L) );
- $edge1.setJoined(true);
- $edge2.setJoined(true);
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setJoined(true)}
+ modify( $edge2 ) {setJoined(true)}
System.out.println("make L");
end
@@ -83,8 +77,7 @@
when
$stage : Stage ( value == Stage.DETECT_JUNCTIONS )
then
- $stage.setValue( Stage.FIND_INITIAL_BOUNDARY );
- update( $stage );
+ modify( $stage ) {setValue( Stage.FIND_INITIAL_BOUNDARY )}
System.out.println("detecting done");
end
@@ -97,12 +90,9 @@
$edge2 : Edge ( p1 == $basePoint, p2 == $p2 )
not Junction( basePoint > $basePoint )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.B );
- $stage.setValue( Stage.FIND_SECOND_BOUNDARY );
- update( $edge1 );
- update( $edge2 );
- update( $stage );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.B )}
+ modify( $stage ) {setValue( Stage.FIND_SECOND_BOUNDARY )}
System.out.println("initial boundary junction L");
end
@@ -116,14 +106,10 @@
$edge3 : Edge ( p1 == $basePoint, p2 == $p3 )
not Junction( basePoint > $basePoint )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.PLUS );
- $edge3.setLabel( Edge.B );
- $stage.setValue( Stage.FIND_SECOND_BOUNDARY );
- update( $edge1 );
- update( $edge2 );
- update( $edge3 );
- update( $stage );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
+ modify( $edge3 ) {setLabel( Edge.B )}
+ modify( $stage ) {setValue( Stage.FIND_SECOND_BOUNDARY )}
System.out.println("initial boundary junction arrow");
end
@@ -137,12 +123,9 @@
$edge2 : Edge ( p1 == $basePoint, p2 == $p2 )
not Junction( basePoint < $basePoint )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.B );
- $stage.setValue( Stage.LABELING );
- update( $edge1 );
- update( $edge2 );
- update( $stage );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.B )}
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println("second boundary junction L");
end
@@ -156,14 +139,10 @@
$edge3 : Edge ( p1 == $basePoint, p2 == $p3 )
not Junction( basePoint < $basePoint )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.PLUS );
- $edge3.setLabel( Edge.B );
- $stage.setValue( Stage.LABELING );
- update( $edge1 );
- update( $edge2 );
- update( $edge3 );
- update( $stage );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
+ modify( $edge3 ) {setLabel( Edge.B )}
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println("second boundary junction arrow");
end
@@ -175,11 +154,8 @@
$edge1: Edge( $p1:p1, $p2:p2, $label:label in ( Edge.PLUS, Edge.MINUS, Edge.B ) )
$edge2: Edge( p1 == $p2, p2 == $p1, label == Edge.NIL )
then
- $edge1.setPlotted( true );
- $edge2.setLabel( $label );
- $edge2.setPlotted( true );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setPlotted( true )}
+ modify( $edge2 ) {setLabel( $label ), setPlotted( true ) }
System.out.println("match edge - Plot "+$label+" "+$p1+" "+$p2);
end
@@ -197,8 +173,7 @@
Edge( p1 == $basePoint, $Edge1P2 : p2, label in ( Edge.PLUS, Edge.MINUS ) )
$edge: Edge( p1 == $basePoint, p2 != $Edge1P2, label == Edge.NIL )
then
- $edge.setLabel( Edge.B );
- update( $edge );
+ modify( $edge ) {setLabel( Edge.B )}
System.out.println("Label L");
end
@@ -209,10 +184,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p1, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p3 )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.B );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.B )}
System.out.println("Label tee A");
end
@@ -224,10 +197,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p1 )
$edge2: Edge( p1 == $basePoint, p2 == $p3, label == Edge.NIL )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.B );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.B )}
System.out.println("Label tee B");
end
@@ -239,10 +210,8 @@
$edge1: Edge( p1 == $basePoint, $p2:p2 != $p1, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 != $p1, p2 != $p2 )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label fork 1");
end
@@ -254,8 +223,7 @@
Edge( p1 == $basePoint, $p2:p2 != $p1, label == Edge.MINUS )
$edge: Edge( p1 == $basePoint, p2 != $p1, p2 != $p2, label == Edge.NIL )
then
- $edge.setLabel( Edge.B );
- update( $edge );
+ modify( $edge ) {setLabel( Edge.B )}
System.out.println("label fork 2");
end
@@ -267,8 +235,7 @@
Edge( p1 == $basePoint, $p2:p2 != $p1, label == Edge.B )
$edge: Edge( p1 == $basePoint, p2 != $p1, p2 != $p2, label == Edge.NIL )
then
- $edge.setLabel( Edge.MINUS );
- update( $edge );
+ modify( $edge ) {setLabel( Edge.MINUS )}
System.out.println("label fork 3");
end
@@ -280,8 +247,7 @@
Edge( p1 == $basePoint, $p2:p2 != $p1, label == Edge.MINUS )
$edge: Edge( p1 == $basePoint, p2 != $p1, p2 != $p2, label == Edge.NIL )
then
- $edge.setLabel( Edge.MINUS );
- update( $edge );
+ modify( $edge ) {setLabel( Edge.MINUS )}
System.out.println("label fork 4");
end
@@ -293,10 +259,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p3 )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( $label );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( $label )}
System.out.println("label arrow 1A");
end
@@ -308,10 +272,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2 )
$edge2: Edge( p1 == $basePoint, p2 == $p3, label == Edge.NIL )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( $label );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( $label )}
System.out.println("label arrow 1B");
end
@@ -323,10 +285,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p1 )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( $label );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( $label )}
System.out.println("label arrow 2A");
end
@@ -338,10 +298,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2 )
$edge2: Edge( p1 == $basePoint, p2 == $p1, label == Edge.NIL )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( $label );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( $label )}
System.out.println("label arrow 2B");
end
@@ -353,10 +311,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p3 )
then
- $edge1.setLabel( Edge.MINUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.MINUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 3A");
end
@@ -368,10 +324,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2 )
$edge2: Edge( p1 == $basePoint, p2 == $p3, label == Edge.NIL )
then
- $edge1.setLabel( Edge.MINUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.MINUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 3B");
end
@@ -383,10 +337,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p1 )
then
- $edge1.setLabel( Edge.MINUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.MINUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 4A");
end
@@ -398,10 +350,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2 )
$edge2: Edge( p1 == $basePoint, p2 == $p1, label == Edge.NIL )
then
- $edge1.setLabel( Edge.MINUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.MINUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 4B");
end
@@ -413,10 +363,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p1 )
$edge2: Edge( p1 == $basePoint, p2 == $p3, label == Edge.NIL )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 5A");
end
@@ -428,10 +376,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p1, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p3 )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 5B");
end
@@ -443,8 +389,7 @@
when
$stage: Stage( value == Stage.LABELING )
then
- $stage.setValue( Stage.PLOT_REMAINING_EDGES );
- update( $stage );
+ modify( $stage ) {setValue( Stage.PLOT_REMAINING_EDGES )}
System.out.println("done labeling");
end
@@ -455,8 +400,7 @@
$edge: Edge( plotted == false, $label:label != Edge.NIL, $p1:p1, $p2:p2 )
then
System.out.println("Plot "+$label+" "+$p1+" "+$p2);
- $edge.setPlotted( true );
- update( $edge );
+ modify( $edge ) {setPlotted( true )}
end
# If we have been un able to label an edge, assume that it is a boundary.
@@ -468,8 +412,7 @@
$edge: Edge( plotted == false, label == Edge.NIL, $p1:p1, $p2:p2 )
then
System.out.println("Plot B "+$p1+" "+$p2);
- $edge.setPlotted( true );
- update( $edge );
+ modify( $edge ) {setPlotted( true )}
end
# If there is no more work to do, then we are done and flag it.
@@ -477,7 +420,6 @@
when
$stage: Stage( value == Stage.PLOT_REMAINING_EDGES )
then
- $stage.setValue( Stage.DONE );
- update( $stage );
+ modify( $stage ) {setValue( Stage.DONE )}
System.out.println("Stage: done");
end
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl 2008-03-11 18:09:18 UTC (rev 18848)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl 2008-03-11 19:50:47 UTC (rev 18849)
@@ -40,8 +40,7 @@
$stage : Stage( value == Stage.DUPLICATE )
not ( Line( ) )
then
- $stage.setValue( Stage.DETECT_JUNCTIONS );
- update( $stage );
+ modify( $stage ) {setValue( Stage.DETECT_JUNCTIONS )}
System.out.println( "Stage.DETECT_JUNCTIONS" );
end
@@ -71,15 +70,9 @@
Junction junction = new Junction( $basePoint, "3j", "make_3_junction " + $basePoint + " " + $p1 + " " + " " + $p2 + " " + $p3, "no" );
insert( junction );
System.out.println( junction.toString( ) );
- $edge1.setJoined( true );
- $edge1.setType( "3j" );
- $edge2.setJoined( true );
- $edge2.setType( "3j" );
- $edge3.setJoined( true );
- $edge3.setType( "3j" );
- update( $edge1 );
- update( $edge2 );
- update( $edge3 );
+ modify( $edge1 ) {setJoined( true ), setType( "3j" )}
+ modify( $edge2 ) {setJoined( true ), setType( "3j" )}
+ modify( $edge3 ) {setJoined( true ), setType( "3j" )}
end
/*
(p make_L
@@ -109,12 +102,8 @@
Junction junction = new Junction( "2j", "L", $basePoint, $p2, $p3, "no" );
insert( junction );
System.out.println( junction.toString() );
- $edge1.setJoined( true );
- $edge1.setType( "2j" );
- $edge2.setJoined( true );
- $edge2.setType( "2j" );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setJoined( true ), setType( "2j" )}
+ modify( $edge2 ) {setJoined( true ), setType( "2j" )}
end
/*
@@ -130,8 +119,7 @@
$stage : Stage( value == Stage.DETECT_JUNCTIONS )
not( Edge ( joined == false ) )
then
- $stage.setValue( Stage.FIND_INITIAL_BOUNDARY );
- update( $stage );
+ modify( $stage ) {setValue( Stage.FIND_INITIAL_BOUNDARY )}
System.out.println( "Stage: FIND_INITIAL_BOUNDARY" );
end
@@ -156,12 +144,10 @@
Edge( p1 == $basePoint, p2 == $p2 )
not Junction( type == "2j", basePoint > $basePoint )//type == "2j" not in original
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
insert( new EdgeLabel( $basePoint, $p1, "B", "1" ) );
insert( new EdgeLabel( $basePoint, $p2, "B", "1" ) );
- $stage.setValue( Stage.FIND_SECOND_BOUDARY );
- update( $stage );
+ modify( $stage ) {setValue( Stage.FIND_SECOND_BOUDARY )}
System.out.println( "Stage.FIND_SECOND_BOUDARY" );
end
/*
@@ -190,13 +176,11 @@
$edge3 : Edge( p1 == $basePoint, p2 == $p3 ) //@FIXME, is this correct? I changed edge2 to edge3
not ( Junction( basePoint > $basePoint ) )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
insert( new EdgeLabel( $basePoint, $p1, "B", "14" ) );
insert( new EdgeLabel( $basePoint, $p2, "+", "14" ) );
insert( new EdgeLabel( $basePoint, $p3, "B", "14" ) );
- $stage.setValue( Stage.FIND_SECOND_BOUDARY );
- update( $stage );
+ modify( $stage ) {setValue( Stage.FIND_SECOND_BOUDARY )}
System.out.println( "Stage.FIND_SECOND_BOUDARY" );
end
@@ -223,12 +207,10 @@
Edge( p1 == $basePoint, p2 == $p2)
not (Junction ( basePoint < $basePoint ) )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
insert( new EdgeLabel( $basePoint, $p1, "B", "1" ) );
insert( new EdgeLabel($basePoint, $p2, "B", "1" ) );
- $stage.setValue( Stage.LABELING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println( "Stage.LABELING" );
end
@@ -258,13 +240,11 @@
Edge( p1 == $basePoint, p2 == $p3 )
not ( Junction( basePoint < $basePoint ) )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
insert( new EdgeLabel( $basePoint, $p1, "B", "14" ) );
insert( new EdgeLabel( $basePoint, $p2, "+", "14" ) );
insert( new EdgeLabel( $basePoint, $p3, "B", "14" ) );
- $stage.setValue( Stage.LABELING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println( "Stage.LABELING" );
end
@@ -282,10 +262,8 @@
$stage : Stage( value == Stage.LABELING )
$junction : Junction( type == "3j", $basePoint : basePoint, $p1 : p1, $p2 : p2, $p3 : p3, visited == "no" )
then
- $stage.setValue( Stage.VISITING_3J );
- update( $stage );
- $junction.setVisited( "now" );
- update( $junction );
+ modify( $stage ) {setValue( Stage.VISITING_3J )}
+ modify( $junction ) {setVisited( "now" )}
System.out.println( "Stage.VISITING_3J" );
end
@@ -599,11 +577,9 @@
$stage : Stage( value == Stage.LABELING )
$junction : Junction( $basePoint : basePoint, type == "2j", $p1 : p1, $p2 : p2, visited == "no" )
then
- $stage.setValue( Stage.VISITING_2J );
- update( $stage );
+ modify( $stage ) {setValue( Stage.VISITING_2J )}
System.out.println( "Stage.VISITING_2J" );
- $junction.setVisited( "now" );
- update( $junction );
+ modify( $junction ) {setVisited( "now" )}
end
/*
@@ -746,8 +722,7 @@
$stage : ( Stage( value == Stage.VISITING_2J ) || Stage( value == Stage.VISITING_3J ) )
$junction : Junction( visited == "now" )
then
- $stage.setValue( Stage.MARKING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.MARKING )}
System.out.println( "Stage.MARKING" );
end
/*
@@ -767,8 +742,7 @@
Edge( $p1 : p1, p2 == $basePoint )
$junction : Junction( basePoint == $p1, visited == "yes" )
then
- $junction.setVisited( "check" );
- update( $junction );
+ modify( $junction ) {setVisited( "check" )}
end
/*
@@ -784,8 +758,7 @@
Stage( value == Stage.MARKING )
$junction : Junction( $basePoint : basePoint, visited == "now" )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
end
/*
@@ -798,8 +771,7 @@
when
$stage : Stage( value == Stage.MARKING )
then
- $stage.setValue( Stage.CHECKING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.CHECKING )}
System.out.println( "Stage.CHECKING" );
end
@@ -822,8 +794,7 @@
Junction( basePoint == $p2, visited == "yes" )
not ( EdgeLabel( p1 == $p2, p2 == $basePoint, labelName == $labelName ) )
then
- $stage.setValue( Stage.REMOVE_LABEL );
- update( $stage );
+ modify( $stage ) {setValue( Stage.REMOVE_LABEL )}
System.out.println( "Stage.REMOVE_LABEL" );
insert ( new Illegal( $basePoint, $labelId ) );
end
@@ -854,8 +825,7 @@
$edgeLabel2 : EdgeLabel( p1 == $basePoint, p2 == $p2, labelId == $labelId )
$edgeLabel3 : EdgeLabel( p1 == $basePoint, p2 == $p3, labelId == $labelId )
then
- $stage.setValue( Stage.CHECKING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.CHECKING )}
System.out.println( "Stage.CHECKING" );
retract( $illegal );
retract( $edgeLabel1 );
@@ -886,8 +856,7 @@
$edgeLabel1 : EdgeLabel( p1 == $basePoint, p2 == $p1, labelId == $labelId )
$edgeLabel2 : EdgeLabel( p1 == $basePoint, p2 == $p2, labelId == $labelId )
then
- $stage.setValue( Stage.CHECKING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.CHECKING )}
System.out.println( "Stage.CHECKING" );
retract( $illegal );
retract( $edgeLabel1 );
@@ -907,8 +876,7 @@
Stage( value == Stage.CHECKING )
$junction : Junction( $basePoint : basePoint, visited == "check" )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
end
/*
@@ -921,8 +889,7 @@
when
$stage : Stage( value == Stage.CHECKING )
then
- $stage.setValue( Stage.LABELING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println( "Stage.LABELING" );
end
/*
@@ -935,8 +902,7 @@
when
$stage : Stage( value == Stage.LABELING )
then
- $stage.setValue( Stage.PRINTING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.PRINTING )}
System.out.println( "Stage.PRINTING" );
end
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl 2008-03-11 18:09:18 UTC (rev 18848)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl 2008-03-11 19:50:47 UTC (rev 18849)
@@ -32,7 +32,6 @@
exists( Hope() )
then
System.out.println( "I'm an evil corporation and I have corrupted " + politician.getName() );
- politician.setHonest( false );
- update( politician );
+ modify( politician ) {setHonest( false )}
end
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl 2008-03-11 18:09:18 UTC (rev 18848)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl 2008-03-11 19:50:47 UTC (rev 18849)
@@ -59,8 +59,7 @@
# A live cell has fewer than 2 live neighbors
theCell: Cell(liveNeighbors < 2, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.KILL);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.KILL)}
end
rule "Kill The Overcrowded"
@@ -70,8 +69,7 @@
# A live cell has more than 3 live neighbors
theCell: Cell(liveNeighbors > 3, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.KILL);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.KILL)}
end
rule "Give Birth"
@@ -81,8 +79,7 @@
# A dead cell has 3 live neighbors
theCell: Cell(liveNeighbors == 3, cellState == CellState.DEAD, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.BIRTH);
- update( theCell );
+ modify( theCell ){setPhase(Phase.BIRTH)}
end
rule "reset calculate"
@@ -99,9 +96,7 @@
when
theCell: Cell(phase == Phase.KILL)
then
- theCell.setCellState(CellState.DEAD);
- theCell.setPhase(Phase.DONE);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.DEAD), setPhase(Phase.DONE) }
end
rule "birth"
@@ -110,9 +105,7 @@
when
theCell: Cell(phase == Phase.BIRTH)
then
- theCell.setCellState(CellState.LIVE);
- theCell.setPhase(Phase.DONE);
- update( theCell );
+ modify( theCell ){setCellState(CellState.LIVE), setPhase(Phase.DONE) }
end
rule "Calculate Live"
@@ -122,9 +115,7 @@
theCell: Cell(cellState == CellState.LIVE)
Neighbor(cell == theCell, $neighbor : neighbor)
then
- $neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() + 1 );
- $neighbor.setPhase( Phase.EVALUATE );
- update( $neighbor );
+ modify( $neighbor ) {setLiveNeighbors( $neighbor.getLiveNeighbors() + 1 ), setPhase( Phase.EVALUATE )}
end
rule "Calculate Dead"
@@ -134,9 +125,7 @@
theCell: Cell(cellState == CellState.DEAD)
Neighbor(cell == theCell, $neighbor : neighbor )
then
- $neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() - 1 );
- $neighbor.setPhase( Phase.EVALUATE );
- update( $neighbor );
+ modify( $neighbor ) {setLiveNeighbors( $neighbor.getLiveNeighbors() - 1 ), setPhase( Phase.EVALUATE )}
end
rule "Kill All"
@@ -145,6 +134,5 @@
when
theCell: Cell(cellState == CellState.LIVE)
then
- theCell.setCellState(CellState.DEAD);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.DEAD)}
end
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl 2008-03-11 18:09:18 UTC (rev 18848)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl 2008-03-11 19:50:47 UTC (rev 18849)
@@ -59,8 +59,7 @@
# A live cell has fewer than 2 live neighbors
theCell: Cell(liveNeighbors < 2, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.KILL);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.KILL)}
end
rule "Kill The Overcrowded"
@@ -70,8 +69,7 @@
# A live cell has more than 3 live neighbors
theCell: Cell(liveNeighbors > 3, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.KILL);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.KILL)}
end
rule "Give Birth"
@@ -81,8 +79,7 @@
# A dead cell has 3 live neighbors
theCell: Cell(liveNeighbors == 3, cellState == CellState.DEAD, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.BIRTH);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.BIRTH)}
end
rule "reset calculate"
@@ -99,9 +96,7 @@
when
theCell: Cell(phase == Phase.KILL)
then
- theCell.setCellState(CellState.DEAD);
- theCell.setPhase(Phase.DONE);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.DEAD), setPhase(Phase.DONE)}
end
rule "birth"
@@ -110,9 +105,7 @@
when
theCell: Cell(phase == Phase.BIRTH)
then
- theCell.setCellState(CellState.LIVE);
- theCell.setPhase(Phase.DONE);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.LIVE), setPhase(Phase.DONE)}
end
rule "Calculate Live"
@@ -122,9 +115,7 @@
theCell: Cell(cellState == CellState.LIVE)
Neighbor(cell == theCell, $neighbor : neighbor)
then
- $neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() + 1 );
- $neighbor.setPhase( Phase.EVALUATE );
- update( $neighbor );
+ modify( $neighbor ) {setLiveNeighbors( $neighbor.getLiveNeighbors() + 1 ), setPhase( Phase.EVALUATE )}
end
rule "Calculate Dead"
@@ -134,9 +125,7 @@
theCell: Cell(cellState == CellState.DEAD)
Neighbor(cell == theCell, $neighbor : neighbor )
then
- $neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() - 1 );
- $neighbor.setPhase( Phase.EVALUATE );
- update( $neighbor );
+ modify( $neighbor ) {setLiveNeighbors( $neighbor.getLiveNeighbors() - 1 ), setPhase( Phase.EVALUATE )}
end
rule "Kill All"
@@ -145,6 +134,5 @@
when
theCell: Cell(cellState == CellState.LIVE)
then
- theCell.setCellState(CellState.DEAD);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.DEAD)}
end
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/troubleticket/ticketing.dsl
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/troubleticket/ticketing.dsl 2008-03-11 18:09:18 UTC (rev 18848)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/troubleticket/ticketing.dsl 2008-03-11 19:50:47 UTC (rev 18849)
@@ -1,5 +1,5 @@
[condition][]There is a customer ticket with status of "{status}"=customer : Customer( ) ticket : Ticket( customer == customer, status == "{status}" )
[condition][]There is a "{subscription}" customer with a ticket status of "{status}"=customer : Customer(subscription == "{subscription}") ticket : Ticket( customer == customer, status == "{status}")
[consequence][]Log "{message}"=System.out.println("{message} ");
-[consequence][]Escalate the ticket=ticket.setStatus("Escalate"); update(ticket);
+[consequence][]Escalate the ticket=modify(ticket) {setStatus("Escalate")}
[consequence][]Send escalation email=sendEscalationEmail( customer, ticket );
More information about the jboss-svn-commits
mailing list