Adding the Not Confirmed Transition

In this task you add the last conditional transition of the Expense Report process. This transition is to be used when the treasurer does not confirm one or more receipts.

Because we don't know the number of items in an expense report beforehand, we need to code a loop to check the status of each receipt.

You could place this loop in the conditional transition itself, but it is better to add a method to the BPM Object. In this way, you can use the method elsewhere, and, if you make any changes to the way this information is stored in the BPM object, you need to update only one piece of code.

Also, the conditional expression in the transition itself is simpler, and thus easier to read and maintain. It is good practice to use simple expressions within conditional transitions.

You will define the areReceiptsChecked method and then add the Not Confirmed transition, which uses it.

To add the areReceiptsChecked method and the Not Confirmed transition:

  1. In the Project Navigator, right-click on the ExpenseReport BPM Object, and click New Method. The Method dialog box appears.
  2. In the Method Name field, enter areReceiptsChecked and click OK. A method editor opens.
  3. In the Properties Window, set the Return Type property to Bool.
  4. Enter the following code into the editor, exactly as shown:
    for each item in items do
       if not item.receiptChecked then
          return false
       end
    end
    
    return true

    for each item in items do

    if not item.receiptChecked then

    return false

    end

    end

    return true

    This code returns false if any item has not been checked. If all items have been checked, it returns true.

  5. Save and close the editor.
  6. In the process design editor, right-click on the Confirm Receipts activity and click Add conditional transition (Condition Transition icon 
				). The mouse cursor begins dragging a transition line originating from the Confirm Receipts activity.
  7. Click on the Edit Report activity. The Transition from Activity dialog appears.
  8. Enter Not Confirmedin the Name field.
  9. Go to the Properties page of the dialog box. In the conditional expression text box, enter the following expression:
    not report.areReceiptsChecked()

    This expression will return true if areReceiptsChecked returns false. In other words, the instance flows through the condition transition if the supervisor does not check receipts for one or more items.

  10. Click OK. The Not Confirmed conditional transition is added.
  11. Click and drag the Not Confirmed transition into an arc, then save your changes.

After completing this task, your process design diagram looks like this:

Figure 1. Expense Report process with Not Confirmed conditional transition