[jboss-svn-commits] JBL Code SVN: r18894 - in labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main: rules/org/drools/benchmark/manners and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Mar 12 12:59:27 EDT 2008


Author: fmeyer
Date: 2008-03-12 12:59:27 -0400 (Wed, 12 Mar 2008)
New Revision: 18894

Modified:
   labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java
   labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl
   labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl
   labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl
   labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl
   labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/TroubleTicket.drl
   labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl
   labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl
   labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/ticketing.dsl
Log:
JBRULES-1502 -  update example to use modify block as default 


Modified: labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java	2008-03-12 16:53:26 UTC (rev 18893)
+++ labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java	2008-03-12 16:59:27 UTC (rev 18894)
@@ -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/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl	2008-03-12 16:53:26 UTC (rev 18893)
+++ labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl	2008-03-12 16:59:27 UTC (rev 18894)
@@ -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/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl	2008-03-12 16:53:26 UTC (rev 18893)
+++ labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl	2008-03-12 16:59:27 UTC (rev 18894)
@@ -28,8 +28,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("reversing done");
 end
 
@@ -48,12 +47,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
@@ -66,10 +62,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
 
@@ -79,8 +73,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
 
@@ -93,12 +86,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
 
@@ -112,14 +102,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
 
@@ -133,12 +119,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
 
@@ -152,14 +135,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
  
@@ -171,11 +150,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
 
@@ -193,8 +169,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 
  
@@ -205,10 +180,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 
 
@@ -220,10 +193,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
 
@@ -235,10 +206,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
 
@@ -250,8 +219,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
 
@@ -263,8 +231,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
 
@@ -276,8 +243,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
  
@@ -289,10 +255,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
  
@@ -304,10 +268,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
  
@@ -319,10 +281,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
  
@@ -334,10 +294,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
  
@@ -349,10 +307,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
  
@@ -364,10 +320,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
  
@@ -379,10 +333,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
  
@@ -394,10 +346,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
  
@@ -409,10 +359,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
 
@@ -424,10 +372,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
  
@@ -439,8 +385,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
 
@@ -451,8 +396,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.
@@ -464,8 +408,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.
@@ -473,7 +416,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/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl	2008-03-12 16:53:26 UTC (rev 18893)
+++ labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl	2008-03-12 16:59:27 UTC (rev 18894)
@@ -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/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl	2008-03-12 16:53:26 UTC (rev 18893)
+++ labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl	2008-03-12 16:59:27 UTC (rev 18894)
@@ -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/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/TroubleTicket.drl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/TroubleTicket.drl	2008-03-12 16:53:26 UTC (rev 18893)
+++ labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/TroubleTicket.drl	2008-03-12 16:59:27 UTC (rev 18894)
@@ -18,8 +18,7 @@
 		customer : Customer( subscription == "Silver" )	
 		ticket : Ticket( customer == customer, status == "New" )	
 	then
-		ticket.setStatus( "Escalate" );
-		update( ticket );		
+		modify( ticket ) {setStatus( "Escalate" )} 		
 end
 
 rule "Gold Priority"
@@ -28,8 +27,7 @@
 		customer : Customer( subscription == "Gold" )	
 		ticket : Ticket( customer == customer, status == "New" )	
 	then
-		ticket.setStatus( "Escalate" );	
-		update( ticket );		
+		modify( ticket ) {setStatus( "Escalate" )}	
 end
 
 rule "Platinum Priority"
@@ -38,7 +36,7 @@
 		ticket : Ticket( customer == customer, status == "New" )	
 	then;
 		ticket.setStatus( "Escalate" );
-		update( ticket );
+		modify ( ticket ) {setStatus( "Escalate" )}
 end
 
 rule "Escalate"

Modified: labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl	2008-03-12 16:53:26 UTC (rev 18893)
+++ labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl	2008-03-12 16:59:27 UTC (rev 18894)
@@ -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/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl	2008-03-12 16:53:26 UTC (rev 18893)
+++ labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl	2008-03-12 16:59:27 UTC (rev 18894)
@@ -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/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/ticketing.dsl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/ticketing.dsl	2008-03-12 16:53:26 UTC (rev 18893)
+++ labs/jbossrules/branches/4.0.x/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/ticketing.dsl	2008-03-12 16:59:27 UTC (rev 18894)
@@ -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