[jbpm-commits] JBoss JBPM SVN: r6031 - in jbpm4/trunk/modules: bpmn/src/main/java/org/jbpm/bpmn/parser and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Dec 23 08:06:31 EST 2009


Author: jbarrez
Date: 2009-12-23 08:06:30 -0500 (Wed, 23 Dec 2009)
New Revision: 6031

Added:
   jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.user.task.png
Modified:
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
   jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
Log:
Documented and slightly enhanced BPMN 2.0 user task

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java	2009-12-23 11:42:13 UTC (rev 6030)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java	2009-12-23 13:06:30 UTC (rev 6031)
@@ -58,7 +58,7 @@
     ActivityResource activityResource = new ActivityResource();
     activityResource.setResourceRef(bpmnProcessDefinition.getResource(resourceRef));
 
-    String scope = XmlUtil.attribute(performer, "type", false, parse);
+    String scope = XmlUtil.attribute(performer, "jbpm:type", false, parse); // Todo refactor for namespaces
 
     Element rae = XmlUtil.element(performer, "resourceAssignmentExpression", false, parse);
     if (rae != null) {
@@ -67,12 +67,12 @@
       if (PERFORMER.equals(type) || HUMAN_PERFORMER.equals(type)) {
         taskDefinition.setAssigneeExpression(formalExpression);
         taskDefinition.setAssigneeExpressionLanguage(lang);
-      } else if (POTENTIAL_OWNER.equals(type) && "group".equals(scope)) {
+      } else if (POTENTIAL_OWNER.equals(type) && "user".equals(scope)) { // default is group
+        taskDefinition.setCandidateUsersExpression(formalExpression);
+        taskDefinition.setCandidateUsersExpressionLanguage(lang);
+      } else { 
         taskDefinition.setCandidateGroupsExpression(formalExpression);
         taskDefinition.setCandidateGroupsExpressionLanguage(lang);
-      } else {
-        taskDefinition.setCandidateUsersExpression(formalExpression);
-        taskDefinition.setCandidateUsersExpressionLanguage(lang);
       }
     }
 

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java	2009-12-23 11:42:13 UTC (rev 6030)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java	2009-12-23 13:06:30 UTC (rev 6031)
@@ -41,7 +41,7 @@
  */
 public abstract class BpmnActivity implements ActivityBehaviour {
 
-  private static final Log log = Log.getLog(BindingsParser.class.getName());
+  private static final Log log = Log.getLog(BpmnActivity.class.getName());
 
   private static final long serialVersionUID = 1L;
 

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java	2009-12-23 11:42:13 UTC (rev 6030)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java	2009-12-23 13:06:30 UTC (rev 6031)
@@ -44,7 +44,7 @@
 
   private static final long serialVersionUID = 1L;
 
-  private static final Log log = Log.getLog(UserTaskActivity.class.getName());
+  private static final Log LOG = Log.getLog(UserTaskActivity.class.getName());
 
   protected TaskDefinitionImpl taskDefinition;
 
@@ -81,19 +81,6 @@
     // save task so that TaskDbSession.findTaskByExecution works for assign
     // event listeners
     dbSession.save(task);
-
-//    SwimlaneDefinitionImpl swimlaneDefinition = taskDefinition.getSwimlaneDefinition();
-//    if (swimlaneDefinition != null) {
-//      SwimlaneImpl swimlane = execution.getInitializedSwimlane(swimlaneDefinition);
-//      task.setSwimlane(swimlane);
-//
-//      // copy the swimlane assignments to the task
-//      task.setAssignee(swimlane.getAssignee());
-//      for (ParticipationImpl participant : swimlane.getParticipations()) {
-//        task.addParticipation(participant.getUserId(), participant.getGroupId(), participant.getType());
-//      }
-//    }
-
     execution.initializeAssignments(taskDefinition, task);
 
     HistoryEvent.fire(new TaskActivityStart(task), execution);

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java	2009-12-23 11:42:13 UTC (rev 6030)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java	2009-12-23 13:06:30 UTC (rev 6031)
@@ -47,10 +47,7 @@
 
     ScopeElementImpl scopeElement = parse.contextStackFind(ScopeElementImpl.class);
     TaskDefinitionImpl taskDefinition = BpmnParser.parseTaskDefinition(element, parse, scopeElement);
-
-    BpmnProcessDefinition bpmnProcessDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
     
-    //bpmnProcessDefinition.getResource(ref)
     addActivityResources(taskDefinition, taskActivity, element, parse);
 
     Element rendering = XmlUtil.element(element, "rendering", false, parse);

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java	2009-12-23 11:42:13 UTC (rev 6030)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java	2009-12-23 13:06:30 UTC (rev 6031)
@@ -338,9 +338,6 @@
     String taskName = XmlUtil.attribute(element, "name");
     taskDefinition.setName(taskName);
 
-    // String form = XmlUtil.attribute(element, "form");
-    // taskDefinition.setForm(form);
-
     BpmnProcessDefinition processDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
     if (processDefinition.getTaskDefinition(taskName) != null) {
       parse.addProblem("duplicate task name " + taskName, element);
@@ -348,18 +345,10 @@
       processDefinition.addTaskDefinitionImpl(taskDefinition);
     }
 
-    Element potentialOwner = XmlUtil.element(element, "potentialOwner");
-    if (potentialOwner != null) {
-      String potentialOwnerRef = XmlUtil.attribute(potentialOwner, "resourceRef");
-      // set to fixed expression, more evaluation needed for real BPMN 2.0
-      //taskDefinition.setAssigneeExpression(potentialOwnerRef);
-      taskDefinition.setCandidateGroupsExpression(potentialOwnerRef);
-    }
     return taskDefinition;
   }
 
-  // private void parseDataObjects(Element element, Parse parse,
-  // BpmnProcessDefinition processDefinition) {
+
   private void parseResources(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
 
     for (Element resourceElement : XmlUtil.elements(documentElement, "resource")) {

Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.user.task.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.user.task.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml	2009-12-23 11:42:13 UTC (rev 6030)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml	2009-12-23 13:06:30 UTC (rev 6031)
@@ -706,6 +706,168 @@
     
     </section>
     
+    <section id="userTask">
+    
+      <title>Task: User Task</title>
+    
+      <para>
+        A <emphasis role="bold">User task</emphasis> is the typical 'human task' that is found
+        in practically every workflow or BPM software out there. When process execution reaches
+        such a user task, a new human task is created in task list for a given user.
+     </para>
+     
+      <para>   
+        The main difference with a <link linkend="manualTask">manual task</link> (which also signifies
+        work for a human actor) is that the task is known to the process engine. The engine can 
+        track the completion, assignee, time, etc which is not the case for a manual task.  
+      </para>
+      
+      <para>
+        A user task is depicted as a rounded rectangle with a small user icon in the top left corner.
+        <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.user.task.png"/></imageobject></mediaobject>
+        A user task is defined as follows in the BPMN 2.0 XML:
+        <programlisting>
+&lt;userTask id=&quot;myTask&quot; name=&quot;My task&quot; />      
+        </programlisting> 
+        According to the specification, multiple implementations are possible (Webservice, WS-humantask, etc.),
+        as stated by using the <emphasis role="bold">implementation</emphasis> attribute.
+        Currently, only the standard jBPM task mechanism is available, so there is no point (yet)
+        in defining the 'implementation' attribute.
+      </para>
+      
+      <para>
+        The BPMN 2.0 specification contains quite a few ways of assigning user tasks to user(s), 
+        group(s), role(s), etc. The current BPMN 2.0 jBPM implementation allows to assign tasks using
+        a <emphasis role="bold">resourceAssignmentExpression</emphasis>, combined
+        with the <emphasis role="bold">humanPerformer or PotentialOwner</emphasis> construct.
+        It is to be expected that this area will evolve future releases.
+      </para>
+      
+      <para>
+        A <emphasis role="bold">potentialOwner</emphasis> is used when you want to make a certain
+        user, group, role, etc. a <emphasis role="bold">candidate</emphasis> for a certain task.
+        Take the following example. Here the candidate group for the task 'My task' will be
+        the 'management' group. Also note that a resource must be defined <emphasis role="bold">
+        outside the process</emphasis>, such that the task assignment can reference the resource.
+        In fact, any activity can reference one or more resource elements.
+        Currently, only defining this resource is enough (since it is a required attribute by the spec),
+        but this will be enhanced in a later release (eg. resources can have runtime parameters).
+        <programlisting>
+&lt;resource id=&quot;manager&quot; name=&quot;manager&quot; /> 
+
+&lt;process ...&gt;
+
+...        
+        
+&lt;userTask id=&quot;myTask&quot; name=&quot;My task&quot;&gt;
+  &lt;potentialOwner resourceRef=&quot;manager&quot; jbpm:type=&quot;group&quot;&gt;
+    &lt;resourceAssignmentExpression&gt;
+      &lt;formalExpression&gt;management&lt;/formalExpression&gt;
+    &lt;/resourceAssignmentExpression&gt;
+  &lt;/potentialOwner&gt;
+&lt;/userTask&gt;        
+        </programlisting>
+        Note that we are using a specific extension here 
+        (<emphasis role="bold">jbpm:type=&quot;group&quot;</emphasis>), to define this is a group assignment.
+        If this attribute is removed, the group semantics will be used as default (which would be 
+        ok in this example).
+        Now suppose that Peter and Mary are a member of the management group (here using the default
+        identity service):
+        <programlisting>
+identityService.createGroup("management");
+    
+identityService.createUser("peter", "Peter", "Pan");
+<emphasis role="bold">identityService.createMembership("peter", "management");</emphasis>
+    
+identityService.createUser("mary", "Mary", "Littlelamb");
+<emphasis role="bold">identityService.createMembership("mary", "management");  </emphasis>      
+        </programlisting>
+        Then both peter and mary can look in their task list for this task (code snippet from the 
+        example unit test):
+        <programlisting>
+// Peter and Mary are both part of management, so they both should see the task
+List&lt;Task&gt; tasks = taskService.findGroupTasks(&quot;peter&quot;);
+assertEquals(1, tasks.size());
+<emphasis role="bold"> tasks = taskService.findGroupTasks(&quot;mary&quot;);</emphasis>
+assertEquals(1, tasks.size());
+    
+// Mary claims the task
+Task task = tasks.get(0);
+taskService.takeTask(task.getId(), &quot;mary&quot;);
+assertNull(taskService.createTaskQuery().candidate(&quot;peter&quot;).uniqueResult());
+    
+taskService.completeTask(task.getId());
+assertProcessInstanceEnded(processInstance);        
+        </programlisting>
+        When the assignment should be done to a <emphasis role="bold">candidate user</emphasis>,
+        just use the <emphasis role="bold">jbpm:type="user"</emphasis> attribute.
+        <programlisting>
+&lt;userTask id=&quot;myTask&quot; name=&quot;My User task&quot;&gt;
+  &lt;potentialOwner resourceRef=&quot;employee&quot; <emphasis role="bold">jbpm:type=&quot;user&quot;</emphasis>&gt;
+    &lt;resourceAssignmentExpression&gt;
+      &lt;formalExpression&gt;peter&lt;/formalExpression&gt;
+    &lt;/resourceAssignmentExpression&gt;
+  &lt;/potentialOwner&gt;
+&lt;/userTask&gt;        
+        </programlisting>
+        In this example, peter will be able to find the task since he's a candidate user for the task.
+        <programlisting>
+List&lt;Task&gt; tasks = taskService.createTaskQuery().candidate(&quot;peter&quot;).list();        
+        </programlisting>
+      </para>
+    </section>
+    
+    <para>
+      A <emphasis role="bold">human performer</emphasis> is used when you want to assign a task
+      directly to a certain user, group, role, etc. The way to do this looks very much
+      like that of the potential owner.
+      <programlisting>
+&lt;resource id="employee" name="employee" /&gt;      
+
+&lt;process ...&gt;
+
+...        
+         
+&lt;userTask id="myTask" name="My User task"&gt;
+  <emphasis role="bold">&lt;humanPerformer resourceRef="employee"&gt;</emphasis>
+    &lt;resourceAssignmentExpression&gt;
+      &lt;formalExpression&gt;mary&lt;/formalExpression&gt;
+    &lt;/resourceAssignmentExpression&gt;
+  &lt;/humanPerformer&gt;
+&lt;/userTask&gt;      
+      </programlisting>
+      In this example, the task will be directly assigned to Mary. She can now find the task
+      in her task list:
+      <programlisting>
+List&lt;Task&gt; tasks = taskService.findPersonalTasks(&quot;mary&quot;);       
+      </programlisting>
+      
+      
+    </para>
+    
+    <para>
+      Since the task assignment is done through the use of a 
+      <emphasis role="bold">formalExpression</emphasis>, it's also possible to define expressions
+      that are evaluated at runtime. The expressions itself need to be put inside a 
+      <emphasis role="bold">${}</emphasis>, as usual in jBPM.
+      For example, if a process variable 'user' is defined, then  it can be used inside an expression.
+      More complex expressions are of course possible.
+      <programlisting>
+&lt;userTask id="myTask" name="My User task"&gt;
+  &lt;humanPerformer resourceRef="employee"&gt;
+    &lt;resourceAssignmentExpression&gt;
+      <emphasis role="bold">&lt;formalExpression&gt;${user}&lt;/formalExpression&gt;</emphasis>
+    &lt;/resourceAssignmentExpression&gt;
+  &lt;/humanPerformer&gt;
+&lt;/userTask&gt;         
+      </programlisting>
+      Note that it is not needed to use the 'jbpm:type' on a humanPerformer element, since only
+      direct user assignments can be done. If a task needs to be assigned to a role or group, 
+      use the potentialOwner with a group type (when you assign a task to a group, all members
+      of that group will always be candidate users for that group - hence the usage of 
+      potentialOwner).
+    </para>
+    
     <section id="serviceTask">
     
       <title>Task: Java Service Task</title>



More information about the jbpm-commits mailing list