Time for action – designing your first process

We have designed a business process using the Activiti Modeler. To add technical details to a business process, we have to design a business process using the Activiti Designer. So, let's design a business process in the Activiti Designer by performing the following steps:

  1. After configuring the Activiti Designer in Eclipse, we will design an executable process. So, let's take the example of the laptop ordering process, as shown in the following diagram:
    Time for action – designing your first process
  2. In the laptop ordering process, we will have three user tasks and three script tasks.
  3. We will create a new Activiti project to start the process creation; for that, we have to navigate to File | New | Activiti Project and provide a name, for example, laptopOrdering-HumanProcess.
    Time for action – designing your first process
  4. Upon the successful creation of the Activiti project, we will have created a directory structure as shown in the following screenshot. In the main directory, we can have the production environment's implementation files, and in the test directory, we can have the test environment's implementation files; there is also a pom.xml file available, which can convert the Activiti project to a Maven project and execute it as such.
    Time for action – designing your first process
  5. Now we will design the process diagram using the Activiti Diagram option by navigating to File| New | Other | Activiti Diagram, which can be found at src | main | resources | diagrams with the name laptopOrderingProcess.
    Time for action – designing your first process
  6. Once the laptopOrderingProcess.bpmn file is created, drag-and-drop a StartEvent option from the Event tab available in the Palette section on the right-hand side of the screen, as shown in the following screenshot:
    Time for action – designing your first process
  7. We can place the next node by selecting it from the start node itself. As we want a user task connected after the start node, we will select the Create user task option from the list shown in the following screenshot:
    Time for action – designing your first process
  8. Now based on the output provided by the execution of the user task, the process has to decide which path to execute. To decide the path, a gateway is used. There are three types of gateways available: inclusive, exclusive, and parallel; they are explained in Chapter 2, Modeling Using the Activiti Modeler. In this process, we will be using the exclusive gateway:
    Time for action – designing your first process
  9. We will design the entire process flow using script tasks, user tasks, and the exclusive gateway.
  10. After designing the entire process, we will populate the properties of the business process and the nodes used.
  11. We will start by populating the properties of our business process. We will provide a unique name and ID for our process. For that, we need to select the white canvas and open the Properties window in which these properties can be specified, as shown in the following screenshot:
    Time for action – designing your first process
  12. We want some values to be provided at the start of the process. For this, populate the form properties of the start node, select the start node, open the Properties window, and select the Form tab from the Properties window, as shown in the following screenshot:
    Time for action – designing your first process
  13. To add a new form property, select the New option; this will open a form where variable declarations can be made. At the start of the process, the customer will provide some information about the laptop to be ordered, such as the laptop name, quantity, model number, and customer name. We will declare these variables using the form property, as shown in the following screenshot:
    Time for action – designing your first process
  14. Activiti supports only certain data types, such as boolean, long, string, enum, and date. There are other properties, such as Readable, Writeable, and Required, that are by default set to true. We will look at the instances in which these properties need to be set to false. So, the form properties that we are setting in the start event will be visible to the user when they start the process.
    Time for action – designing your first process
  15. Once the customer provides the details regarding the laptop, they should be passed to the Order Approval user task. This task will be assigned to a specific user who will either approve or reject the order. To assign this task to a specific user, populate the Assignee property of the user task. By default, there are three users available. All these properties are available in the Main Config tab of the user task properties.
    Time for action – designing your first process

    Note

    If you want to assign a task to multiple users, you will have to populate the Candidate user comma separated property in this field and provide the names with comma-separated values. If you want the task to be assigned to a group, populate the Candidate group comma separated property with group names.

  16. The user task is only responsible for accepting and rejecting orders. The user task also has form properties; we will be setting Type as enum and in Form values we will provide the values to be displayed, as shown in the following screenshot:
    Time for action – designing your first process
  17. To display the details provided by the user, we will have to populate the Expression property. In the Expression property, we have to use the ${id} syntax. As shown in the following screenshot, the Expression values are the IDs that were provided by us in the start node, and the Writeable and Required properties are set to false as these values cannot be edited:
    Time for action – designing your first process
  18. We have defined an exclusive gateway connected after the Order Approval task; it checks the output provided by the Order Approval task, that is, whether the order is accepted or rejected. There are two outgoing connections from the gateway: one for insufficient stock and another for accepting the order. To provide conditions, we have to make changes in the Condition property of the Stock Not Available flow with the acceptOrder value. This is the form property defined in the Order Approval task. So, here we are checking whether or not the output is set to false. If it is, follow the path shown in this screenshot:
    Time for action – designing your first process

    Note

    Conditions can be defined on the paths but not on the gateway.

  19. In the other flow conditions property, we are checking whether or not the output is set to true. If it is, follow the path shown in this screenshot:
    Time for action – designing your first process
  20. If the acceptOrder values are set to false, a script task named Mail for insufficient stock is executed. For this script task, we have set the Script Language property to groovy, and in the Script property, we have just printed a simple message to display on the console. Similarly, if the output is set to true, the Order Processing script task should be executed first and then the Invoice Process script task and the Payment Task user task, as shown in the following screenshot:
    Time for action – designing your first process
  21. For the Payment Task user task, we are going to dynamically assign users. In the following screenshot, you can see that the Assignee property is populated with ${id}, customerName, which is the form property field of the start event; this was the name provided at the start of the process. The Payment Task will be assigned to the particular user who has been assigned.
    Time for action – designing your first process
  22. After the Payment Task and Mail for insufficient Stock tasks are completed, we have to add an exclusive gateway that has two incoming connections and one outgoing connection. This means that if any of the incoming flow is executed, the process will proceed to the Notification script task, the message defined in the Script property will be displayed, and the process will be terminated as there is an end node defined after the Notification task is executed, as shown in the following screenshot:
    Time for action – designing your first process

What just happened?

We have just finished discussing process creation using the Activiti Designer and also gained some knowledge regarding the various nodes and how to populate their properties. Now you should be able to design your own process using the Activiti Designer by adding technical details to your process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset