BEA Logo BEA WebLogic Process Integrator Release 1.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WebLogic Process Integrator Doc Home   |   Tutorial   |   Previous Topic   |   Next Topic   |   Contents   |  

Defining the Order Processing Workflow

 

The following sections describe how to create and define the Order Processing workflow:

 


Overview of the Order Processing Workflow

The following figure illustrates how the Order Processing workflow diagram should look after you define the entire workflow.

For details on the various workflow components represented by nodes in a workflow diagram, see Chapter 4, "Working with Workflow Components," in the BEA WebLogic Process Integrator Studio Guide.

Figure 2-1 Order Processing Workflow

The Order Processing workflow will contain the following nodes:

Table 2-1 Order Processing Workflow Nodes

Icon

Node

Definition


Start

XML event coming from workflow: Start Order Processing.



Task

Confirm Order

  • Task is assigned to user: joe upon activation.

  • Upon execution, the user is presented with a prompt from the WebLogic Process Integrator Worklist application to validate the order.

  • The result: Yes or No is stored in the variable :Confirm.

  • Task is marked done.


Decision

Is order Confirmed? Does the variable Confirm= Yes?

  • If Yes, flow moves on to the next task.

  • If No, a cancellation XML message is sent.



Task

Inventory Check

  • Upon activation, the inventory bean is called.

  • The bean returns a value to the variable :Inventory.

  • The task is marked done.


Decision

Is stock available? Is variable Inventory greater than zero?

  • If yes, the workflow: ShipBill is started and the flow moves on to the next node: Event: ShipBill Confirmation.

  • If No: The workflow is terminated.


Event

ShipBill Confirmation

When the XML document that confirms the shipping and billing comes back from the ShipBill workflow, the ShipBill Confirmation event is triggered, and the Order Processing workflow is completed.


Event

Cancellation Watch

A cancellation event is triggered by an XML message directing the order to be cancelled. When this event is triggered, the Done node is reached and the workflow is completed.


Done

Workflow Completed.

 


Creating a New Workflow Template

A workflow template is, in essence, a folder or a container for WebLogic Process Integrator workflow template definitions; each workflow template can hold one or more WebLogic Process Integrator workflow template definitions. Workflow template definitions are essentially different versions of a workflow.

WebLogic Process Integrator workflow template definitions are identified in the folder tree by an Effective and Expiry date; these are discussed in "Understanding Effective and Expiry Dates" of Chapter 3, "Defining and Maintaining Workflows" in the BEA WebLogic Process Integrator Studio Guide.

To create the Order Processing workflow template:

  1. If you have not already done so, perform steps 1 and 2 in the Important Terms section of Overview of the Example.

  2. Start WebLogic Process Integrator Studio by selecting Start > Programs > WebLogic Process Integrator Studio to display the WebLogic Process Integrator Logon dialog box.

    Figure 2-2 Logon to WebLogic Process Integrator Dialog Box

  3. Enter your user ID, password, and the name of the WebLogic Process Integrator server to which you will connect, and click OK.

  4. In the WebLogic Process Integrator Studio main window, create a new template by right-clicking Template and choosing New Template from the pop-up menu.

    Figure 2-3 Choose New Template

  5. In the dialog box that is displayed, enter Order Processing in the Name field and choose the organizations to which you want the template to belong: ORG1 in this example.

    The Order Processing workflow template will be added under the Templates folder.

    Figure 2-4 Template Properties Dialog Box

 


Creating a New Workflow Template Definition

To create a new workflow template definition for the new workflow template:

  1. Under the Templates folder, right-click Order Processing workflow template and choose New Template Definition from the pop-up menu.

    Figure 2-5 Choose New Template Definition

  2. In the dialog box that is displayed, enter an Effective date for the new workflow template definition and click OK. (In this example, do not specify an Expiry date in order to make this workflow template definition always effective.)

    Figure 2-6 Template Definition Dialog Box

    The Effective and Expiry dates allow you to make the workflow template definitions valid for a specific range of time. Each workflow template can contain one or more workflow template definitions, distinguished by the Effective and Expiry dates. At run time, the processing engine chooses the most effective workflow template definition for the specified workflow template, the most effective being the most current template definition that is marked active.

 


Drawing the Flow

Once you complete the Template Definition dialog box and click OK, the drawing area is displayed with a simple predefined workflow containing a start node, a task node, and a done node. From the toolbar, you choose the icons that represent nodes and other elements that you use to draw the flow. (Nodes in the drawing area are also referred to as shapes.)

Figure 2-7 Workflow Drawing Area

The Processing Order workflow requires the following nodes:

Placing Node Icons (Shapes) in the Drawing Area

Place a shape in the drawing area by clicking its icon in the toolbar and then clicking the drawing area. This drops the shape (representing a workflow node) in the drawing area. Follow this procedure to place one task, two events, and two decisions in the drawing area. (The start and done nodes and one task node are already represented.)

You can move shapes within the drawing area by dragging and dropping them anywhere in the drawing area.

Figure 2-8 Shapes Placed in Drawing Area

Connecting the Nodes

Next, you connect the shapes in the drawing area to form the flow of the workflow. You connect shapes in one of two ways:

To connect the nodes:

  1. Before you begin making the connections, delete the connection between the Task 1 node and the Done node by clicking once on the arrow connecting them, right-clicking with your mouse, and choosing Delete Connection from the pop-up menu.

  2. Make the following shape connections using the first connection method described at the beginning of this section.

    1. Connect the Start node to Event 1 (E1). (The Start node, by default, is connected to Task 1 (T1). Leave this connection intact.)

    2. Connect Event 1 (E1) to the done node.

    3. Connect Task 1 (T1) to the C1 decision node.

    4. Connect the C1 decision node to Task 2 (T2).

      Note: A Decision node contains a condition, which can be either True or False. If the condition within the Decision node is verified as True, the workflow continues to Task 2.

    5. A dialog box appears asking you what kind of connection you want. Select True.

    6. Connect Task 2 (T2) to the C2 decision node.

    7. Connect the C2 decision node to Event 2 (E2).

      Note: A decision node contains a condition, which can be either True or False. If the condition within the decision node is verified as True, the workflow continues to Task 2.

    8. A dialog box appears asking you what kind of connection you want. Select True.

    9. Connect Event 2 (E2) to the done node.

      You should have the following flow.

      Figure 2-9 Completed Drawing

Renaming Nodes

Next, you will rename nodes in the drawing area.

Task 1 (T1) Node

  1. In the drawing area, double-click the Task 1 (T1) node to open the Task Properties dialog box.

    This dialog contains the names of the nodes in the drawing area.

  2. Enter Confirm Order in the Task Name field, and click OK.

    Figure 2-10 Task Properties Dialog Box

Task 2 (T2) Node

  1. In the drawing area, double-click the Task 2 (T2) node.

  2. Enter Inventory Check in the Task Name field, and click OK.

    Figure 2-11 Task Properties Dialog Box

Event 1 (E1) Node

  1. In the drawing area, double-click the Event 1 (E1) node to open the Event Properties dialog box.

  2. Enter Cancellation Watch in the Task Name field, and click OK.

    Figure 2-12 Event Properties Dialog Box

Event 2 (E2) Node

  1. In the drawing area, double-click the Event 2 (E2) node.

  2. Enter Ship/Bill Confirmation in the Task Name field, and click OK.

    Figure 2-13 Event Properties Dialog Box

    Figure 2-14 Final Flow

After you connect all the nodes, you will define variables for the workflow; add the appropriate properties to each node; and define the actions for each node. These actions are executed at run time upon the instantiation of the workflow. Instantiation means that the workflow is started or placed into run time.

 


Defining Variables

Each workflow has a set of variables associated with it. A variable is typically used to store application-specific information required by the workflow at run time. This information is often used to control the logic within a workflow.

The Order Processing workflow requires the following variables.

Table 2-2 Variable Definitions

Variable

Type

Description

Confirm

String

User confirmation response; values are: Y or N

Inventory

Integer

Number of items available in inventory; can be zero

CustomerName

String

Name of the customer ordering the item

CustomerId

String

ID number of the customer ordering the item

CustomerMail

String

E-mail address of the customer

CustomerState

String

State or province for billing address and tax calculation

ItemName

String

Name of the ordered product

ItemNumber

Integer

Numerical identifier of the item

ItemQuantity

Integer

Quantity ordered

ItemPrice

Double

Unit price of the item

TotalPrice

Double

Total price of the order

OrderStatus

String

Status of the order

OrderNumber

Integer

Numerical identifier of the order

You will also need to define some of these variables for the ShipBill workflow that will be called by this workflow.

To define the variables for the Order Processing workflow:

  1. Expand the Order Processing folder, right-click Variable, and choose New Variable from the pop-up menu.

    Figure 2-15 Choose New Variable

The Variable Properties dialog box is displayed.

Figure 2-16 Variable Properties Dialog Box

You will define all of the variables in the preceding table using the Variable Properties dialog box. For example, you will begin by defining the variable Confirm, which is a string type variable. It is a user confirmation response, and its possible values are Y (yes) or N (no).

Note: For now, you will only enter the variable name and type. You will define the possible values later in this tutorial.

To define this variable, proceed as follows:

  1. In the Variable Properties dialog box, enter the variable name Confirm in the Name field.

  2. Select the String option button.

  3. For this demonstration, do not enter values in the Parameter and Notes portions of the dialog box, and click OK.

  4. Expand the Variables folder to view the new variable.

    Figure 2-17 New Variable

  5. Repeat these steps to create all variables listed in the preceding table. When you have created all new variables, your folder tree should look like the following:

    Figure 2-18 New Variables List

 


Defining Business Operations

The WebLogic Process Integrator Business Operations facility enables you to display all Enterprise JavaBeans (EJBs) or Java classes that are registered in WebLogic Sever and their remote methods and parameters. Using this Business Operations facility, you provide a descriptive name for the remote methods and parameters of the EJBs or Java classes that you wish to deploy, thus providing non-technical users with an understanding of the business meaning behind these remote methods and parameters.

In WebLogic Process Integrator, a business operation represents a method call on an EJB or Java class instance. This method call is added to a workflow in WebLogic Process Integrator through use of the Perform Business Operation action. The invocation results of this action can be assigned to the workflow variables.

EJBs represent a component architecture for developing and deploying object-oriented, distributed, enterprise-level applications. The Business Operations feature, in effect, allows for the creation of customized actions, which create the connection between WebLogic Process Integrator and end-user applications and components.

To define business operations:

  1. From the Configuration menu, choose Business Operation to display the Business Operations dialog box.

    Figure 2-19 Business Operations Dialog Box

  2. Click Add. You are prompted to add a new business operation.

    Figure 2-20 Add Business Operation Dialog Box

  3. Choose EJB and click OK. The Define Business Operation dialog box is displayed.

    Figure 2-21 Define Business Operation Dialog Box

    The Session Bean drop-down list displays all registered JavaBeans that are defined for BEA WebLogic Server. For each JavaBean, the methods are displayed in the Remote Method drop-down list, and for each method, the parameter types are displayed under this list. You will provide a meaningful name for each parameter.

    Using the Define Business Operation dialog box, you will define two business operations. These business operations represent remote methods of invoking the wlpi.tourPOBean JavaBean. This JavaBean is used in the workflow to check the inventory for the item ordered and return the results to the workflow.

    The business operations are:

  4. From the Session Bean list, select wlpi.tour.POBean.

  5. In the Description field, enter Check Inventory.

  6. Choose CheckInventory from the Remote Method drop-down list.

  7. Highlight the Parameter field, and click Update to display the Parameter dialog box.

    Figure 2-22 Parameter Dialog Box

  8. In the Description field, enter the parameter description CheckInventory, and click OK.

    Note: The parameter type is displayed for each parameter, because these parameters are already defined.

    Figure 2-23 Define Business Operation Dialog Box

    Next you will define the business operation Calculate.

  9. In the Description field of the Define Business Operation dialog box, enter Calculate Total Price.

  10. Choose Calculate from the Remote Method drop-down list.

  11. In the Parameters column, highlight the first parameter, which is of the type integer, and click Update to display the Parameter dialog box.

  12. In the Description field, enter the parameter description ItemNumber, and click OK.

  13. Repeat these steps to enter the remaining two parameter names. The second parameter should be named ItemQuantity, and the third parameter should be named CustomerState.

    Figure 2-24 Define Business Operation Dialog Box

    The Business Operations dialog box now displays the two defined business operations.

    Figure 2-25 Business Operations Dialog Box

    Once the actual business operations are defined, you can call them into the workflow using the Perform Business Operation action. This action calls the business operations into the workflow.

    Instructions for using the Perform Business Operations action are provided in Define Inventory Check Task and in Defining the ShipBill Workflow.

 


Defining Tasks

A workflow consists of a series of tasks, each of which represents a discrete activity to be performed automatically by the WebLogic Process Integrator server or by a workflow end user by using the worklist application. In this section, you define the tasks in the Order Processing workflow.

Defining the Confirm Order Task

To define the Confirm Order task:

  1. In the workflow diagram, double-click the task Confirm Order to display the Task Properties dialog box.

    Figure 2-26 Task Properties

    Confirm Order is the first task in this workflow. At run time, this task is performed by an end user. Therefore, it is assigned to an actual user and is displayed on that user's worklist upon instantiation of the workflow.

    The tabs on the left side of the dialog box display four separate lists of actions for the tasks that are performed at the four task events. A task responds to an event at run time by executing the associated actions. The four task events are:

  2. Select the Activated tab. The Assign Task "Confirm Order" to User WorkflowAttribute("Initiator") action, by default, is already defined in this task event.

  3. Select the Assign Task to User action in the Activated tab, and click Delete to delete this action.

  4. Click Yes to confirm the delete.

    You are now ready to add the new Assign Task to User action.

  5. Click Add to display the Add Action dialog box.

    Figure 2-27 Add Action Dialog Box

    Actions are the basic building blocks of the workflow. They can be defined within tasks, events, decisions, starts, and as a sub-action of an action itself.

    The action categories are Task, Workflow, Integration, and Miscellaneous. The task category contains all actions relevant to tasks, including actions that allow the assignment of tasks to users and roles.

    Figure 2-28 Add Action Dialog Box

  6. Select Assign Task to User and click OK.

    Figure 2-29 Assign Task to User Dialog Box

  7. In the Task to Assign portion of the dialog box, select the task Confirm Order.

  8. Select joe from the User drop-down list, and click OK.

    The Assign Task to User action is displayed in the Activated tab.

    Figure 2-30 Task Properties: Assign Task to User Action

    The Confirm Order task, upon execution, prompts the user to confirm the order. The Decision node that succeeds the task directs the flow according to the user's response.

  9. Select the Executed tab of the task and click Add.

  10. Select Integration Actions from the Add Action dialog box.

    The action that allows the user to interact with the worklist and enter a response to a question or value for a variable is Send XML to Client in the Integration Actions category.

    Figure 2-31 Integration Actions

  11. Select Send XML to Client, and click OK to display the Send XML to Client dialog box.

    Proceed to the next section, Defining the Order Processing Workflow, to continue defining the Confirm Order task.

    Figure 2-32 Send XML to Client Dialog Box

Understanding the XML Document Structure

In the Send XML to Client dialog box, you define an XML document, which will be sent out to the client application. The client application should be programmed to identify this XML document, respond to it appropriately, and send an XML document to the WebLogic Process Integrator server with information that can be used to populate workflow variables. The WebLogic Process Integrator Worklist responds to certain default setups of this action.

Default structures for the XML document can be used to:

To prompt the user for a simple Yes/No confirmation, the XML document must have the following structure, where:

Defining the XML Document Structure

Refer to the following figure and procedure to define the XML document structure. The figure shows how the Send XML to Client dialog box should look after you complete the procedure.

Figure 2-33 Final XML Document Structure

To define the XML document structure:

  1. In the Send XML to Client dialog box, change the default root element default to message-box by highlighting the default root element and entering the name message-box in the Name field.

  2. In the Value Expression field, enter the following value: "Do you Confirm this Order?" This is the question that will be presented to the end user in the message-box.

  3. Select the root element message-box and click Add to add the attribute title to message-box. A new XML node is displayed in the XML Document Structure portion of the dialog box.

  4. Select the Attribute radio button to make this new XML node an attribute, and rename the new XML node by entering title in the Name field.

  5. In the Value Expression field, enter the message-box title: "Confirm Order".

  6. Select the root element message-box and click Add to add the attribute style to message-box. A new XML node is displayed in the XML Document Structure portion of the dialog box.

  7. Select the Attribute radio button to make this new XML node an attribute, and rename the new XML node by entering style in the Name field.

  8. In the Value Expression field, enter the message-box style: "question".

  9. Select the root element message-box and click Add to add the attribute options to message-box. A new XML node is displayed in the XML Document Structure portion of the dialog box.

  10. Select the Attribute radio button to make this new XML node an attribute, and rename the new XML node by entering options in the Name field.

  11. In the Value Expression field, enter the message-box options: "Yes_No".

  12. Using the up and down arrows, rearrange the XML nodes so that they appear in the XML document structure in the following order:

  13. Click the Add button at the bottom of the dialog box to add a callback variable. The Workflow Variable Assignment dialog box is displayed.

  14. From the Variable drop-down list, select the Confirm variable.

  15. In the XML Expression field, enter the XML expression for the message-box using the XPath language structure. The XML expression for Confirm should be:

    XPath("/message-box/attribute::option")

    Note: If you know XML, you can type the expression directly into this field. Otherwise, click the A+B button to access the Expression Builder. For instructions on using the Expression Builder, see Chapter 6, "Using Expressions and Conditions," of the BEA WebLogic Process Integrator Studio Guide and Using the Expression Builder in this document.

    BEA WebLogic Process Integrator uses the XPath XML model. For information on XPath, refer to the following Web site: http://www.w3.org/TR/xpath.html. Also, refer to Chapter 6, "Using Expressions and Conditions," in the BEA WebLogic Process Integrator Studio Guide.

    Figure 2-34 Workflow Variable Assignment

    In the example here, the user's response will be stored in the workflow variable Confirm as defined in the Callback Variables tab in the lower part of the Send XML to Client dialog box.

  16. Click OK.

Using the Expression Builder

You use the Expression Builder to define the value of the variable coming back in an XML document from the worklist client application. The function XPath is used to parse the XML document and extract the relevant value from it.

The Expression Builder, available in dialog boxes where you see A+B, enables you to build expressions, by using predefined functions, literals and operators, which will be evaluated and executed at run time. Workflow variables are usually used in expressions. Clicking A+B in any dialog box displays the Expression Builder dialog box.

Figure 2-35 Expression Builder

See Chapter 6, "Using Expressions and Conditions," of the BEA WebLogic Process Integrator Studio Guide for detailed explanations of each function available in the Expression Builder.

Define Inventory Check Task

Upon activation, the Inventory Check task calls the JavaBean POBean, which checks the inventory for the item ordered and returns the results to this workflow.

To define the Inventory Check task:

  1. In the workflow diagram, double-click the Inventory Check task.

  2. In the Task Properties dialog box, select the Activated tab, then click Add.

  3. In the Add Action dialog box under Integration Actions, select the Perform Business Operation action, and click OK to display the Perform Business Operation dialog box.

    Figure 2-36 Add Action: Perform Business Operation

    Figure 2-37 Perform Business Operation Dialog Box

  4. The Operation drop-down list contains the business operations CheckInventory and Calculate that you defined earlier. Select CheckInventory.

  5. In the Parameters section, the variable ItemNumber (defined earlier) is automatically inserted. Highlight it and click the Update button to display the Expression Builder. You will use the Expression Builder to specify the value of the ItemNumber input parameter.

    Figure 2-38 Expression Builder Dialog Box

  6. Select the Variables radio button, and from the scrollable list of variables (which you defined earlier), select the ItemNumber input parameter.

  7. Double-click on this parameter to display it in the Expression field, then click OK.

    The Value field of the Perform Business Operation dialog box is now populated with the :ItemNumber parameter value.

    Figure 2-39 Perform Business Operation Dialog Box

  8. From the Assign result to drop-down list, select the variable Inventory, and click OK.

    You have now placed the value of the variable ItemNumber as the input parameter to the JavaBean POBean and the variable Inventory will get the result back from the execution of this JavaBean.

    You will now add the Mark Task as Done action to the Activated tab of the Task Properties dialog box. This action will mark the task as done and instantiate the C2 Decision node. Make sure the Activated tab is selected.

  9. Click the Add button to display the Add Action dialog box.

  10. Under Task Actions, select the Mark Task as Done action, and click OK.

    Figure 2-40 Add Action Dialog Box

    The Mark Task as Done dialog box is displayed.

  11. Select the Inventory Check (T2) task as the task to be marked done, and click OK.

    Figure 2-41 Mark Task as Done Dialog Box

    The Activated tab of the Task Properties dialog box now contains two tasks that will be executed upon activation of the workflow.

    Figure 2-42 Activated Tab

 


Defining Decisions

A decision allows you to control the flow by evaluating a condition as true or false. Actions can be defined within the decision for each true or false case. The Order Processing workflow contains two decisions: one decision evaluates whether the user has confirmed the order, and the other confirms whether the inventory is available. If the inventory is available, the Order Processing workflow starts the ShipBill workflow, discussed in Defining the ShipBill Workflow.

Decision: Has Order Been Confirmed?

The first decision checks whether the user has confirmed the order. If the order has been confirmed, the flow continues to the next task Inventory Check. If the order has not been confirmed, an XML message is sent to cancel the workflow; the Cancellation Watch event in the workflow is triggered by this XML message, and the succeeding done node will cause the workflow to cancel.

Defining the C1 Decision Node

To define the C1 decision node:

  1. With the Order Processing workflow diagram open in the drawing area, double-click the C1 decision shape to display the Decision Properties dialog box.

    Figure 2-43 Decision Properties Dialog Box

  2. In the Condition field, enter :Confirm="yes" to rename the C1 decision node. Note that this is an expression.

    Note: You can type this expression directly into the Condition description field or can construct it using the Expression Builder, which you can access by clicking the A+B button.

    This condition evaluates whether the user has responded Yes or No to the confirmation of the order. If the condition is true (the user has double-clicked Confirm Order in the worklist and responded Yes to the Confirm Order message), the flow moves to the next node. If the condition is false, an XML message is sent to the workflow server, which cancels the order.

  3. The action that allows you to define an XML document and post it is Post XML Event in the Integration Actions category. Select the False tab in the Decision Properties dialog box. In the False tab, you will set up the Post XML Event action. If the condition evaluates to false (if the order is not confirmed by the user joe), the event Cancellation Watch will be triggered by this particular XML document. You will set up the Cancellation Watch event in Defining Events.

  4. Click Add to display the Add Action dialog box.

    Figure 2-44 Decision Properties Dialog Box

  5. Under Integration Actions, select Post XML Event and click OK to display the Post XML Event dialog box.

    Figure 2-45 Post XML Event Dialog Box

Defining the XML Document Structure

In the Post XML Event dialog box, you define an XML document. In this example, the XML document has the root element order and two sub-elements:

To define the XML document structure:

  1. Select the root element root, and in the Name field, type order.

  2. Select the Element radio button.

  3. Click Add to insert a new XML node in the XML document structure.

  4. Highlight the new XML node, and in the Name field, type status.

  5. Select the Element radio button and click OK.

  6. In the Value Expression field, type "cancelled".

  7. Click Add to insert a new XML node in the XML document structure.

  8. Highlight the new XML node, and in the Name field, enter itemnumber.

  9. Select the Element radio button, and click OK.

  10. In the Value expression field, enter :ItemNumber.

    Figure 2-46 Post XML Event Dialog Box

  11. Click OK to add the action to the False tab of the Decision Properties dialog box.

    Figure 2-47 Decision Properties Dialog Box

As you will see in the Defining Events section, the event Cancellation Watch will be triggered by this particular XML document.

Decision: Is Item Available?

This decision evaluates the value of a variable that is set as the result of a call to the JavaBean POBean. The value is the quantity in stock of the ordered item. If this number is zero, the order is cancelled. If the number is greater than zero, the ShipBill workflow is started by the Start Workflow action and the flow moves on to the next node, which is the Ship/Bill Confirmation event. (In this example, the available number of items is greater than the numbers of items ordered.)

To define the C2 Decision node:

  1. In the workflow diagram, double-click the C2 Decision shape to open the Decision Properties dialog box.

  2. In the Condition field, type :Inventory<>0. (This means "Inventory not equal to zero.")

    This expression can be typed directly into the Condition description field or can be constructed using the Expression Builder, accessed by clicking the A+B button. This condition evaluates whether the user has responded Yes or No to the confirmation of the order.

  3. Select the False tab and Click Add.

  4. In the Add Action dialog box under Workflow Actions, select the Abort Workflow action and click OK to display the Abort Workflow dialog box.

    Figure 2-48 Abort Workflow Dialog Box

  5. You do not need to enter anything in this dialog box. Simply click OK.

  6. The Abort Workflow action is added to the False tab in the Decision Properties dialog box. If the condition "Inventory not equal to zero" (:Inventory<>0) is false, the Abort Workflow action causes the workflow to cancel and the order cannot be completed.

    Figure 2-49 Decision Properties Dialog Box: Abort Workflow Action

  7. Select the True tab and click Add to display the Add Action dialog box.

  8. Under Workflow actions, select the Start Workflow action and click OK to display the Start Workflow dialog box.

    The Start Workflow action enables you to start a sub-workflow (in this case, ShipBill) from the current workflow, Order Processing.

    Figure 2-50 Start Workflow Dialog Box

  9. In the Workflow to Start portion of the dialog, select ShipBill.

  10. Under Start in Organization, select Current Organization.

In this example, the organization will remain ORG1, and the value of some variables are transferred from the Order Processing workflow to the ShipBill workflow.

As the example progresses, the variables in the "child" workflow (ShipBill), which will receive values from the "parent" workflow (Order Processing), will be defined as input variables within the variable definition dialog box. All input variables of the child workflow will automatically be displayed. Ordinarily, you can then use the Expression Builder to assign values to them. (In the example, we are simply transferring the values of the variables in the current workflow.)

 


Defining Events

An event is a notification node. An event is triggered by the arrival of an XML document that is produced internally within the WebLogic Process Integrator processing engine or from an external source through a Java Message Service (JMS) topic. When the flow reaches an event node, it waits until that event is triggered. An event can be cancelled by using the Cancel XML Event action.

The example contains two events: one event waits for the cancellation message, and the other event is triggered upon receipt of the shipping and billing confirmation in order to complete the order.

Event: Cancellation Watch

To define the Cancellation Watch event:

  1. In the Order Processing workflow diagram, double-click the Cancellation Watch (E1) event to open the Event Properties dialog box.

    Figure 2-51 Event Properties Dialog Box

  2. In the Root Element field, enter the root element of the XML document: order. As described in the Decision: Has Order Been Confirmed? section, order is the root element of the XML message sent by the Confirm Order task if the user does not confirm the order.

  3. In the Condition field, enter the condition to be satisfied. In this case, the condition is for the status to be "cancelled" and the ID of the workflow to match the value of the variable OrderNumber. Enter the condition as an expression in the Condition field or use the Expression Builder to compose the expression by clicking the A+B button. The expression in the Condition field should be:

    (status="cancelled")AND(ordernumber=:OrderNumber)

    Figure 2-52 Event Properties Dialog Box

    No further actions will be performed within this event, and the flow will move to the next node, which is the done node. However, in order to distinguish between a cancelled order and a completed one (having reached the done node of the workflow), you will add a workflow comment that will be displayed on the monitoring window upon execution of this workflow and when the cancellation occurs.

  4. Select the Actions tab and click Add to display the Add Action dialog box.

    Figure 2-53 Add Action Dialog Box

  5. In the Add Action dialog box under Workflow Actions, select Set Workflow Comment and click OK.

  6. In the Set Workflow Comment dialog box, type "Order Cancelled".

    Figure 2-54 Set Workflow Comment Dialog Box

  7. Click OK to add the action to the Actions tab of the Event Properties dialog box.

    Figure 2-55 Event Properties Dialog Box

Event: ShipBill Confirmation

Next, you set up the ShipBill Confirmation event, which waits for the ShipBill workflow to send back an XML document confirming the shipping and billing for the ordered item. (The ShipBill workflow is predefined for this example and is discussed in Defining the ShipBill Workflow.)

The root element of the XML message that will trigger this event is order, the same element that triggers the Cancellation Watch event. The condition, however, is different. For this event to be triggered, the status has to be "complete".

The total price of the item calculated by the JavaBean POBean in the ShipBill workflow is also returned to this workflow through the XML document.

To define the ShipBill Confirmation event:

  1. In the Order Processing workflow diagram, double-click the ShipBill Confirmation (E2) event to open the Event Properties dialog box.

    Figure 2-56 Event Properties Dialog Box

  2. In the Root Element field, enter the root element of the XML document: order. As described in the Decision: Has Order Been Confirmed? section, order is the root element of the XML message sent by the Confirm Order task if the user does not confirm the order.

  3. In the Condition field enter the condition to be satisfied. In this case, the condition is for the status to be "complete". The status must be such in order to trigger the Ship/Bill Confirmation event. Enter the condition as an expression in the Condition field or use the Expression Builder to compose the expression by clicking the A+B button. The expression should read as follows:

    status="complete"

    Next, you will set up an XML document, which returns the total price of the item calculated by the JavaBean POBean in the ShipBill workflow to the Order Processing workflow.

  4. In the Event Properties dialog box, click the Add button to display the Workflow Variable Assignment dialog box.

    Figure 2-57 Workflow Variable Assignment Dialog Box

  5. From the Variable drop-down list, select the variable TotalPrice.

  6. In the XML Expression field, enter the XML expression directly in the field or use the A+B button to access the Expression Builder to compose the expression, then click OK. The expression should read as follows:

    XPath("/order/totalprice/text()")

    Your final Event Properties dialog box should look like the following figure:

    Figure 2-58 Final Event Properties Dialog Box

 


Setting Up the Trigger

The Order Processing workflow is an event-triggered workflow. An XML document will be constructed and sent from the Start Order Processing workflow to trigger the Order Processing workflow. You specify the trigger conditions for the workflow in the Start node. There are four ways to start a workflow:

This example uses the Event method. The root element of the XML document will be order, and the condition is status="new". The organization for which this workflow should be instantiated also must be specified. Once this workflow is triggered, some of the variables will be populated by values contained in the XML document.

To set up the XML document that will trigger the Order Processing workflow:

  1. In the Order Processing workflow diagram, double-click the Start node to display the Start Properties dialog box.

  2. Select the Event radio button.

    Figure 2-59 Start Properties Dialog Box: Event

  3. In the Root Element field, enter the root element of the XML document: order. As described in the Decision: Has Order Been Confirmed? section, order is the root element of the XML message sent by the Confirm Order task if the user does not confirm the order.

  4. In the Condition field, enter the condition to be satisfied. In this case, the condition is for the status to be "new". The status must be such in order to trigger the Order Processing workflow whenever a new order is processed. Enter the condition as an expression in the Condition field or use the Expression Builder to compose the expression by clicking the A+B button. The expression should look like the following:

    status="new"

  5. In the Start Organization Expression field, enter an expression indicating in which organization the Order Processing will be started:

    "ORG1"

    Next, you will construct an XML document by defining the variable CustomerName to extract the value of the element name from the root customer.

  6. Click the Add button to display the Workflow Variable Assignment dialog box.

    Figure 2-60 Workflow Variable Assignment Dialog Box

  7. From the Variable drop-down list, select the variable CustomerName.

  8. In the XML Expression field, enter the XML expression to extract the value of the element name from the root customer. Enter the XML expression directly in the field or use the A+B button to access the Expression Builder to compose the expression:

    XPath("/order/customer/name/text()")

  9. Click OK.

  10. Repeat steps 7 through 9 for the following variables:

    Table 2-3 Variable Expressions

    Variable

    Expression

    CustomerId

    XPath("order/customer/id/text()")

    CustomerMail

    XPath("order/customer/email/text()")

    CustomerState

    XPath("order/customer/state/text()")

    ItemName

    XPath("order/item/name/text()")

    ItemNumber

    XPath("order/item/id/text()")

    ItemQuantity

    XPath("order/item/quantity/text()")

    ItemPrice

    XPath("order/item/price/text()")

    OrderStatus

    XPath("order/status/text()")

    OrderNumber

    XPath("order/number/text()")

    Figure 2-61 Start Properties Dialog Box

 


Setting Up the Workflow Template Definition Processing Properties

In order to process the Order Processing workflow, you must set up certain workflow template definition processing properties. The workflow must be marked as Active in the Properties dialog before it can be instantiated.

To set up the workflow template definition processing properties:

  1. In the main window of the WebLogic Process Integrator Studio, right-click the Order Processing folder and choose Properties from the pop-up menu to display the Template Definition Order Processing dialog box.

    Figure 2-62 Template Definition Order Processing Dialog Box

  2. In the Id field, type "Order" + :Order Number.

    The ID for the Order Processing workflow will be displayed on the worklist and on the monitoring screens. This ID is unique for each instance of this workflow; it is an expression built using workflow variables.

  3. Select the Active checkbox to allow the instantiation of the Order Processing workflow at run time. (A workflow cannot start unless it is marked Active.)

    You already defined the Effective and Expiry dates when you created the workflow template definition for Order Processing in Creating a New Workflow Template Definition.

    Figure 2-63 Template Definition Order Processing Dialog Box

  4. Click OK.