[jboss-svn-commits] JBL Code SVN: r20813 - in labs/jbossrules/trunk/drools-examples: drools-examples-drl/src/main/rules/org/drools/examples and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jun 26 11:08:30 EDT 2008


Author: KrisVerlaenen
Date: 2008-06-26 11:08:30 -0400 (Thu, 26 Jun 2008)
New Revision: 20813

Added:
   labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/OrderExample.java
Removed:
   labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/RuleSetExample.java
Modified:
   labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/NumberGuess.rf
   labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/NumberGuess.rfm
   labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/ClinicalPathwayX.rf
   labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/TreatmentX.rf
   labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/TreatmentY.rf
   labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/process/order/RuleSetExample.rf
   labs/jbossrules/trunk/drools-examples/drools-insurance/src/main/rules/approval/insurance-process.rf
Log:
JBRULES-1658: Generalize action framework

Copied: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/OrderExample.java (from rev 20797, labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/RuleSetExample.java)
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/OrderExample.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/OrderExample.java	2008-06-26 15:08:30 UTC (rev 20813)
@@ -0,0 +1,73 @@
+package org.drools.examples.process.order;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseConfiguration;
+import org.drools.RuleBaseFactory;
+import org.drools.StatefulSession;
+import org.drools.compiler.PackageBuilder;
+import org.drools.process.instance.impl.demo.UIWorkItemHandler;
+
+public class OrderExample {
+	
+	public static void main(String[] args) {
+		try {
+			RuleBase ruleBase = createKnowledgeBase();
+			StatefulSession session = ruleBase.newStatefulSession();
+			
+			CustomerService customerService = new DefaultCustomerService();
+			Customer c = new Customer("A-12345");
+			Calendar birthday = Calendar.getInstance();
+			birthday.set(1982, 1, 1);
+			c.setBirthday(birthday.getTime());
+			c.setFirstName("John");
+			c.setLastName("Doe");
+			customerService.addCustomer(c);
+			session.setGlobal("customerService", customerService);
+			
+			ItemCatalog itemCatalog = new DefaultItemCatalog();
+			Item i = new Item("I-9876");
+			i.setName("Rampage !!! PC game");
+			i.setMinimalAge(18);
+			//itemCatalog.addItem(i);
+			session.setGlobal("itemCatalog", itemCatalog);
+			
+			UIWorkItemHandler handler = new UIWorkItemHandler();
+			session.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
+			handler.setVisible(true);
+			
+			Order order = new Order();
+			order.setOrderId("O-ABCDE");
+			order.setCustomerId("A-12345");
+			order.addOrderItem("I-9876", 3, 50.0D);
+			session.insert(order);
+			
+			Map<String, Object> parameters = new HashMap<String, Object>();
+			parameters.put("orderId", order.getOrderId());
+			session.startProcess("org.drools.examples.process.ruleset.RuleSetExample", parameters);
+			session.fireAllRules();
+		} catch (Throwable t) {
+			t.printStackTrace();
+		}
+	}
+
+	private static RuleBase createKnowledgeBase() throws Exception {
+		PackageBuilder builder = new PackageBuilder();
+		Reader source = new InputStreamReader(
+			OrderExample.class.getResourceAsStream("RuleSetExample.rf"));
+		builder.addProcessFromXml(source);
+		source = new InputStreamReader(
+			OrderExample.class.getResourceAsStream("validation.drl"));
+		builder.addPackageFromDrl(source);
+		RuleBaseConfiguration configuration = new RuleBaseConfiguration();
+		configuration.setAdvancedProcessRuleIntegration(true);
+		RuleBase ruleBase = RuleBaseFactory.newRuleBase(configuration);
+		ruleBase.addPackage(builder.getPackage());
+		return ruleBase;
+	}
+}

Deleted: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/RuleSetExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/RuleSetExample.java	2008-06-26 15:07:27 UTC (rev 20812)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/RuleSetExample.java	2008-06-26 15:08:30 UTC (rev 20813)
@@ -1,70 +0,0 @@
-package org.drools.examples.process.order;
-
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
-import org.drools.compiler.PackageBuilder;
-import org.drools.process.instance.impl.demo.UIWorkItemHandler;
-
-public class RuleSetExample {
-	
-	public static void main(String[] args) {
-		try {
-			RuleBase ruleBase = createKnowledgeBase();
-			StatefulSession session = ruleBase.newStatefulSession();
-			
-			CustomerService customerService = new DefaultCustomerService();
-			Customer c = new Customer("A-12345");
-			Calendar birthday = Calendar.getInstance();
-			birthday.set(1982, 1, 1);
-			c.setBirthday(birthday.getTime());
-			c.setFirstName("John");
-			c.setLastName("Doe");
-			customerService.addCustomer(c);
-			session.setGlobal("customerService", customerService);
-			
-			ItemCatalog itemCatalog = new DefaultItemCatalog();
-			Item i = new Item("I-9876");
-			i.setName("Rampage !!! PC game");
-			i.setMinimalAge(18);
-			itemCatalog.addItem(i);
-			session.setGlobal("itemCatalog", itemCatalog);
-			
-			UIWorkItemHandler handler = new UIWorkItemHandler();
-			session.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
-			handler.setVisible(true);
-			
-			Order order = new Order();
-			order.setOrderId("O-ABCDE");
-			order.setCustomerId("A-12345");
-			order.addOrderItem("I-9876", 3, 50.0D);
-			session.insert(order);
-			
-			Map<String, Object> parameters = new HashMap<String, Object>();
-			parameters.put("orderId", order.getOrderId());
-			session.startProcess("org.drools.examples.process.ruleset.RuleSetExample", parameters);
-			session.fireAllRules();
-		} catch (Throwable t) {
-			t.printStackTrace();
-		}
-	}
-
-	private static RuleBase createKnowledgeBase() throws Exception {
-		PackageBuilder builder = new PackageBuilder();
-		Reader source = new InputStreamReader(
-				RuleSetExample.class.getResourceAsStream("RuleSetExample.rf"));
-		builder.addProcessFromXml(source);
-		source = new InputStreamReader(
-				RuleSetExample.class.getResourceAsStream("validation.drl"));
-		builder.addPackageFromDrl(source);
-		RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-		ruleBase.addPackage(builder.getPackage());
-		return ruleBase;
-	}
-}

Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/NumberGuess.rf
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/NumberGuess.rf	2008-06-26 15:07:27 UTC (rev 20812)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/NumberGuess.rf	2008-06-26 15:08:30 UTC (rev 20813)
@@ -14,7 +14,9 @@
 
   <nodes>
     <start id="1" name="Start" x="76" y="60" width="80" height="40" />
-    <action id="2" name="Guess correct" x="219" y="260" width="102" height="40" dialect="mvel" >System.out.println( "You guessed correctly" );</action>
+    <actionNode id="2" name="Guess correct" x="219" y="260" width="102" height="40" >
+      <action type="expression" dialect="mvel" >System.out.println( "You guessed correctly" );</action>
+    </actionNode>
     <ruleSet id="3" name="No more Guesses" x="499" y="260" width="109" height="40" ruleFlowGroup="No more Guesses" />
     <end id="4" name="End" x="373" y="336" width="80" height="40" />
     <split id="5" name="Guess correct?" x="59" y="261" width="115" height="40" type="2" >
@@ -40,8 +42,12 @@
     <join id="9" name="Incorrect guess" x="67" y="387" width="103" height="40" type="2" />
     <join id="10" name="No more guesses Join" x="350" y="261" width="128" height="40" type="2" />
     <ruleSet id="11" name="Guess incorrect" x="79" y="455" width="80" height="40" ruleFlowGroup="Guess incorrect" />
-    <action id="12" name="Too high" x="3" y="325" width="80" height="40" dialect="mvel" >System.out.println( "Your guess was too high" );</action>
-    <action id="13" name="Too low" x="154" y="324" width="80" height="40" dialect="mvel" >System.out.println( "Your guess was too low" );</action>
+    <actionNode id="12" name="Too high" x="3" y="325" width="80" height="40" >
+      <action type="expression" dialect="mvel" >System.out.println( "Your guess was too high" );</action>
+    </actionNode>
+    <actionNode id="13" name="Too low" x="154" y="324" width="80" height="40" >
+      <action type="expression" dialect="mvel" >System.out.println( "Your guess was too low" );</action>
+    </actionNode>
   </nodes>
 
   <connections>

Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/NumberGuess.rfm
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/NumberGuess.rfm	2008-06-26 15:07:27 UTC (rev 20812)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/NumberGuess.rfm	2008-06-26 15:08:30 UTC (rev 20813)
@@ -14,7 +14,9 @@
 
   <nodes>
     <start id="1" name="Start" />
-    <action id="2" name="Guess correct" dialect="mvel" >System.out.println( "You guessed correctly" );</action>
+    <actionNode id="2" name="Guess correct" >
+      <action type="expression" dialect="mvel" >System.out.println( "You guessed correctly" );</action>
+    </actionNode>
     <ruleSet id="3" name="No more Guesses" ruleFlowGroup="No more Guesses" />
     <end id="4" name="End" />
     <split id="5" name="Guess correct?" type="2" >
@@ -40,8 +42,12 @@
     <join id="9" name="Incorrect guess" type="2" />
     <join id="10" name="No more guesses Join" type="2" />
     <ruleSet id="11" name="Guess incorrect" ruleFlowGroup="Guess incorrect" />
-    <action id="12" name="Too high" dialect="mvel" >System.out.println( "Your guess was too high" );</action>
-    <action id="13" name="Too low" dialect="mvel" >System.out.println( "Your guess was too low" );</action>
+    <actionNode id="12" name="Too high" >
+      <action type="expression" dialect="mvel" >System.out.println( "Your guess was too high" );</action>
+    </actionNode>
+    <actionNode id="13" name="Too low" >
+      <action type="expression" dialect="mvel" >System.out.println( "Your guess was too low" );</action>
+    </actionNode>
   </nodes>
 
   <connections>

Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/ClinicalPathwayX.rf
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/ClinicalPathwayX.rf	2008-06-26 15:07:27 UTC (rev 20812)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/ClinicalPathwayX.rf	2008-06-26 15:08:30 UTC (rev 20813)
@@ -13,7 +13,9 @@
 
   <nodes>
     <start id="1" name="Start" x="26" y="100" width="80" height="40" />
-    <action id="3" name="Notify GP" x="463" y="199" width="80" height="40" dialect="mvel" >System.out.println("Notifying GP of patient of the diagnose.");</action>
+    <actionNode id="3" name="Notify GP" x="463" y="199" width="80" height="40" >
+      <action type="expression" dialect="mvel" >System.out.println("Notifying GP of patient of the diagnose.");</action>
+    </actionNode>
     <ruleSet id="4" name="Examinations" x="145" y="102" ruleFlowGroup="Examinations" />
     <join id="5" name="" x="255" y="113" width="19" height="17" type="2" />
     <ruleSet id="6" name="Additional Examinations" x="310" y="24" width="144" height="40" ruleFlowGroup="AdditionalExaminations" />
@@ -34,7 +36,9 @@
     <subProcess id="10" name="Treatment Y" x="437" y="342" width="99" height="40" processId="org.drools.examples.cdss.TreatmentY" />
     <join id="11" name="" x="416" y="416" width="19" height="19" type="2" />
     <end id="12" name="End" x="576" y="341" width="80" height="40" />
-    <action id="13" name="Schedule Follow-up" x="356" y="455" width="139" height="40" dialect="mvel" >System.out.println("Scheduling follow-up of patient.");</action>
+    <actionNode id="13" name="Schedule Follow-up" x="356" y="455" width="139" height="40" >
+      <action type="expression" dialect="mvel" >System.out.println("Scheduling follow-up of patient.");</action>
+    </actionNode>
     <end id="14" name="End" x="386" y="528" width="80" height="40" />
     <milestone id="15" name="Wait for Diagnose" x="293" y="101" width="124" height="40" >Diagnose( )</milestone>
   </nodes>

Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/TreatmentX.rf
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/TreatmentX.rf	2008-06-26 15:07:27 UTC (rev 20812)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/TreatmentX.rf	2008-06-26 15:08:30 UTC (rev 20813)
@@ -9,7 +9,9 @@
 
   <nodes>
     <start id="1" name="Start" x="100" y="100" />
-    <action id="2" name="Dummy TreatmentX" x="214" y="99" width="138" height="40" dialect="mvel" >System.out.println("Executing TreatmentX");</action>
+    <actionNode id="2" name="Dummy TreatmentX" x="214" y="99" width="138" height="40"  >
+      <action type="expression" dialect="mvel" >System.out.println("Executing TreatmentX");</action>
+    </actionNode>
     <end id="3" name="End" x="398" y="99" />
   </nodes>
 

Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/TreatmentY.rf
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/TreatmentY.rf	2008-06-26 15:07:27 UTC (rev 20812)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/cdss/TreatmentY.rf	2008-06-26 15:08:30 UTC (rev 20813)
@@ -11,9 +11,15 @@
     <start id="1" name="Start" x="45" y="99" width="80" height="40" />
     <split id="2" name="AND" x="156" y="105" width="49" height="34" type="1" />
     <join id="3" name="AND" x="432" y="102" width="54" height="34" type="1" />
-    <action id="4" name="Dummy TreatmentY Part1" x="240" y="46" width="161" height="40" dialect="mvel" >System.out.println("Executing TreatmentY Part1");</action>
-    <action id="5" name="Dummy TreatmentY Part2" x="241" y="99" width="160" height="40" dialect="mvel" >System.out.println("Executing TreatmentY Part2");</action>
-    <action id="6" name="Dummy TreatmentY Part3" x="241" y="151" width="160" height="40" dialect="mvel" >System.out.println("Executing TreatmentY Part3");</action>
+    <actionNode id="4" name="Dummy TreatmentY Part1" x="240" y="46" width="161" height="40" >
+      <action type="expression" dialect="mvel" >System.out.println("Executing TreatmentY Part1");</action>
+    </actionNode>
+    <actionNode id="5" name="Dummy TreatmentY Part2" x="241" y="99" width="160" height="40" >
+      <action type="expression" dialect="mvel" >System.out.println("Executing TreatmentY Part2");</action>
+    </actionNode>
+    <actionNode id="6" name="Dummy TreatmentY Part3" x="241" y="151" width="160" height="40" >
+      <action type="expression" dialect="mvel" >System.out.println("Executing TreatmentY Part3");</action>
+    </actionNode>
     <end id="7" name="End" x="509" y="98" width="80" height="40" />
   </nodes>
 

Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/process/order/RuleSetExample.rf
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/process/order/RuleSetExample.rf	2008-06-26 15:07:27 UTC (rev 20812)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/process/order/RuleSetExample.rf	2008-06-26 15:08:30 UTC (rev 20813)
@@ -33,26 +33,26 @@
     <end id="8" name="End" x="88" y="486" width="80" height="40" />
     <humanTask id="9" name="Correct Order" x="16" y="215" width="96" height="40" swimlane="SalesRepresentative" >
       <work name="Human Task" >
+        <parameter name="Comment" type="org.drools.process.core.datatype.impl.type.StringDataType" >Invalid order #{orderId}, needs to be corrected (contact customer if necessary)</parameter>
+        <parameter name="Priority" type="org.drools.process.core.datatype.impl.type.StringDataType" />
         <parameter name="TaskName" type="org.drools.process.core.datatype.impl.type.StringDataType" >Correct Order</parameter>
-        <parameter name="Priority" type="org.drools.process.core.datatype.impl.type.StringDataType" />
         <parameter name="ActorId" type="org.drools.process.core.datatype.impl.type.StringDataType" />
-        <parameter name="Comment" type="org.drools.process.core.datatype.impl.type.StringDataType" >Invalid order ${orderId}, needs to be corrected (contact customer if necessary)</parameter>
       </work>
     </humanTask>
     <humanTask id="10" name="Follow-up Order" x="144" y="215" width="106" height="40" swimlane="SalesRepresentative" >
       <work name="Human Task" >
+        <parameter name="Comment" type="org.drools.process.core.datatype.impl.type.StringDataType" >This is a large order, follow up this order manually</parameter>
+        <parameter name="Priority" type="org.drools.process.core.datatype.impl.type.StringDataType" />
         <parameter name="TaskName" type="org.drools.process.core.datatype.impl.type.StringDataType" >Follow-up Order</parameter>
-        <parameter name="Priority" type="org.drools.process.core.datatype.impl.type.StringDataType" />
         <parameter name="ActorId" type="org.drools.process.core.datatype.impl.type.StringDataType" />
-        <parameter name="Comment" type="org.drools.process.core.datatype.impl.type.StringDataType" >This is a large order, follow up this order manually</parameter>
       </work>
     </humanTask>
     <humanTask id="11" name="Human Task" x="72" y="340" width="111" height="40" >
       <work name="Human Task" >
+        <parameter name="Comment" type="org.drools.process.core.datatype.impl.type.StringDataType" />
+        <parameter name="Priority" type="org.drools.process.core.datatype.impl.type.StringDataType" />
         <parameter name="TaskName" type="org.drools.process.core.datatype.impl.type.StringDataType" />
-        <parameter name="Priority" type="org.drools.process.core.datatype.impl.type.StringDataType" />
         <parameter name="ActorId" type="org.drools.process.core.datatype.impl.type.StringDataType" />
-        <parameter name="Comment" type="org.drools.process.core.datatype.impl.type.StringDataType" />
       </work>
     </humanTask>
   </nodes>

Modified: labs/jbossrules/trunk/drools-examples/drools-insurance/src/main/rules/approval/insurance-process.rf
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-insurance/src/main/rules/approval/insurance-process.rf	2008-06-26 15:07:27 UTC (rev 20812)
+++ labs/jbossrules/trunk/drools-examples/drools-insurance/src/main/rules/approval/insurance-process.rf	2008-06-26 15:08:30 UTC (rev 20813)
@@ -25,8 +25,12 @@
 $policy : Policy( approved == true )</constraint>
       </constraints>
     </split>
-    <action id="8" name="Action" x="333" y="68" width="80" height="40" dialect="mvel" >System.out.println("Insurance calculate");</action>
-    <action id="9" name="Action" x="333" y="138" dialect="mvel" >System.out.println("Rejection");</action>
+    <actionNode id="8" name="Action" x="333" y="68" width="80" height="40" >
+      <action type="expression" dialect="mvel" >System.out.println("Insurance calculate");</action>
+    </actionNode>
+    <actionNode id="9" name="Action" x="333" y="138" >
+      <action type="expression" dialect="mvel" >System.out.println("Rejection");</action>
+    </actionNode>
   </nodes>
 
   <connections>




More information about the jboss-svn-commits mailing list