com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Simulating an Order Approval Process

The following example demonstrates creating a business process scenario to simulate an order approval process. The Production Manager invokes an order approval process where it is possible to set the product ID. Additionally, an admin user of the Production Division can set the quantity to order and the unit price of the product. The quantity and the unit price are used to calculate the total cost. If the total cost is above 100,000, the order will have to be approved by an admin user from the Production Division before the order email is dispatched to the Purchasing Division. Alternatively, if the cost is below 100,000, the order email is dispatched to the Purchasing Division without approval. 

Before you begin,

  • Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the JAVA_HOME environment variable.
  • Download the product installer from here, and run the installer.
    Let's call the installation location of your product the <EI_HOME> directory.

    If you installed the product using the installer, this is located in a place specific to your OS as shown below:

    OSHome directory
    Mac OS/Library/WSO2/EnterpriseIntegrator/6.5.0
    WindowsC:\Program Files\WSO2\EnterpriseIntegrator\6.5.0\
    Ubuntu/usr/lib/wso2/EnterpriseIntegrator/6.5.0
    CentOS/usr/lib64/EnterpriseIntegrator/6.5.0
  • Select and download the relevant WSO2 Integration Studio ZIP file depending on your operating system from here, and then extract the ZIP file.

Let's get started! This tutorial includes the following sections:

Creating the artifacts

Follow the steps below to create the requires artifacts.

  1. Create a new BPMN project named OrderApprovalBPMNFor instructions, see Creating a BPMN Project.
  2. Create a BPMN Diagram named OrderApproval.bpmn. For instructions, see Creating the BPMN Diagram.

  3. Click anywhere on the canvas, go to the Properties tab, and fill in the following details:
    Id               : orderApproval
    Name         : Order Approval Process
    Namespacehttp://wso2.org/bpmn/orderApproval
  4. To implement the order approval process, drag and drop a StartEvent element, two UserTask elements, a MailTask element and a End Event element on the canvas. 
  5. For each artifact, in the Properties tab, select General and enter the corresponding names as Fill Order FormApprove Order and Order Product as shown below.
  6. According to the business logic in this example, the Start Event should trigger the Fill Order Form User Task. Therefore, in the Connection tab, select Sequence Flow, and connect the Start Event to the Fill Order Form User Task.

  7. Hover your mouse over the Fill Order Form task and click on the Exclusive Gateway icon.

    The diamond shape with a cross in the middle implies an Exclusive Gateway. This is used to add the condition logic statements. The condition statement should implement the logic that if the total cost calculated from the quantity and unit price is above 100,000 a user task has to be executed. Else, the mail task has to be executed. 


  8. Use the Sequence Flow to connect the other artifacts as shown below.

Configuring the artifacts

After the diagram has been constructed, you must configure the properties of each element to implement the business logic.

Configuring the Start Event

Follow the steps below to configure the Start Event.

  1. Click on the Start Event and set the following values in the General section of the Properties tab.

    • Id: fillOrderDetails

    • Name: Enter Order Details

  2. Click the Start Event and click Form in the Properties tab.

    This is to create a form to get the order details (i.e., the product ID) from the manager who invokes the process. 

     

  3. Click the New button, enter the below details to create a productID field and click OK.
    • Id: productID

    • Name: Product Id

    • Type: string

    • Variable: productID

Configuring the User Tasks

Now, you can configure the Fill Order Form User Task, which is a Claimable Task. An administrator of the Production Division can claim and complete the form. 

  1. Click on the Fill Order FormUser Task and set fillOrderForm as the ID in the General section of the Properties tab.

  2. Click Main Config in the Properties tab and enter admin as the value of the Candidate Group.

    Since there is no specific user to assign the task, an admin user from the Goods Division can claim the task and execute it. This allows any administrator under the Goods Division to claim and complete the task.

  3. Click Form in the Properties tab, click New each time and add the values in the below table. This creates the form that the employee needs to fill with the productID, quantity and unitPrice fields.  


    productIDquantityunitPrice
    IdproductIDquantityunitPrice
    NameProduct IDQuantityUnit Price
    Typestringlongdouble
    VariableproductIDquantityunitPrice

    Once the above fields are added to the form, the table in your Form should look similar to the following:

  4. Now that you have configured your Fill Order Form User Task, you can identify the two flows: the default flow and conditional flow. Follow the steps below to assign the default flow.

    1.   Click on the Sequence Flow arrow, which connects the Exclusive Gateway to the Mail Task.
    2. Set orderProductFlow as the value of the Id property.
    3. To set orderProductFlow as the default flow, do the following.
      1. Click on the Exclusive Gateway
      2. Click the General tab in the Properties pane and select orderProductFlow in the drop down to assign it.
  5. To assign the Conditional flow, click on the Sequence Flow arrow, which connects the Exclusive Gateway to the Approve Order User Task. In the Main Config section of the Properties tab, enter the following value as the Condition${(quantity*unitPrice) > 100000}

    This is for calculating the total cost and checking if it exceeds 100,000. If it does, it will take the conditional flow.


     You have now configured the conditional flow. If the total cost exceeds 100,000, the flow is directed to the Approve Order User Task.

  6. To configure the Approve Order User Task, do the following. 

    1. Click on the Approve Order User Task

    2. In the General section of the Properties tab, enter approveOrderFlow as the Id. 

    3. In the Main Config section, set the Candidate Group as admin. This enables anyone from the order approval group to claim and complete the task. 

    4. To allow the approver to view the order details, create a form to display the Product ID, Quantity and Unit Price. To do this, navigate to the Form section in the Properties tab and create the fields as shown below.


      productIDquantityunitPrice
      IdproductIDquantityunitPrice
      NameProduct IDQuantityUnit Price
      Typestringlongdouble
      VariableproductIDquantityunitPrice
      Readabletruetruetrue

    Now, you have configured all the BPMN artifacts.

Configuring the Mail Task

To configure the Mail Task, do the following. 

  1. Click on the Order Product Mail Task and enter orderProduct as the Id in the General section of the Properties tab.

  2. In the Main Config section of the Properties tab, fill the respective fields (i.e., To, From, Subject). 
  3. In the Non-HTML field of the Main Config section, enter Order ${quantity} of ${productID} at the rate of ${unitPrice}. The variable will be used to create the mail body.
  4. Copy the following JAR files into the<EI_HOME>/lib directory and restart the Business Process profile server instance. 

  5. In the <EI_HOME>/wso2/business-process/conf/activiti.xml fileadd the following properties under the <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> property as shown below, to enable the Gmail configurations.

    • Replace the mailServerHost and mailServerPort property values as follows:

      <property name="mailServerHost" value="smtp.gmail.com"/>
      <property name="mailServerPort" value="587"/>
    • Add the following properties:

      <property name="mailServerDefaultFrom" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/>
      <property name="mailServerUseTLS" value="true"/>
      <property name="mailServerUsername" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/>
      <property name="mailServerPassword" value="<ENTER_THE_EMAIL_PASSWORD>"/>

The model is now complete as the necessary logic has been applied.

Deploying the artifacts

  1. For instructions on creating the deployable artifacts, see Creating the deployable archive.
  2. For instructions on deploying them, see Deploying BPMN artifacts.

Testing the output

Follow the steps below to test the output.

  1. If you have not started the business profile previously, make sure to start it.

  2. Log in to the BPMN-explorer at https://localhost:9445/bpmn-explorer using admin for both the username and password.
  3. Click PROCESSES in the top menu, and click the Start option of the Order Approval Process.

  4. Enter a value for the Product Id and click Start. This creates a Claimable Task.
  5. Click TASKS in the top menu, and then click Claimable Tasks
  6. Click on the new Claimable Task.

  7. Click Claim Task on the next Fill Order Form screen.
  8. Enter values for the Quantity and Unit Price to get a total value (i.e., Quantity * Unit Price), which is less than 100,000, and click Complete Task.

    You view the claimable task being completed and removed from the TASKS list, since the total value you entered (i.e., Quantity * Unit Price) is less than 100,000. 

    Click TASKSCOMPLETED TASKS to view the completed task.

    Also, you will receive an email to the recipient email address you defined.

  9. Follow the above steps again by entering values for the Quantity and Unit Price to get a total value (i.e., Quantity * Unit Price), which is more than 100,000.
  10. Click TASKS CLAIMABLE TASKS. Since you are logged in as the administrator, you view the Claimable Task, which is created for the administrator to approve the order. 
  11. Click on the Task and click Complete Task to approve the order.
  12. Click on the task, click Claim Task, and then click Complete Task.

    You will receive an email to the recipient email address you defined.


com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.