[jbpm-commits] JBoss JBPM SVN: r4582 - in jbpm4/trunk/modules: api/src/main/resources and 19 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Apr 20 09:09:19 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-04-20 09:09:19 -0400 (Mon, 20 Apr 2009)
New Revision: 4582

Added:
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/subprocess/
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/subprocess/variables/
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/subprocess/variables/SubProcessVariablesTest.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessDocument.jpdl.xml
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessReview.jpdl.xml
   jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.subprocess.review.png
Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientProcessDefinition.java
   jbpm4/trunk/modules/api/src/main/resources/jpdl-4.0.xsd
   jbpm4/trunk/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.execution.hbm.xml
   jbpm4/trunk/modules/distro/src/main/resources/config-tool/jbpm/jbpm.jpdl.activities.xml
   jbpm4/trunk/modules/distro/src/main/resources/config-tool/jbpm/wire.bindings/part1.jbpm.wire.bindings.xml
   jbpm4/trunk/modules/examples/src/test/resources/jbpm.execution.hbm.xml
   jbpm4/trunk/modules/examples/src/test/resources/jbpm.jpdl.activities.xml
   jbpm4/trunk/modules/examples/src/test/resources/jbpm.wire.bindings.xml
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
   jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.execution.hbm.xml
   jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.jpdl.activities.xml
   jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.wire.bindings.xml
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java
   jbpm4/trunk/modules/pvm/src/test/resources/jbpm.execution.hbm.xml
   jbpm4/trunk/modules/pvm/src/test/resources/jbpm.jpdl.activities.xml
   jbpm4/trunk/modules/pvm/src/test/resources/jbpm.wire.bindings.xml
   jbpm4/trunk/modules/test-db/src/test/resources/jbpm.execution.hbm.xml
   jbpm4/trunk/modules/test-db/src/test/resources/jbpm.jpdl.activities.xml
   jbpm4/trunk/modules/test-db/src/test/resources/jbpm.wire.bindings.xml
   jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.state.choice.png
   jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
Log:
JBPM-2025 sub-process example and docs

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientProcessDefinition.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientProcessDefinition.java	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientProcessDefinition.java	2009-04-20 13:09:19 UTC (rev 4582)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.api.client;
 
+import org.jbpm.api.Execution;
 import org.jbpm.api.model.OpenExecution;
 import org.jbpm.api.model.OpenProcessDefinition;
 
@@ -46,6 +47,15 @@
    * @param key is a user provided reference that uniquely identifies this 
    * process instance in the scope of the process name. */
   ClientProcessInstance createProcessInstance(String key);
+  
+  /** creates a new process instances with a given key. The returned process instance 
+   * is not started yet.  This way, 
+   * {@link OpenExecution#setVariable(String, Object) variables can be set} 
+   * before execution is started.  Invoke {@link ClientProcessInstance#start()} 
+   * to start execution of the process. 
+   * @param key is a user provided reference that uniquely identifies this 
+   * process instance in the scope of the process name. key is allowed to be null.*/
+  ClientProcessInstance createProcessInstance(String key, Execution superProcessExecution);
 
   /** creates the process instance and immediately start its execution. */
   ClientExecution startProcessInstance();

Modified: jbpm4/trunk/modules/api/src/main/resources/jpdl-4.0.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/jpdl-4.0.xsd	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/api/src/main/resources/jpdl-4.0.xsd	2009-04-20 13:09:19 UTC (rev 4582)
@@ -214,6 +214,7 @@
         </complexType>
       </element>
 
+      <!-- ~~~ FORK ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       <element name="fork">
         <annotation><documentation>Spawns multiple concurrent paths of 
         execution.
@@ -227,6 +228,7 @@
         </complexType>
       </element>
     
+      <!-- ~~~ JOIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       <element name="join">
         <annotation><documentation>Spawns multiple concurrent paths of 
         execution.
@@ -240,6 +242,7 @@
         </complexType>
       </element>
 
+      <!-- ~~~ SCRIPT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       <element name="script">
         <annotation><documentation>Evaluates a piece of text as a script
         </documentation></annotation>
@@ -256,6 +259,7 @@
         </complexType>
       </element>
 
+      <!-- ~~~ HQL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       <element name="hql">
         <annotation><documentation>Performs a hibernate query
         </documentation></annotation>
@@ -272,6 +276,7 @@
         </complexType>
       </element>
 
+      <!-- ~~~ SQL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       <element name="sql">
         <annotation><documentation>Performs a hibernate SQL query
         </documentation></annotation>
@@ -288,6 +293,7 @@
         </complexType>
       </element>
 
+      <!-- ~~~ JAVA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       <element name="java">
         <annotation><documentation>Invokes a method on a java object.  
         Either the java class is instantiated with reflection, or the 
@@ -307,6 +313,7 @@
         </complexType>
       </element>
 
+      <!-- ~~~ ESB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       <element name="esb">
         <annotation><documentation>Invokes a service over the ESB.  
         </documentation></annotation>
@@ -323,6 +330,7 @@
         </complexType>
       </element>
 
+      <!-- ~~~ TASK ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
       <element name="task">
         <annotation><documentation>Creates a task in the task component.  
         </documentation></annotation>
@@ -358,29 +366,68 @@
         </complexType>
       </element>
       
-      <!-- 
-      <element name="process-state">
+      <!-- ~~~ SUB-PROCESS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+      <element name="sub-process">
         <annotation><documentation>Waits while a sub process instance is 
         being executed and continues when the sub process instance ends.
         </documentation></annotation>
-        < ! - - take into account the following situation:
-        Unlike in jBPM 3, a process-state should not signal the newly created 
-        process instance.  The signal in jBPM 3 is probably historically there 
-        because in the beginning there was no initial attribute on the process
-        definition.
-        - - >
         <complexType>
-          <sequence>
-            <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+          <sequence minOccurs="0" maxOccurs="unbounded">
+            <element ref="tns:variable" minOccurs="0" maxOccurs="unbounded" />
+            <element ref="tns:out-variable" minOccurs="0" maxOccurs="unbounded" />
+            <element ref="tns:timer" minOccurs="0" maxOccurs="unbounded"/>
             <element ref="tns:on" minOccurs="0" maxOccurs="unbounded">
               <annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
             </element>
-            <element ref="tns:timer" minOccurs="0" maxOccurs="unbounded"/>
+            <element name="swimlane-mapping" minOccurs="0" maxOccurs="unbounded">
+              <complexType>
+                <attribute name="swimlane" type="string" use="required" />
+                <attribute name="sub-swimlane" type="string" use="required" />
+              </complexType>
+            </element>
+            <element name="transition" minOccurs="0" maxOccurs="unbounded">
+              <complexType>
+                <complexContent>
+                  <extension base="tns:transitionType">
+                    <sequence minOccurs="0" maxOccurs="unbounded">
+                      <element name="outcome-value">
+                        <complexType>
+                          <group ref="tns:wireObjectGroup" />
+                        </complexType>
+                      </element>
+                      <element name="outcome">
+                        <complexType>
+                          <attribute name="activity" type="string" use="required" />
+                        </complexType>
+                      </element>
+                    </sequence>
+                  </extension>
+                </complexContent>
+              </complexType>
+            </element>
           </sequence>
+          <attribute name="sub-process-id" type="string">
+            <annotation><documentation>Identifies the sub process by the id.  This means that a specific 
+              version of a process definition is referenced
+            </documentation></annotation>
+          </attribute>
+          <attribute name="sub-process-key" type="string">
+            <annotation><documentation>Identifies the sub process by the key.  This means that the latest 
+              version of the process definition with the given key is referenced.  The latest version 
+              of the process is looked up each time the activity executes.  
+            </documentation></annotation>
+          </attribute>
+          <attribute name="outcome" type="string">
+            <annotation><documentation>Expression that is evaluated when the sub process 
+            instance ends.  The value is then used for outcome transition mapping. 
+            </documentation></annotation>
+          </attribute>
           <attributeGroup ref="tns:activityAttributes" />
         </complexType>
       </element>
 
+      <!-- ~~~ SUPER-STATE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+      <!-- 
       <element name="super-state">
         <annotation><documentation>Scope enclosing a number of activities.
         </documentation></annotation>
@@ -644,6 +691,35 @@
     </complexType>
   </element>
 
+  <element name="variable">
+    <complexType>
+      <attribute name="name" type="string">
+        <annotation><documentation>The name of the variable.
+        </documentation></annotation>
+      </attribute>
+      <attribute name="init" type="string">
+        <annotation><documentation>An expression for which the resulting 
+        value will be used as initial value for the variable.
+        </documentation></annotation>
+      </attribute>
+    </complexType>
+  </element>
+
+  <element name="out-variable">
+    <complexType>
+      <attribute name="name" type="string">
+        <annotation><documentation>The name of the variable.
+        </documentation></annotation>
+      </attribute>
+      <attribute name="init" type="string">
+        <annotation><documentation>An expression that will be resolved in the 
+        inner scope and for which the resulting value will be set as a variable 
+        in the outer scope.
+        </documentation></annotation>
+      </attribute>
+    </complexType>
+  </element>
+
   <element name="timer">
     <complexType>
       <sequence>

Modified: jbpm4/trunk/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.execution.hbm.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.execution.hbm.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -94,6 +94,12 @@
                  foreign-key="FK_EXEC_SUPEREXEC"
                  index="IDX_EXEC_SUPEREXEC" />
                  
+    <many-to-one name="subProcessInstance"
+                 column="SUBPROCINST_"
+                 class="ExecutionImpl"
+                 foreign-key="FK_EXEC_SUBPI"
+                 index="IDX_EXEC_SUBPI" />
+                 
   </class>
 
   <!-- ### COMMENTS ####################################################### -->

Modified: jbpm4/trunk/modules/distro/src/main/resources/config-tool/jbpm/jbpm.jpdl.activities.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/resources/config-tool/jbpm/jbpm.jpdl.activities.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/distro/src/main/resources/config-tool/jbpm/jbpm.jpdl.activities.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -13,4 +13,5 @@
   <activity binding="org.jbpm.jpdl.internal.activity.ScriptBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.EsbBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.TaskBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.SubProcessBinding" />
 </activities>

Modified: jbpm4/trunk/modules/distro/src/main/resources/config-tool/jbpm/wire.bindings/part1.jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/resources/config-tool/jbpm/wire.bindings/part1.jbpm.wire.bindings.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/distro/src/main/resources/config-tool/jbpm/wire.bindings/part1.jbpm.wire.bindings.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -52,6 +52,8 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionFactoryBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.RepositorySessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailTemplateBinding" />
   
   <!-- db sessions -->
   <binding class="org.jbpm.pvm.internal.wire.binding.PvmDbSessionBinding" />

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/subprocess/variables/SubProcessVariablesTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/subprocess/variables/SubProcessVariablesTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/subprocess/variables/SubProcessVariablesTest.java	2009-04-20 13:09:19 UTC (rev 4582)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.subprocess.variables;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SubProcessVariablesTest extends JbpmTestCase {
+
+  long reviewDeploymentDbid;
+  long subProcessDeploymentDbid;
+  
+  protected void setUp() throws Exception {
+    super.setUp();
+    
+    reviewDeploymentDbid = repositoryService.createDeployment()
+        .addResourceFromClasspath("org/jbpm/examples/subprocess/variables/SubProcessReview.jpdl.xml")
+        .deploy();
+
+    subProcessDeploymentDbid = repositoryService.createDeployment()
+        .addResourceFromClasspath("org/jbpm/examples/subprocess/variables/SubProcessDocument.jpdl.xml")
+        .deploy();
+  }
+
+  protected void tearDown() throws Exception {
+    repositoryService.deleteDeploymentCascade(reviewDeploymentDbid);
+    repositoryService.deleteDeploymentCascade(subProcessDeploymentDbid);
+    
+    super.tearDown();
+  }
+
+  public void testWaitStatesSequence() {
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("document", "This document describes how we can make more money...");
+    
+    ProcessInstance processInstance = executionService
+        .startProcessInstanceByKey("SubProcessDocument", variables);
+    
+    assertNotNull(processInstance.findActiveExecutionIn("review"));
+
+    List<Task> taskList = taskService.findAssignedTasks("johndoe");
+    Task task = taskList.get(0);
+    
+    // first we show that the document has been passed to the sub process instance 
+    // and is available as a task variable
+    String document = (String) taskService.getVariable(task.getDbid(), "document");
+    assertEquals("This document describes how we can make more money...", document);
+    
+    // the result variable is set in the task
+    taskService.setVariable(task.getDbid(), "result", "accept");
+    
+    // the task in the sub process instance is completed 
+    taskService.completeTask(task.getDbid());
+
+    // we check that the process instance has moved to the wait state activity 
+    processInstance = executionService.findProcessInstanceById(processInstance.getId());
+    assertNotNull(processInstance.findActiveExecutionIn("wait"));
+    
+    // and we check that the result has been propagated from the sub process 
+    // into the parent process
+    String result = (String) executionService.getVariable(processInstance.getId(), "reviewResult");
+    assertEquals("accept", result);
+  }
+}


Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/subprocess/variables/SubProcessVariablesTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: jbpm4/trunk/modules/examples/src/test/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/jbpm.execution.hbm.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/examples/src/test/resources/jbpm.execution.hbm.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -94,6 +94,12 @@
                  foreign-key="FK_EXEC_SUPEREXEC"
                  index="IDX_EXEC_SUPEREXEC" />
                  
+    <many-to-one name="subProcessInstance"
+                 column="SUBPROCINST_"
+                 class="ExecutionImpl"
+                 foreign-key="FK_EXEC_SUBPI"
+                 index="IDX_EXEC_SUBPI" />
+                 
   </class>
 
   <!-- ### COMMENTS ####################################################### -->

Modified: jbpm4/trunk/modules/examples/src/test/resources/jbpm.jpdl.activities.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/jbpm.jpdl.activities.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/examples/src/test/resources/jbpm.jpdl.activities.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -13,4 +13,5 @@
   <activity binding="org.jbpm.jpdl.internal.activity.ScriptBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.EsbBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.TaskBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.SubProcessBinding" />
 </activities>

Modified: jbpm4/trunk/modules/examples/src/test/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/jbpm.wire.bindings.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/examples/src/test/resources/jbpm.wire.bindings.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -52,6 +52,8 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionFactoryBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.RepositorySessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailTemplateBinding" />
   
   <!-- db sessions -->
   <binding class="org.jbpm.pvm.internal.wire.binding.PvmDbSessionBinding" />

Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<process name="StateChoice" xmlns="http://jbpm.org/4/jpdl">
-
-  <start g="16,60,48,48">
-    <transition to="wait for response"/>
-  </start>
-
-  <state name="wait for response" g="96,58,109,52">
-    <transition name="accept" to="submit document" g="151,41:-48,0" />
-    <transition name="reject" to="try again" g="151,125:-47,-17" />
-  </state>
-
-  <state name="submit document" g="237,16,114,52" />
-  <state name="try again" g="237,100,114,52" />
-
+<process name="StateChoice" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,60,48,48">
+    <transition to="wait for response"/>
+  </start>
+
+  <state name="wait for response" g="96,58,109,52" >
+    <transition name="accept" to="submit document" g="148,34:3,-15" />
+    <transition name="reject" to="try again" g="151,133:3,2" />
+  </state>
+
+  <state name="submit document" g="238,8,114,52" />
+  <state name="try again" g="238,108,114,52" />
+
 </process>
\ No newline at end of file

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessDocument.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessDocument.jpdl.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessDocument.jpdl.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="SubProcessDocument" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="20,20,48,48">
+    <transition to="review" />
+  </start>
+
+  <sub-process name="review"
+               sub-process-key="SubProcessReview" 
+               g="96,16,127,52">
+               
+    <variable name="document" init="#{document}" />
+    <out-variable name="reviewResult" init="#{result}" />
+    
+    <transition to="wait" />
+  </sub-process>
+  
+  <state name="wait" g="255,16,88,52"/>
+
+</process>


Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessDocument.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessReview.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessReview.jpdl.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessReview.jpdl.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="SubProcessReview" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="20,20,48,48">
+    <transition to="get approval"/>
+  </start>
+
+  <task name="get approval"
+        assignee="johndoe" 
+        g="96,16,127,52">
+               
+    <transition to="end"/>
+  </task>
+  
+  <end name="end" g="254,19,88,52" />
+
+</process>
\ No newline at end of file


Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/subprocess/variables/SubProcessReview.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java	2009-04-20 13:09:19 UTC (rev 4582)
@@ -66,11 +66,8 @@
       processDefinition = repositorySession.findProcessDefinitionByKey(subProcessKey);
     }
     
-    JpdlExecution subProcessInstance = (JpdlExecution) processDefinition.createProcessInstance();
+    JpdlExecution subProcessInstance = (JpdlExecution) processDefinition.createProcessInstance(null, execution);
     
-    subProcessInstance.setSuperProcessExecution(jpdlExecution);
-    jpdlExecution.setSubProcessInstance(subProcessInstance);
-    
     for (String swimlaneName: swimlaneMappings.keySet()) {
       String subSwimlaneName = swimlaneMappings.get(swimlaneName);
       SwimlaneImpl subSwimlane = subProcessInstance.createSwimlane(subSwimlaneName);
@@ -87,14 +84,18 @@
     }
     
     subProcessInstance.start();
+    execution.waitForSignal();
   }
 
   public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
     JpdlExecution jpdlExecution = execution.getExtension(JpdlExecution.class);
 
     ExecutionImpl subProcessInstance = jpdlExecution.getSubProcessInstance();
+    jpdlExecution.setSubProcessInstance(null);
+
     variableOutDefinitionSet.processOutVariables(jpdlExecution, subProcessInstance);
     
+    
     String transitionName = null;
     
     if (outcomeExpression!=null) {
@@ -102,7 +103,9 @@
       Object value = scriptManager.evaluateExpression(outcomeExpression, subProcessInstance, null);
       transitionName = outcomeActivityMappings.get(value);
 
-    } else if (!outcomeActivityMappings.isEmpty()) {
+    } else if ( (outcomeActivityMappings!=null)
+                && (!outcomeActivityMappings.isEmpty())
+              ) {
       String subProcessActivityName = subProcessInstance.getActivityName();
       transitionName = outcomeActivityMappings.get(subProcessActivityName);
     }

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java	2009-04-20 13:09:19 UTC (rev 4582)
@@ -27,7 +27,6 @@
 
 import org.jbpm.jpdl.internal.xml.JpdlParser;
 import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
-import org.jbpm.pvm.internal.model.VariableOutDefinitionImpl;
 import org.jbpm.pvm.internal.model.VariableOutDefinitionSet;
 import org.jbpm.pvm.internal.util.XmlUtil;
 import org.jbpm.pvm.internal.wire.Descriptor;
@@ -50,10 +49,10 @@
   public Object parse(Element element, Parse parse, Parser parser) {
     SubProcessActivity subProcessActivity = new SubProcessActivity();
     
-    String subProcessKey = XmlUtil.attribute(element, "process-key");
+    String subProcessKey = XmlUtil.attribute(element, "sub-process-key");
     subProcessActivity.setSubProcessKey(subProcessKey);
     
-    String subProcessId = XmlUtil.attribute(element, "process-id");
+    String subProcessId = XmlUtil.attribute(element, "sub-process-id");
     subProcessActivity.setSubProcessId(subProcessId);
     
     List<VariableDefinitionImpl> variableDefinitions = JpdlParser.parseVariableDefinitions(element, parse, true);

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java	2009-04-20 13:09:19 UTC (rev 4582)
@@ -469,6 +469,8 @@
       if (sources>1) {
         parse.addProblem("init attribute and init element are mutually exclusive on element variable", inElement);
       }
+      
+      variableDefinitions.add(variableDefinition);
     }
 
     return variableDefinitions;

Modified: jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.execution.hbm.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.execution.hbm.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -94,6 +94,12 @@
                  foreign-key="FK_EXEC_SUPEREXEC"
                  index="IDX_EXEC_SUPEREXEC" />
                  
+    <many-to-one name="subProcessInstance"
+                 column="SUBPROCINST_"
+                 class="ExecutionImpl"
+                 foreign-key="FK_EXEC_SUBPI"
+                 index="IDX_EXEC_SUBPI" />
+                 
   </class>
 
   <!-- ### COMMENTS ####################################################### -->

Modified: jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.jpdl.activities.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.jpdl.activities.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.jpdl.activities.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -13,4 +13,5 @@
   <activity binding="org.jbpm.jpdl.internal.activity.ScriptBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.EsbBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.TaskBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.SubProcessBinding" />
 </activities>

Modified: jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.wire.bindings.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.wire.bindings.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -52,6 +52,8 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionFactoryBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.RepositorySessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailTemplateBinding" />
   
   <!-- db sessions -->
   <binding class="org.jbpm.pvm.internal.wire.binding.PvmDbSessionBinding" />

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java	2009-04-20 13:09:19 UTC (rev 4582)
@@ -23,6 +23,8 @@
 
 import java.io.Serializable;
 
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.script.ScriptManager;
 import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 
@@ -43,6 +45,7 @@
   protected String typeName;
 
   protected String initExpression;
+  protected String initLanguage;
   protected Descriptor initDescriptor;
 
   public Object getInitValue(ExecutionImpl execution) {
@@ -50,7 +53,8 @@
       return WireContext.create(initDescriptor);
     }
     if (initExpression!=null) {
-      throw new UnsupportedOperationException("TODO add variable in expression resolution");
+      ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
+      return scriptManager.evaluateExpression(initExpression, execution, initLanguage);
     }
     return null;
   }
@@ -79,4 +83,10 @@
   public void setTypeName(String typeName) {
     this.typeName = typeName;
   }
+  public String getInitLanguage() {
+    return initLanguage;
+  }
+  public void setInitLanguage(String initLanguage) {
+    this.initLanguage = initLanguage;
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java	2009-04-20 13:09:19 UTC (rev 4582)
@@ -47,17 +47,10 @@
           ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
           
           // TODO update evaluateExpression so that scopeInstance can be passed in directly
-          ExecutionImpl innerExecution = null;
-          if (innerScopeInstance instanceof ExecutionImpl) {
-            innerExecution = (ExecutionImpl) innerScopeInstance;
-          } else {
-            throw new UnsupportedOperationException("implement me");
-          }
-
           String expression = variableOutDefinition.getExpression();
           String language = variableOutDefinition.getLanguage();
 
-          Object value = scriptManager.evaluateExpression(expression, innerExecution, language);
+          Object value = scriptManager.evaluateExpression(expression, (ExecutionImpl)innerScopeInstance, language);
           outerExecution.setVariable(variableName, value);
         }
       }
@@ -65,9 +58,9 @@
   }
 
   public boolean hasVariableOutDefinitions() {
-    return ( (variableOutDefinitions==null)
-            || (variableOutDefinitions.isEmpty())
-          );
+    return ( (variableOutDefinitions!=null)
+             && (!variableOutDefinitions.isEmpty())
+           );
   }
   
   public List<VariableOutDefinitionImpl> getVariableOutDefinitions() {

Modified: jbpm4/trunk/modules/pvm/src/test/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/jbpm.execution.hbm.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/pvm/src/test/resources/jbpm.execution.hbm.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -94,6 +94,12 @@
                  foreign-key="FK_EXEC_SUPEREXEC"
                  index="IDX_EXEC_SUPEREXEC" />
                  
+    <many-to-one name="subProcessInstance"
+                 column="SUBPROCINST_"
+                 class="ExecutionImpl"
+                 foreign-key="FK_EXEC_SUBPI"
+                 index="IDX_EXEC_SUBPI" />
+                 
   </class>
 
   <!-- ### COMMENTS ####################################################### -->

Modified: jbpm4/trunk/modules/pvm/src/test/resources/jbpm.jpdl.activities.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/jbpm.jpdl.activities.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/pvm/src/test/resources/jbpm.jpdl.activities.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -13,4 +13,5 @@
   <activity binding="org.jbpm.jpdl.internal.activity.ScriptBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.EsbBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.TaskBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.SubProcessBinding" />
 </activities>

Modified: jbpm4/trunk/modules/pvm/src/test/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/jbpm.wire.bindings.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/pvm/src/test/resources/jbpm.wire.bindings.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -39,7 +39,6 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.BusinessCalendarBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.IdGeneratorBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.AuthenticationBinding" />
-  <binding class="org.jbpm.pvm.internal.wire.binding.MailTemplateBinding" />
   <!-- hibernate bindings -->
   <binding class="org.jbpm.pvm.internal.wire.binding.HibernateConfigurationBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.SeamHibernateSessionBinding" />
@@ -54,6 +53,7 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.RepositorySessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.MailSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailTemplateBinding" />
   
   <!-- db sessions -->
   <binding class="org.jbpm.pvm.internal.wire.binding.PvmDbSessionBinding" />

Modified: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.execution.hbm.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.execution.hbm.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -94,6 +94,12 @@
                  foreign-key="FK_EXEC_SUPEREXEC"
                  index="IDX_EXEC_SUPEREXEC" />
                  
+    <many-to-one name="subProcessInstance"
+                 column="SUBPROCINST_"
+                 class="ExecutionImpl"
+                 foreign-key="FK_EXEC_SUBPI"
+                 index="IDX_EXEC_SUBPI" />
+                 
   </class>
 
   <!-- ### COMMENTS ####################################################### -->

Modified: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.jpdl.activities.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.jpdl.activities.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.jpdl.activities.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -13,4 +13,5 @@
   <activity binding="org.jbpm.jpdl.internal.activity.ScriptBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.EsbBinding" />
   <activity binding="org.jbpm.jpdl.internal.activity.TaskBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.SubProcessBinding" />
 </activities>

Modified: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.wire.bindings.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.wire.bindings.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -52,6 +52,8 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionFactoryBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.RepositorySessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailTemplateBinding" />
   
   <!-- db sessions -->
   <binding class="org.jbpm.pvm.internal.wire.binding.PvmDbSessionBinding" />

Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.state.choice.png
===================================================================
(Binary files differ)

Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.subprocess.review.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.subprocess.review.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml	2009-04-20 12:49:13 UTC (rev 4581)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml	2009-04-20 13:09:19 UTC (rev 4582)
@@ -1125,6 +1125,249 @@
 taskService.setVariables(taskDbid, variables);</programlisting>
       </section>
     </section>
+
+    <!-- ### SUB-PROCESS ################################################## -->
+
+    <section id="subprocess">
+      <title><literal>sub-process</literal></title>
+
+      <para>Creates a sub process instance and waits till it is completed.  When 
+      the sub process instance completes, then the execution in the sub-process 
+      will continue.    
+      </para>
+
+      <table><title><literal>sub-process</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>sub-process-id</literal></entry>
+              <entry>string</entry>
+              <entry></entry>
+              <entry>either this or sub-process-key is required</entry>
+              <entry>Identifies the sub process by the id.  This means that a specific 
+              version of a process definition is referenced.</entry>
+            </row>
+            <row>
+              <entry><literal>sub-process-key</literal></entry>
+              <entry>string</entry>
+              <entry></entry>
+              <entry>either this or sub-process-key is required</entry>
+              <entry>Identifies the sub process by the key.  This means that the latest 
+              version of the process definition with the given key is referenced.  The latest version 
+              of the process is looked up each time the activity executes.
+              </entry>
+            </row>
+            <row>
+              <entry><literal>outcome</literal></entry>
+              <entry>expression</entry>
+              <entry></entry>
+              <entry>required when transitions have <literal>outcome-value</literal>'s specified</entry>
+              <entry>Expression that is evaluated when the sub process 
+              instance ends.  The value is then used for outcome transition mapping.  
+              Add <literal>outcome-value</literal> elements to the outgoing transitions 
+              of this <literal>sub-process</literal> activity.
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      
+      <table><title><literal>process</literal> elements:</title>
+	      <tgroup cols="3" rowsep="1" colsep="1">
+	        <thead>
+	          <row>
+	            <entry>Element</entry>
+	            <entry>Multiplicity</entry>
+	            <entry>Description</entry>
+	          </row>
+	        </thead>
+	        <tbody>
+	          <row>
+	            <entry><literal>variable</literal></entry>
+	            <entry>0..*</entry>
+	            <entry>Declares a variable that is passed to the sub process instance
+	            when it is created.
+	            </entry>
+	          </row>
+            <row>
+              <entry><literal>swimlane-mapping</literal></entry>
+              <entry>0..*</entry>
+              <entry>Declares a swimlane that will be propagated to the sub process 
+              instance when the sub process is created.
+              </entry>
+            </row>
+	          <row>
+	            <entry><literal>out-variable</literal></entry>
+	            <entry>0..*</entry>
+	            <entry>Declares a variable that will be set in the parent execution
+	            when the sub process ends.
+	            </entry>
+	          </row>
+	        </tbody>
+	      </tgroup>
+	    </table>
+
+      <table><title>Extra <literal>transition</literal> elements in case of outcome variable mappings:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>outcome-value</literal></entry>
+              <entry>0..1</entry>
+              <entry>If the <literal>outcome</literal> matches the value, this 
+              transition is taken after the sub-process ended.  The value is specified with one child 
+              element.
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      
+      <table><title>Extra <literal>transition</literal> elements in case of activity mappings:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>outcome</literal></entry>
+              <entry>0..1</entry>
+              <entry>Specifies 
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      
+      <table><title><literal>outcome</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>activity</literal></entry>
+              <entry>string</entry>
+              <entry></entry>
+              <entry><emphasis role="bold">required</emphasis></entry>
+              <entry>Refers to an <literal>end</literal> activity name of the 
+              sub-process.  This transition is taken when the sub process ends in
+              that specific <literal>end</literal> activity.</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      
+      <!-- ~~~ SUB PROCESS VARIABLES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
+      <section id="subprocessvariables">
+        <title><literal>sub-process</literal> variables</title>
+        <para>The SubProcessVariables example scenario will show the basic workings of the 
+        sub-process activity, how to feed information in the sub process when it starts 
+        and how to extract information out of the subprocess when it ends.
+        </para>
+        <para>The parent process involves a document that needs to be reviewed.</para>
+        <figure id="process.subprocess.document">
+          <title>The subprocess document example process</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.subprocess.document.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;SubProcessDocument&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;review&quot; /&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;sub-process name=&quot;review&quot;
+               sub-process-key=&quot;SubProcessReview&quot;&gt;
+               
+    &lt;variable name=&quot;document&quot; init=&quot;#{document}&quot; /&gt;
+    &lt;out-variable name=&quot;reviewResult&quot; init=&quot;#{result}&quot; /&gt;
+    
+    &lt;transition to=&quot;wait&quot; /&gt;
+  &lt;/sub-process&gt;</emphasis>
+  
+  &lt;state name=&quot;wait&quot;/&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>The review process is a reusable process for all kinds of reviews.</para>
+        <figure id="process.subprocess.review">
+          <title>The subprocess review example process</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.subprocess.review.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;SubProcessReview&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;get approval&quot;/&gt;
+  &lt;/start&gt;
+
+  &lt;task name=&quot;get approval&quot;
+        assignee=&quot;johndoe&quot;&gt;
+               
+    &lt;transition to=&quot;end&quot;/&gt;
+  &lt;/task&gt;
+  
+  &lt;end name=&quot;end&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>The document process is started with a document variable:</para>
+        <programlisting>Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();
+variables.put(&quot;document&quot;, &quot;This document describes how we can make more money...&quot;);
+    
+ProcessInstance processInstance = executionService
+    .startProcessInstanceByKey(&quot;SubProcessDocument&quot;, variables);</programlisting>
+        <para>Then the parent process execution will arrive in the sub process 
+        activity.  A sub process instance is created and linked with the super
+        process execution.  When the <literal>SubProcessReview</literal> process 
+        instance starts, it arrives in the <literal>task</literal>.  A task will be 
+        created for <literal>johndoe</literal>. 
+        </para>
+        <programlisting>List&lt;Task&gt; taskList = taskService.findAssignedTasks(&quot;johndoe&quot;);
+Task task = taskList.get(0);</programlisting>
+        <para>We can see that the document has been passed from the super process 
+        instance to the sub process instance: 
+        </para>
+        <programlisting>String document = (String) taskService.getVariable(task.getDbid(), &quot;document&quot;);
+assertEquals(&quot;This document describes how we can make more money...&quot;, document);</programlisting>
+        <para>Then we set a variable on the task.  This is typically done through a form.  But 
+        here we'll show how it is done programmatically.
+        </para>
+        <programlisting>taskService.setVariable(task.getDbid(), &quot;result&quot;, &quot;accept&quot;);</programlisting>
+        <para>Completing this task, will cause the sub process instance to end.
+        </para>
+        <programlisting>taskService.completeTask(task.getDbid());</programlisting>
+        <para>When the sub process ends, the super process execution will get signalled(=notified).
+        First the <literal>result</literal> variable from the sub process instance 
+        will be copied into the <literal>reviewResult</literal> variable in the 
+        super process execution.  Then the super process execution will continue 
+        and leave the <link>review</link> activity.
+        </para>
+      </section>
+    </section>
   </section>
   
   <!-- ##################################################################### -->




More information about the jbpm-commits mailing list