Red Hat Training

A Red Hat training course is available for Red Hat Process Automation Manager

Chapter 6. Designing the case definition

You design cases using the process designer in Business Central. Case design is the basis of case management and sets the specific goals and tasks for each case. The case flow can be modified dynamically during run time by adding dynamic tasks or processes.

The IT_Orders sample project in Business Central includes the following orderhardware business process case definition. In this procedure, you will create this same case definition to familiarize yourself with the case definition design process.

Figure 6.1. orderhardware business process case definition

IT Orders case design

Prerequisites

Procedure

  1. In Business Central, go to MenuDesignProjects and click IT_Orders_New.
  2. Click Add AssetCase Definition (legacy).
  3. In the Create new Case definition window, add the following required information:

    • Case Definition: Input orderhardware. This is usually the subject of the case or project that is being case managed.
    • Package: Select com.myspace.it_orders_new to specify the location that the case file is created in.
  4. Click Ok to open the process designer.
  5. Define process-level and case-level variables.

    1. Click expand proj explorer to view the Project Explorer.
    2. Click BUSINESS PROCESSES (LEGACY)orderhardware.
    3. Click left arrows on the right side of the designer to open the Diagram properties panel.
    4. Click the down arrow in the Variable Definitions field to open the Editor for Variable Definitions.
    5. Click Add Variable, and input the following values and click Ok:

      Figure 6.2. IT Orders variables

      Editor for IT Orders variables
  6. Define the roles involved in the case.

    1. Click the down arrow in the Case Roles field to open the Editor for Case Roles.
    2. Click Add Case Role, and input the following values and click Ok:

      Figure 6.3. ITOrders Case Roles

      Case Roles
      • owner: The employee who is making the hardware order request. The role cardinality is set to 1, which means that only one person or group can be assigned to this role.
      • manager: The employee’s manager; the person who will approve or deny the requested hardware. The role cardinality is set to 1, which means that only one person or group can be assigned to this role.
      • supplier: The available suppliers of IT hardware in the system. The role cardinality is set to 2, which means that more than one supplier can be assigned to this role.
  7. Define the work item to be triggered when a new case starts.

    Note

    By default, the process designer includes a Milestone object.

  8. Click Add AssetBusiness Process (legacy).
  9. Enter the following values:

    • Business Process: orderhardware
    • Package: Select com.myspace.it_orders_new
  10. Click Ok to open the Business Process (legacy) editor. The following image shows the different panels that comprise the editor.

    Figure 6.4. Business Process (legacy) editor

    Editor navigation

    1: The canvas where you build your process diagram. Drag elements from the Object Library to the canvas to design your process.

    2: The Object Library.

    3: The Properties panel displays the properties of the selected element. If no element is selected, the panel contains process properties.

6.1. Create the Manager approval business process

The manager approval process determines whether or not the order will be placed or rejected.

Procedure

  1. In the process designer, expand Tasks in the Object Library and drag a new User task on the canvas.
  2. Click the new user task and in the upper-right corner, click left arrows to open the Properties panel.
  3. Input supplier in the Groups field, Prepare hardware spec in the Name field, and PrepareHardwareSpec in the Task Name field.
  4. Enter the following in the Description field:

    Prepare hardware specification for #{initiator} (order number #{CaseId})

  5. Click the down arrow in the Assignments field, add the following new conditions in the Prepare hardware spec Data I/O window, and click Save.

    Prepare hardware I/O values
  6. Click the Prepare hardware spec user task and create an new user task.

    Creating a new user task
  7. Click the new user task and in the upper-right corner, click left arrows to open the Properties panel.
  8. Input manager in the Actors field, Manager approval in the Name field, and ManagerApproval in the Task Name field.
  9. Enter Approval request for new hardware for #{initiator} (order number #{CaseId}) in the Description field:
  10. Click the down arrow in the Assignments field, add the following new conditions in the ManagerApproval Data I/O window, and click Save.

    Manager approval I/O values
  11. Click the Manager approval user task and create a Data-based Exclusive (XOR) gateway, and then click the exclusive gateway and create a new task.

    Creating an exclusive gateway
    Creating a new user task
  12. Click the new task, and then click left arrows to open the Properties panel.
  13. Input Sub-Process in the ActivityType field and Place order in the Name field.
  14. Click the down arrow in the Called Element field, select place-order.bpmn from the Asset Name column, and click Save.
  15. Click the down arrow in the Independent field and select false.
  16. Click the down arrow in the Assignments field and add the following new conditions in the Place order Data I/O window.

    Place order I/O values
  17. Click the connection from the exclusive gateway to the Place order task and add the following in the Expression field, and click Save.

    return KieFunctions.isTrue(approved);

  18. Click the Place order user task and create an end event.

    Create an end event
  19. Click the exclusive gateway and create a new user task and drag the new task to align it below the Place order task.

    Align new task
  20. Click the new user task and in the upper-right corner, click left arrows to open the Properties panel.
  21. Input owner in the Actors field, Order rejected in the Name field, and OrderRejected in the Task Name field.
  22. Enter Order #{CaseId} has been rejected by manager in the Description field, click the down arrow in the Assignments field, and add the following new conditions in the Order rejected Data I/O window.

    Order rejected I/O values
  23. Click the connection from the exclusive gateway to the Order rejected task, add return KieFunctions.isFalse(approved); in the Expression field, and click Save.
  24. Click the Place order user task, create an end event, click Save, and then Save to confirm your changes.

6.2. Create the Hardware spec ready Milestone

Create a Hardware spec ready milestone that is reached when the required hardware specification document is completed.

Procedure

  1. In the process designer, expand Milestone in the Object Library and drag a new milestone on the canvas and place it on the right side of the Place order end event.
  2. Click the new milestone and in the upper-right corner, click left arrows to open the Properties panel.
  3. Input Hardware spec ready in the Name field.
  4. Select true from the Adhoc autostart menu.
  5. Click the down arrow in the Assignments field and add the following new conditions in the Hardware spec ready Data I/O window.

    Add CaseData(data.get("hwSpec") != null) by selecting Constant from the Source menu.

    Hardware spec ready I/O values
  6. Click Save.

6.3. Create the Manager decision Milestone

This milestone is reached when the managerDecision variable has been given a response.

Procedure

  1. In the process designer, expand Milestone in the Object Library and drag a new milestone on the canvas below the the Notify requestor script task.
  2. Click the new milestone and in the upper-right corner, click left arrows to open the Properties panel.
  3. Input Manager decision in the Name field.
  4. Select true from the Adhoc autostart menu.
  5. Click the down arrow in the Assignments field and add the following new conditions in the Manager decision Data I/O window.

    Add CaseData(data.get("managerDecision") != null) by selecting Constant from the Source menu.

    Manager decision I/O values
  6. Click Save.

6.4. Create the Order placed Milestone

This milestone is reached when the ordered variable has been given a response.

Procedure

  1. In the process designer, click the default Milestone object.
  2. In the upper-right corner, click left arrows to open the Properties panel.
  3. Input Milestone 1: Order placed in the Name field.
  4. Select true from the Adhoc autostart menu.
  5. Click the down arrow in the Assignments field to add a new condition in the Milestone 1: Order placed Data I/O window.
  6. Click the Source column drop-down, select Constant, and input org.kie.api.runtime.process.CaseData(data.get("ordered") == true). This means that a case variable named ordered exists with the value true.

    Milestone evaluation condition configuration
  7. Click Save.

    For more information about milestones, see Section 1.1, “Milestones”.

  8. Click Milestone 1: Order placed and create a new script task.

    new task creation
    convert to a script task
  9. Click the new script task and in the upper-right corner, click left arrows to open the Properties panel.
  10. Input Notify requestor in the Name field.
  11. Click the down arrow in the Script field, input System.out.println("Notification::Order placed");, and click Ok.
  12. Click the Notify requestor scipt task and create a signal end event.

    new end event
    convert to a signal event
  13. Click the signal event and click left arrows to open the Properties panel.
  14. Click the down arrow in the Signal Scope field, select Process Instance.
  15. Click the down arrow in the SignalRef field, input Milestone 2: Order shipped, and click Ok.

6.5. Create the Order shipped Milestone

The condition for this milestone is that a case file variable named shipped is true. Adhoc autostart is not enabled for this milestone. Instead, it is triggered by a signal event when the order is ready to be sent.

Procedure

  1. In the process designer, expand Milestone in the Object Library and drag a new milestone on the canvas below the the Notify requestor script task.
  2. Click the new milestone and in the upper-right corner, click left arrows to open the Properties panel.
  3. Input Milestone 2: Order shipped in the Name field.
  4. Select false from the Adhoc autostart menu.
  5. Click the down arrow in the Assignments field to add a new condition in the Data Inputs and Assignments window.
  6. Click the Source column drop-down, select Constant, and input org.kie.api.runtime.process.CaseData(data.get("shipped") == true). This means that a case variable named shipped exists with the value true.
  7. Click Save.
  8. Click Milestone 2: Order shipped and create a new script task.
  9. Click the new script task and in the upper-right corner, click left arrows to open the Properties panel.
  10. Input Send to tracking system in the Name field.
  11. Click the down arrow in the Script field, input System.out.println("Order added to tracking system");, and click Ok.
  12. Click the Send to tracking system scipt task and create a signal end event.
  13. Click the signal event and click left arrows to open the Properties panel.
  14. Click the down arrow in the Signal Scope field, select Process Instance.
  15. Click the down arrow in the SignalRef field, input Milestone 3: Delivered to customer, and click Ok.

6.6. Create the Delivered to customer milestone

The condition for this milestone is that a case file variable named delivered is true. Adhoc autostart is not enabled for this milestone. Instead, it is triggered by a signal event after the order has successfully shipped to the customer.

Procedure

  1. In the process designer, expand Milestone in the Object Library and drag a new milestone on the canvas below the the Send to tracking system script task.
  2. Click the new milestone and in the upper-right corner, click left arrows to open the Properties panel.
  3. Input Milestone 3: Delivered to customer in the Name field.
  4. Select false from the Adhoc autostart menu.
  5. Click the down arrow in the Assignments field to add a new condition in the Milestone 2: Order shipped Data I/O window.
  6. Click the Source column drop-down, select Constant, and input org.kie.api.runtime.process.CaseData(data.get("delivered") == true). This means that a case variable named delivered exists with the value true.
  7. Click Save.
  8. Click Milestone 3: Delivered to customer and create a new user task.
  9. Click the new user task and in the upper-right corner, click left arrows to open the Properties panel.
  10. Input owner in the Actors field.
  11. Click the down arrow in the Assignments field to add data input and output assignments in the Milestone 3: Delivered to customer Data I/O window as shown below. For the output Data Type column, select Constant, and input org.kie.api.runtime.process.CaseData(data.get("delivered") == true).

    survey I/O values
  12. Click Save.
  13. Input Customer satisfaction survey in the Name field.
  14. Input CustomerSurvey in the Task Name field.
  15. Click the Customer satisfaction survey user task and create an end event.
  16. Click Save, and then Save to confirm your changes.

The IT Orders case can be closed after all milestone sequences are completed. However, due to the ad hoc nature of cases, the case could be reopened if, for example, the order was never received by the customer or the item is faulty. Tasks can be re-triggered or added to the case definition as required, even during run time.

For more information about ad hoc processes, see Chapter 8, Ad hoc and dynamic tasks.