[jbpm-commits] JBoss JBPM SVN: r4404 - jbpm4/trunk/modules/userguide/src/main/docbook/en/modules.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Apr 3 08:01:11 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-04-03 08:01:11 -0400 (Fri, 03 Apr 2009)
New Revision: 4404

Modified:
   jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
Log:
documenting the task examples

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-03 10:45:02 UTC (rev 4403)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml	2009-04-03 12:01:11 UTC (rev 4404)
@@ -824,6 +824,8 @@
 
       <para>Creates a task for a person in the task component.  
       </para>
+      
+      <!-- ~~~ TASK ASSIGNEE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
 
       <section id="taskassignee">
         <title><literal>task</literal> assignee</title>
@@ -915,6 +917,8 @@
         </para>
 	    </section>
 
+      <!-- ~~~ TASK CANDIDATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
       <section id="taskcandidates">
         <title><literal>task</literal> candidates</title>
         <para>A task that will be offered to a group of users.  One of the users should then 
@@ -1010,6 +1014,8 @@
         </para>
       </section>
 
+      <!-- ~~~ TASK ASSIGNMENT HANDLER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
       <section id="taskassignmenthandler">
         <title><literal>task</literal> assignment handler</title>
         <para>An <literal>AssignmentHandler</literal> can be used to calculate the 
@@ -1024,30 +1030,15 @@
         Swimlanes.  So AssignmentHandlers can be used for tasks as well as swimlanes 
         (see later).
         </para>
-        <para><literal>task-handler</literal> is a sub element of the task element.</para>      
-        <table><title><literal>task-handler</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>class</literal></entry>
-                <entry>swimlane (string)</entry>
-                <entry></entry>
-                <entry>optional</entry>
-                <entry>refers to a swimlane that is declared in the process</entry>
-              </row>
-            </tbody>
-          </tgroup>
-        </table>
+        <para><literal>assignment-handler</literal> is a sub element of the task element.
+        It specifies a user code object.  So the attributes and elements of <literal>assignment-handler</literal>
+        are documented in <xref linkend="usercode" />
+        </para>
         <para>Let's look at the task assignment example process.</para>
+        <figure id="process.task.assignmenthandler">
+          <title>The task assignment handler example process</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.task.png"/></imageobject></mediaobject>
+        </figure>
         <programlisting>&lt;process name=&quot;TaskAssignmentHandler&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
 
   &lt;start g=&quot;20,20,48,48&quot;&gt;
@@ -1066,9 +1057,29 @@
   &lt;state name=&quot;wait&quot; g=&quot;255,16,88,52&quot; /&gt;
   
 &lt;/process&gt;</programlisting>
-        <para></para>
+        <para>The referenced class <literal>AssignTask</literal> looks like this: </para>
+        <programlisting>public class AssignTask implements AssignmentHandler {
+
+  String assignee;
+
+  public void assign(Assignable assignable, OpenExecution execution) {
+    assignable.setAssignee(assignee);
+  }
+}</programlisting>
+        <para>Please note that potentially, AssignmentHandler implementations can use 
+        the process variables and any other Java API to access resources like your 
+        application database to calculate the assignee and candidate users and groups. 
+        </para>
+        <para>Starting a new process instance of the <literal>TaskAssignmentHandler</literal> 
+        process will immediately bring the new execution to the task activity.  A new 
+        <literal>review</literal> task is created and at that point, the <literal>AssignTask</literal> 
+        assignment handler is called.  That will set <literal>johndoe</literal> as 
+        the assignee.  So John Doe will find the task in his personal task list.
+        </para>
       </section>
 
+      <!-- ~~~ TASK SWIMLANES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
       <section id="taskswimlanes">
         <title><literal>task</literal> swimlanes</title>
         <para>Multiple tasks in a process should be assigned to the same 
@@ -1211,6 +1222,33 @@
         would release the task and offer it back to the other candidates.
         </para>
       </section>
+
+      <!-- ~~~ TASK VARIABLES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
+      <section id="taskvariables">
+        <title><literal>task</literal> variables</title>
+        <para>Tasks can see and update process variables.  Later tasks will have 
+        the option to declare task-local process variables.  Task variables 
+        are an important part of the task forms.  Task forms typically show 
+        data that comes from the task and the process instance.  Then 
+        input from the user is translated in setting task variables. 
+        </para>
+        <para>Getting task variables can be done like this:</para>
+        <programlisting>List&lt;Task&gt; taskList = taskService.findAssignedTasks(&quot;johndoe&quot;);
+
+Task task = taskList.get(0);
+long taskDbid = task.getDbid();
+
+Set&lt;String&gt; variableNames = taskService.getVariableNames(taskDbid);
+
+Map&lt;String, Object&gt; variables = taskService.getVariables(taskDbid, variableNames);</programlisting>
+        <para>And setting task variables can be done like this:</para>
+        <programlisting>variables = new HashMap&lt;String, Object&gt;();
+variables.put(&quot;category&quot;, &quot;small&quot;);
+variables.put(&quot;lires&quot;, 923874893);
+
+taskService.setVariables(taskDbid, variables);</programlisting>
+      </section>
     </section>
 
     <!-- ### SCRIPT ######################################################## -->




More information about the jbpm-commits mailing list