Activiti Workflows with decision points

cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti Workflows with decision points

resplin
Intermediate
0 0 7,684

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



Workflow

Back to Workflow_with_Activiti.

A simple BPM workflow can viewed as a sequence of tasks. Slightly more complex is a workflow that has one or more decision points. A decision point is where a choice has to be made, and the flow can go more than one way, depending on that choice.
For example the Alfresco-supplied review workflow is a workflow designed to assign a task to a user, who must complete the task by approving or rejecting the work item.  You can see the BPMN 2.0 process definition in the file review.bpmn20.xml, and the jPDL process definition in the file review_processdefinition.xml. Both these files are in the alfresco/workflow directory.

In jBPM, the jPDL process definition uses transition elements within the task-node element to describe which task is to be executed next in the sequence. So a task is able to determine what the next task in the sequence is from its own content.

BPMN 2.0 is a more expressive language. A BPMN 2.0 process defintion is a graph consisting  of flow objects linked  together by connecting objects. There are three core flow objects:


  • An event - represents something that happens.
  • An activity - represents some work that is done. A task is an activity that represents a single unit of work, that can not be broken down further into business processes.
  • A gateway - represents forking or merging of paths depending on a condition or conditions.

A sequenceFlow is a connecting object that  describes the source and target a step in the flow. The source and target are flow objects.

The following diagram shows the review process definition as an Activiti flow diagram :-

none|review process definition as an Activiti flow diagram



Examining the XML for the BPMN 2.0 process definition, review.bpmn20.xml, we can see how the decision point on accepting or rejecting at review is described:-



       <userTask id='reviewTask' name='Review Task'
            activiti:formKey='wf:activitiReviewTask'>
  ...
        </userTask>

        <sequenceFlow id='flow2'
        sourceRef='reviewTask'
            targetRef='reviewDecision' />

        <exclusiveGateway  id='reviewDecision' name='Review Decision' />

        <sequenceFlow id='flow3' sourceRef='reviewDecision' targetRef='approved' >
            <conditionExpression xsi:type='tFormalExpression'>
                              ${wf_reviewOutcome == 'Approve'}</conditionExpression>
        </sequenceFlow>

        <sequenceFlow id='flow4'
        sourceRef='reviewDecision'
            targetRef='rejected' />

       <userTask id='approved' name='Document Approved'
            activiti:formKey='wf:approvedTask' >
            <documentation>
                The document was reviewed and approved.
            </documentation>
...
        </userTask>
       
        <userTask id='rejected' name='Document Rejected'
            activiti:formKey='wf:rejectedTask' >
            <documentation>
                The document was reviewed and rejected.
            </documentation>
...
        </userTask>

        <sequenceFlow id='flow5' sourceRef='approved'
            targetRef='end' />

       

You can see that the exclusiveGateway reviewDecision is the decision point. The following two sequenceFlow connecting  objects describe the 2 possible forks in the flow. Note that the first connecting object flow3 has a condition based on the wf_reviewOutcome property which must be met for the flow to proceed to its  target. If the condition is not met, then processing drops through to the next sequenceFlow, flow4 which in this case has no condition that needs to be met, because it describes the only other possible path in the flow.

Because the flow is described outside the task elements, Alfresco does not know during task processing what the preceding or next task will be, and so cannot present the outcome in the task history in Alfresco Share. To provide this capability, the task model in workflowModel.xml has a new type, wf:activitiReviewTask:



       <type name='wf:activitiReviewTask'>
            <parent>bpm:activitiOutcomeTask</parent>
            <properties>
                <property name='wf:reviewOutcome'>
                    <type>d:text</type>
                    <default>Reject</default>
                    <constraints>
                        <constraint type='LIST'>
                            <parameter name='allowedValues'>
                                <list>
                                    <value>Approve</value>
                                    <value>Reject</value>
                                </list>
                            </parameter>
                        </constraint>
                    </constraints>
                </property>
            </properties>
            <overrides>
                <property name='bpm:packageItemActionGroup'>
                    <default>edit_package_item_actions</default>
                </property>
                <property name='bpm:outcomePropertyName'>
                    <default>{http://www.alfresco.org/model/workflow/1.0}reviewOutcome</default>
                </property>
            </overrides>
        </type>

The list constraint provides the list of allowed values for the review decision, and the bpmSmiley SurprisedutcomePropertyName provides the location that alfresco retrieves the outcome string from to display in the task's history panel in My Tasks. Without bpmSmiley SurprisedutcomePropertyName Alfresco would use the default outcome string, 'Next'.

The parent of 'wf:activitiReviewTask', bpmSmiley SurprisedutcomePropertyName is defined in the workflow base task model 'bpm:businessprocessmodel'. You can find this model in bpmModel.xml located in  the config file alfresco/model/bpmModel.xml.





       
        <type name='bpm:activitiOutcomeTask'>
            <parent>bpm:workflowTask</parent>
            <properties>
                <property name='bpm:outcomePropertyName'>
                    <type>d:qname</type> 
                </property>
            </properties>
        </type>