Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 4. BPMN2 tasks in process designer
A task is an automatic activity that is defined in the process model and the smallest unit of work in a process flow. The following task types defined in the BPMN2 specification are available in the Red Hat Process Automation Manager process designer palette:
- Business rule task
- Script task
- User task
- Service task
- None task
Business rule task |
|
Script task |
|
User task |
|
Service task |
|
None task |
|
In addition, the BPMN2 specification provides the ability to create custom tasks. The following predefined custom tasks are included with Red Hat Process Automation Manager:
- Rest service tasks: Used to invoke a remote RESTful service
- Email service tasks: Used to send an email
- Log service tasks: Used to log a message
- Java service tasks: Used to call Java code
- WebService service tasks: Used to invoke a remote WebService call
- DecisionTask tasks: Used to execute a DMN diagram
Business rule task
A business rule task defines a way to make a decision either through a DMN model or a rule flow group.
When a process reaches a business rule task defined by a DMN model, the process engine executes the DMN model decision with the inputs provided.
When a process reaches a business rule task defined by a rule flow group, the process engine begins executing the rules in the defined rule flow group. When there are no more active rules in the rule flow group, the execution continues to the next element. During the rule flow group execution, new activations belonging to the active rule flow group can be added to the agenda because these activations are changed by other rules.
Script task
A script task represents a script to be executed during the process execution.
The associated script can access process variables and global variables. Review the following list before using a script task:
- Avoid low-level implementation details in the process. A script task can be used to manipulate variables, but consider using a service task when modelling more complex operations.
- Ensure that the script is executed immediately, otherwise use an asynchronous service task.
- Avoid contacting external services through a script task. Use a service task to model communication with an external service.
- Ensure scripts do not throw exceptions. Runtime exceptions should be caught and managed, for example, inside the script or transformed into signals or errors that can then be handled inside the process.
When a script task is reached during execution, the script is executed and the outgoing flow is taken.
User task
User tasks are tasks in the process workflow that cannot be performed automatically by the system and therefore require the intervention of a human user, the actor.
On execution, the User task element is instantiated as a task that appears in the list of tasks of one or more actors. If a User task element defines the Groups
attribute, it is displayed in task lists of all users that are members of the group. Any user who is a member of the group can claim the task.
After it is claimed, the task disappears from the task list of the other users.
User tasks are implemented as domain-specific tasks and serve as a base for custom tasks.
Service task
Service tasks are tasks that do not require human interaction. They are completed automatically by an external software service.
None task
None tasks are completed on activation. This is a conceptual model only. A none task is never actually executed by an IT system.
4.1. Creating a business process in Business Central Copier lienLien copié sur presse-papiers!
The process designer is the Red Hat Process Automation Manager process modeler. The output of the modeler is a BPMN 2.0 process definition file. The definition is used as input for the Red Hat Process Automation Manager process engine, which creates a process instance based on the definition.
The procedures in this section provide a general overview of how to create a simple business process. For a more detailed business process example, see Getting started with business processes.
Prerequisites
- You have created or imported a Red Hat Process Automation Manager project. For more information about creating projects, see Managing projects in Business Central.
- You have created the required users. User privileges and settings are controlled by the roles assigned to a user and the groups that a user belongs to. For more information about creating users, see Installing and configuring Red Hat Process Automation Manager on Red Hat JBoss EAP 7.2.
Procedure
-
In Business Central, go to Menu
Design Projects. - Click the project name to open the project’s asset list.
-
Click Add Asset
Business Process. In the Create new Business Process wizard, enter the following values:
- Business Process: New business process name
-
Package: Package location for your new business process, for example
com.myspace.myProject
- Click Ok to open the process designer.
In the upper-right corner, click the Diagram properties
icon and add your business process property information, such as process data and variables:
- Scroll down and expand Process Data.
-
Click
next to Process Variables and define the process variables that you want to use in your business process.
- In the process designer canvas, use the left toolbar to drag and drop BPMN components to define your business process logic, connections, events, tasks, or other elements.
- After you add and define all components of the business process, click Save to save the completed business process.
4.2. Creating business rules tasks Copier lienLien copié sur presse-papiers!
Business rules tasks are used to make decisions through a Decision Model and Notation (DMN) model or rule flow group.
Procedure
- Create a business process.
- In the process designer, select the Activities tool from the tool palette.
- Select Business Rule.
- Click a blank area of the process designer canvas.
- If necessary, in the upper-right corner of the screen, click the Properties icon.
Add or define the task information listed in the following table as required.
Expand Table 4.2. Business rule task parameters Label Description Name
The name of the business rule task.
Rule Language
The output language for the task. Select Decision Model and Notation (DMN) or Drools (DRL).
Rule Flow Group
The rule flow group associated with this business task. Select a rule flow group from the list or specify a new rule flow group.
On Entry Action
A Java, JavaScript, or MVEL script that specifies an action at the start of the task.
On Exit Action
A Java, JavaScript, or MVEL script that specifies an action at the end of the task.
Is Async
Select if this task should be invoked asynchronously. Make tasks asynchronous if they cannot be executed instantaneously, for example a task performed by an outside service.
Adhoc Autostart
Select if this is an ad hoc task that should be started automatically. Adhoc Autostart enables the task to automatically start when the process or case instance is created instead of being starting by a start task. It is often used in case management.
SLA Due Date
The date that the service level agreement (SLA) expires.
Assignments
Click to add local variables.
- Click Save.
4.3. Creating script tasks Copier lienLien copié sur presse-papiers!
Script tasks are used to execute a piece of code written in Java, JavaScript, or MVEL. They contain code snippets that specify the action of the script task. You can include global and process variables in your scripts.
You can write action scripts in Java, JavaScript, and MVEL. Note that MVEL accepts any valid Java code and additionally provides support for nested access of parameters. For example, the MVEL equivalent of the Java call person.getName()
is person.name
. MVEL also provides other improvements over Java and MVEL expressions are generally more convenient for business users.
Procedure
- Create a business process.
- In the process designer, select the Activities tool from the tool palette.
- Select Script.
- Click a blank area of the process designer canvas.
- If necessary, in the upper-right corner of the screen, click the Properties icon.
Add or define the task information listed in the following table as required.
Expand Table 4.3. Script task parameters Label Description Name
The name of the business rule task.
Documentation
Enter a description of the task. The text in this field is included in the process documentation. Click the Documentation tab in the upper-left side of the process designer canvas to view the process documentation.
Script
Enter a script in Java, JavaScript, or MVEL to be excuted by the task, and select the script type.
Is Async
Select if this task should be invoked asynchronously. Make tasks asynchronous if they cannot be executed instantaneously, for example a task performed by an outside service.
Adhoc Autostart
Select if this is an ad hoc task that should be started automatically. Adhoc Autostart enables the task to automatically start when the process or case instance is created instead of being starting by a start task. It is often used in case management.
- Click Save.
4.4. Creating user tasks Copier lienLien copié sur presse-papiers!
User tasks are used to include human actions as input to the business process.
Procedure
- Create a business process.
- In the process designer, select the Activities tool from the tool palette.
- Select User.
- . Either drag and drop a business rule onto the process designer canvas or click a blank area of the canvas.
- If necessary, in the upper-right corner of the screen, click the Properties icon.
Add or define the task information listed in the following table as required.
Expand Table 4.4. User task parameters Label Description Name
The display name of the business rule task.
Documentation
Enter a description of the task. The text in this field is included in the process documentation. Click the Documentation tab in the upper-left side of the process designer canvas to view the process documentation.
Task Name
The name of the human task.
Subject
Enter a subject for the task.
Actors
The actors responsible for executing the human task. Click Add to add a row then select an actor from the list or click New to add a new actor.
Groups
The groups responsible for executing the human task. Click Add to add a row then select a group from the list or click New to add a new group.
Assignments
Local variables for this task. Click to open the Task Data I/O window then add data inputs and outputs as required.
Reassignments
Specify a different actor to complete this task.
Notifications
Click to specify notifications associated with the task.
Is Async
Select if this task should be invoked asynchronously. Make tasks asynchronous if they cannot be executed instantaneously, for example a task performed by an outside service.
Skippable
Select if this task is not mandatory.
Priority
Specify a priority for the task.
Description
Enter a description for the human task.
Created By
The user that created this task.
Adhoc Autostart
Select if this is an ad hoc task that should be started automatically. Adhoc Autostart enables the task to automatically start when the process or case instance is created instead of being starting by a start task. It is often used in case management.
Multiple Instance
Select if this task has multiple instances.
On Entry Action
A Java, JavaScript, or MVEL script that specifies an action at the start of the task.
On Exit Action
A Java, JavaScript, or MVEL script that specifies an action at the end of the task.
Content
The content of the script.
SLA Due Date
The date the the service level agreement (SLA) expires.
- Click Save.
4.5. Creating service tasks Copier lienLien copié sur presse-papiers!
A service task is a task that is part of the process that is executed outside of the process, but is not a human task. Examples of service tasks include sending an email and logging a message when these tasks are performed by systems. You can define the parameters (input) and results (output) that are associated with a service task. A Service Task should have one incoming connection and one outgoing connection.
Procedure
- Create a business process.
- In the process designer, select the Activities tool from the tool palette.
- Select Service Task.
- Click a blank area of the process designer canvas.
- If necessary, in the upper-right corner of the screen, click the Properties icon.
Add or define the task information listed in the following table as required.
Expand Table 4.5. Service task parameters Label Description Name
The name of the service task.
Documentation
Enter a description of the task. The text in this field is included in the process documentation. Click the Documentation tab in the upper-left side of the process designer canvas to view the process documentation.
Implementation
Specify whether the task is implemented in Java or is a web service
Interface
The class used to implement the script, for example
org.xyz.HelloWorld
.Operation
The method that will be called by the interface, for example
sayHello()
.Assignments
Click to add local variables.
Adhoc Autostart
Select if this is an ad hoc task that should be started automatically. Adhoc Autostart enables the task to automatically start when the process or case instance is created instead of being starting by a start task. It is often used in case management.
Is Async
Select if this task should be invoked asynchronously. Make tasks asynchronous if they cannot be executed instantaneously, for example a task performed by an outside service.
Is Multiple Instance
Select if this task has multiple instances.
On Entry Action
A Java, JavaScript, or MVEL script that specifies an action at the start of the task.
On Exit Action
A Java, JavaScript, or MVEL script that specifies an action at the end of the task.
SLA Due Date
The date the the service level agreement (SLA) expires.
- Click Save.
4.6. Making a copy of a business process Copier lienLien copié sur presse-papiers!
You can make a copy of a business process in Business Central and modify the copied process as needed.
Procedure
- In the business process designer, click Copy in the upper-right toolbar.
- In the Make a Copy window, enter a new name for the copied business process, select the target package, and optionally add a comment.
- Click Make a Copy.
- Modify the copied business process as needed and click Save to save the updated business process.
4.7. Resizing elements and using the zoom function to view business processes Copier lienLien copié sur presse-papiers!
You can resize individual elements in a business process and zoom in or out to modify the view of your business process.
Procedure
- In the business process designer, select the element and click the red dot in the lower-right corner of the element.
Drag the red dot to resize the element.
Figure 4.1. Resize an element
To zoom in or out to view the entire diagram, click the plus or minus sign on the lower-right side of the canvas.
Figure 4.2. Enlarge or shrink a business process
4.8. Generating process documentation in Business Central Copier lienLien copié sur presse-papiers!
In the process designer in Business Central, you can view and print a report of the process definition. The process documentation summarizes the components, data, and visual flow of the process in a format (PDF) that you can print and share more easily.
Procedure
- In Business Central, navigate to a project that contains a business process and select the process.
In the process designer, click the Documentation tab to view the summary of the process file, and click Print in the top-right corner of the window to print the PDF report.
Figure 4.3. Generate process documentation