BEA Logo BEA WebLogic Collaborate Release 1.0.1

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

 

   WebLogic Collaborate Doc Home   |   Tutorial   |   Previous Topic   |   Next Topic   |   Contents   |   Index

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


Decision

Is order Confirmed? Does the variable Confirm= Yes?



Task

Inventory Check


Decision

Is stock available? Is variable Inventory greater than zero?


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 Create Template from the pop-up menu.

    Figure 2-3 Create 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 Create 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

 


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.

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

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

    3. 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.

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

    2. 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 Description 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 Description field, and click OK.

    Figure 2-13 Event Properties Dialog Box

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

POBeanHandle

Session EJB

Handler for POBean EJB

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 Create Variable from the pop-up menu.

    Figure 2-15 Create 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. From the Type drop-down list, select String.

  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 Table 2-2. When you have created all new variables, your folder tree should look like the following:

    Figure 2-18 New Variables List

 


Defining Business Operations

In WebLogic Process Integrator, a business operation represents a method call on an Entity/Session 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.

Entity/Session 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.

The WebLogic Processing Integrator Business Operations facility enables business analysts to design workflows that invoke the methods of Java objects and Enterprise Java Beans (EJBs) that are registered in WebLogic Sever (WLS). Using this Business Operations facility, you provide a descriptive name for the remote methods and parameters of the Entity/Session 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.

Using the Define Business Operation dialog box, you will define two Session EJB business operations. These business operations represent remote methods of invoking the wlpi.tour.POBean 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:

Defining the Check Inventory Business Operation

To define the first business operation, Check Inventory, which is called from the Order Processing workflow and returns the number of items available in stock:

  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 to display the Define Business Operation dialog box.

    Figure 2-20 Define Business Operation Dialog Box

  3. In the Business Operation Name field, enter the business operation name Check Inventory.

    Next, you will select the type of business operation that you are defining. The choices are:

  4. You will create a Session EJB business operation. Select the Session EJB radio button to display fields relevant to Session EJBs in the Define Business Operation dialog box.

    Figure 2-21 Create Session EJB Business Operation

  5. From the JNDI Name for Session EJB drop-down list, select the JNDI (Java Naming and Directory Interface) name for the Session EJB: wlpi.tour.POBean.

    JNDI is a service provided by WebLogic Server; this service stores objects much like a database. Here, you are selecting the JNDI name for the Session EJB; a Session EJB is an object stored in this service.

  6. The Method to Call drop-down list contains a list of methods (or operations) that you can perform on the Session EJB. Select the method to call from the drop-down list: int checkInventory(int p0) throws RemoteException.

  7. Highlight the Parameter Name 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 ItemNumber, and click OK.

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

Defining the Calculate Total Price Business Operation

To create the next business operation, Calculate Total Price, which calculates the total price of the order and is called within the workflow ShipBill:

  1. From the Configuration menu, choose Business Operation to display the Business Operations dialog box. (See Figure 2-19.)

  2. Click Add to display the Define Business Operation dialog box. (See Figure Figure 2-20.)

  3. In the Business Operation Name field, enter the business operation name Calculate Total Price.

  4. Select the Session EJB radio button to display fields relevant to Session EJBs in the Define Business Operation dialog box. (See Figure 2-21.)

  5. From the JNDI Name for Session EJB drop-down list, select the JNDI (Java Naming and Directory Interface) name for the Session EJB: wlpi.tour.POBean.

  6. The Method to Call drop-down list contains a list of methods (or operations) that you can perform on the Session EJB by calling it. Select the method to call from the drop-down list: double calculate(int p0, int p1, String p2).

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

    Figure 2-23 Parameter Dialog Box

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

  9. 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.

  10. Click OK.

Note: The parameter type is displayed for each parameter.

Figure 2-24 Calculate Business Operation

Defining the Create PO Bean Business Operation

To define the final business operation, Create PO Bean, which creates the POBean object for the Order Processing workflow:

  1. From the Configuration menu, choose Business Operation to display the Business Operations dialog box. (See Figure 2-19.)

  2. Click Add to display the Define Business Operation dialog box. (See Figure 2-20.)

  3. In the Business Operation Name field, enter the business operation name Create PO Bean.

  4. Select the Session EJB radio button to display fields relevant to Session EJBs in the Define Business Operation dialog box. (See Figure 2-21.)

  5. From the JNDI Name for Session EJB drop-down list, select the JNDI (Java Naming and Directory Interface) name for the Session EJB: wlpi.tour.POBean.

  6. The Method to Call drop-down list contains a list of methods (or operations) that you can perform on the Session EJB by calling it. Select the method to call from the drop-down list: PurchaseOrder create(), and click OK.

Note: This method contains no parameters.

Figure 2-25 Create PO Bean Business Operation

After Business Operation Creation

The Business Operations dialog box now contains the three business operations you have just defined.

Figure 2-26 Business Operations Dialog Box

Once you have defined the business operations, you can call them from the workflow using the Perform Business Operation action. This action calls the business operations from the workflow. Instructions for using the Perform Business Operations action are provided in Define Inventory Check Task and in Defining the ShipBill Workflow: An Exception Handling Example.

 


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-27 Task Properties

  2. Select the Activated tab. The Assign Task "Confirm Order" to User Workflow Attribute ("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-28 Add Action Dialog Box

  6. Select Assign Task to User and click OK.

    Figure 2-30 Assign Task to User Dialog Box

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

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

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

    Figure 2-31 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-32 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 XML Document Structure, to continue defining the Confirm Order task.

    Figure 2-33 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 following figure shows how the Send XML to Client dialog box should look after you complete the procedure.

Figure 2-34 Final XML Document Structure

To define the XML document structure:

  1. In the Send XML to Client dialog box, change the default root element display 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-35 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 to return to the Confirm Order Task Properties dialog box. 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-36 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, you create two Perform Business Operation actions, which perform the business operations you defined in Defining Business Operations, and one Mark Task as Done action, which marks the task as done once the two business operations are complete.

Defining the Create PO Bean Perform Business Operation Action

To define the Create PO Bean Perform Business Operation action, which creates the POBean object:

  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 to display the Add Action dialog box.

    Figure 2-37 Add Action: Perform Business Operation

  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-38 Perform Business Operation Dialog Box

  4. The Operation drop-down list contains three business operations Check Inventory, Calculate Total Price, and Create PO Bean that you defined earlier. Select Create PO Bean.

    Note: No parameters are associated with the Create PO Bean business operation, since it represents a home method session EJB.

    The Assign result to (int) drop-down list already contains the value associated with this business operation, PoBeanHandle.

  5. Click OK to return to the Task Properties dialog box.

Defining the Check Inventory Perform Business Operation Action

To define the Check Inventory Perform Business Operation action, which returns the total number of items in stock:

  1. With the Inventory Check Task Properties dialog box still open, select the Activated tab, then click Add to display the Add Action dialog box. (See Figure 2-37.)

  2. 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. (See Figure 2-38.)

  3. From the Operation drop-down list, select the Check Inventory business operation.

    Instance Variable, Parameter Name, and Assign result to are already populated with values correlating to the Check Inventory business operation.

  4. 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-39 Expression Builder Dialog Box

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

  6. 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.

  7. From the Assign result to (int) drop-down list, select the variable Inventory (integer), and click OK to return to the Task Properties dialog box.

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

    Figure 2-40 Perform Business Operation Dialog Box: Check Inventory

Defining the Mark Task as Done Action

You will now add the Mark Task as Done action to the Activated tab of the Task Properties dialog box. This action marks the task as done once all other actions within this task are performed and activates the C2 Decision node.

  1. With the Check Inventory Task Properties dialog box still open, select the Activated tab, then click Add to display the Add Action dialog box. (See Figure 2-37.)

  2. In the Add Action dialog box under Task Actions, select the Mark Task as Done action, and click OK to display the Mark Task as Done dialog box.

    Figure 2-41 Mark Task as Done Dialog Box

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

    The Activated tab of the Task Properties dialog box now contains three tasks that will be executed upon activation of the workflow. (See Figure 2-42.)

    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: An Exception Handling Example.

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.

    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 set up the Post XML Event action. If the condition evaluates to false (if the order is not confirmed by the user joe), WebLogic Process Integrator will trigger the event Cancellation Watch as a result of 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 subelements:

To define the XML document structure:

  1. Select the By Composing radio button on the Post XML Event dialog box.

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

  3. Select the Element radio button.

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

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

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

  7. Highlight the order node, and click Add to insert a new node in the XML document structure.

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

  9. In the Value expression field, enter $ItemNumber.

    Figure 2-46 Post XML Event Dialog Box

  10. 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: An Exception Handling Example.)

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:

 


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, expand the Order Processing folder to display its template definitions.

  2. Right-click the template definition and choose Open to open the template definition, and right-click the template definition again 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

  3. 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.

  4. 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

  5. Click OK.

Note: For instructions on using the Exception Handlers tab to set up an exception handler, see Defining the ShipBill Workflow: An Exception Handling Example.