This section describes details on how to use business process and Worklist controls to support the integration of business processes with human actors via the Worklist system.
As with other built-in controls in Workshop for WebLogic Platform, you use the controls by adding instances of the controls to your business process. Subsequently, you invoke operations on the controls at the point in the business process at which you want to reach out to one or more human actors.
In this step, you will perform the following tasks:
Information in this section is an extension of the previous section, it is assumed that the Loan Application is open, and the myworklist server is up and running.
Subscribe to Worklist Events
Perform the following steps to configure access to the Message Broker Channel, and initiate the access using a start event.
In the Package Explorer pane, right-click theLoan_Web\src folder, and select New > Folder. This will display the New Folder dialog box.
Enter process in the Folder name field and click Finish.
Select the process folder and use Ctrl+N to display the Select a Wizard dialog box.
Select WebLogic Integration > Process and click Next to display the New Process File dialog box.
In the Name field, enter Loan_jpd. This will create a business process file Loan_jpd.java under the newly created processes folder (see Figure 6-1).
Figure 6-1 Defining a New Process
Click Finish to complete the process.
The new business process appears in the Design view (see Figure 6-2).
Figure 6-2 Creating a New Process
Double-click the Select Start Event (see Figure 6-2).
The node builder displays.
In the node builder, select Subscribe to a Message Broker channel and start via an event... and click Close. The Design view is refreshed and the Start node is named Subscription.
Click on Subscription and replace it with Subscribe worklist event.
Double-click the Start node to configure it (see Figure 6-3).
Figure 6-3 Configuring the Start Node
In the General Settings tab, click View Code and replace the following code:
public void subscription(com.bea.data.RawData x0, com.bea.wli.worklist.xml.TaskEventMetadataDocument x1) {
Click Save, and select Design to return to the Design view.
Double-click the Start node and in the Specify Filter tab, select eventType from the TaskEventMetadata xml tree, and type CREATE as the filter value.
In the Receive Data tab, do the following:
Select Create new variable next to RawData x0 and in the Create Variable dialog box that appears, enter worklistEventData in the Variable Name field, and select com.bea.data.RawData as its type.
Select Create new variable next to xl andin the Create Variable dialog box that appears, enter worklistEventMetaData in the Variable Name field, and enter com.bea.wli.worklist.xml.TaskEventMetadataDocument as its type.
Click OK to set the variable name, and click Close on the Start Node configuration to complete this step.
Configure a Perform Node
After creating a business process to subscribe to a Worklist event to start, create, and configure a Perform node to echo the event. Perform the following steps:
In the Design view, select Insert > Perform to insert an action node between Subscription and the Finish nodes.
Name the node as Print Messages, as shown in Figure 6-4.
Figure 6-4 Adding the Perform Node
Click the Source tab of the business process and it should highlight the perform method definition.
Enter the following code into the perform method:
System.out.println("####Got worklist event for loan task type");
ByteArrayInputStream bais = new ByteArrayInputStream(worklistEventData.byteValue());
ObjectInputStream ois = new ObjectInputStream(bais);
TaskEvent event = (TaskEvent)ois.readObject();
System.out.println("####Got TaskEvent data in JPD: " + event.getSummary());
Enter the following import statements to the beginning of the process.
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import com.bea.wli.worklist.api.events.data.*;
Select File > Save or use Ctrl+S to save the file.
Deploy the Loan_JPD
In the Package Explorer pane, right-click the Loan_jpd.java project that you created previously and select Run As > Run on Server.
The Run on Server dialog box is displayed.
Select Choose an existing server and from the Select the server that you want to use: list, select the myworklist server and click Next.
This will display the Add and Remove Projects dialog box.
click Next.
Ensure that Loan_EAR is listed in the Configured projects list. If it is not, then select Loan_EAR from the Available projects list, and click Add.
Click Finish to start deploying the project on the server.
Verify the Worklist Event is Published
Test the Application by creating a new task instance using the Worklist User Portal. After the task instance has been created, the Worklist event is published to the Message Broker, and a business process instance is started by the event. Perform the following steps:
Start a new session of the loan web project in a Web browser using the URL:
http://localhost:7001/Loan_Web
Log in to the portal using the following credentials:
Username: weblogic
Password: weblogic
Click Login to display the Task home page for user weblogic (see Figure 6-5).
Figure 6-5 View Task Home Page for User weblogic
Click the /Loan/loan_approval 1.0 option in the Create Task portlet. The Create New Task page is displayed.
Ensure that NewLoan is selected as the task plan constructor.
Specify the details listed in Table 6-1 for the other fields on the page:
Table 6-1 Specifications for the New Loan Approval Task Instance
Field Name
Value
Task Name
Car loan for Maggie JPD
User Properties: SSN
222-33-4444
User Properties: LoanAmt
40000
User Properties: Name
Maggie JPD
Click Create Task. The task is created and shows up in the Upcoming Tasks portlet on the home page.
You can also verify creation of the business process instance by logging into the WebLogic Worklist Console.
Open a Web browser and enter the following URL to open the WebLogic Worklist Console:
http://localhost:7001/worklistconsole
Use the following credentials to log in to the Worklist Console, with administrator rights:
Username: weblogic
Password: weblogic
Click View Tasks for the Loan_EAR Worklist System Instance.
In the Task Summary page, select the task from the list by clicking the check box adjacent to the task name, Car Loan for Maggie JPD.
The Worklist Task Details is displayed (see Figure 6-6).
Figure 6-6 Worklist Task Details - Maggie JPD
Use the Worklist Control
In this section, you will create a loan processing task instance using a Task Control in a business process. During this process, you will create a Worklist business process (WorklistControl), a Task Control (MyControl), deploy the process, and subsequently create a sample task to validate the task instance creation.
Create a Worklist Business Process
This section details steps on how to create a Worklist business process.
In the Package Explorer pane, select the Loan_Web\src\processes folder, and use Ctrl+N to display the Select a Wizard dialog box.
Select WebLogic Integration > Process and click Next to display the New Process File dialog box, similar to Figure 6-1.
In the Name field, enter WorklistControl. This will create a business process file WorklistControl.java under the processes folder.
Click Finish to complete the process.
The new business process appears in the design view (see Figure 6-7).
In the node builder, select Invoked via a Client Request and click Close. The Design view is refreshed and the Start node is named Client Request.
Double-click Client Request node to invoke the node builder for the Client Request node as shown in Figure 6-8.
Figure 6-8 Configuring Client Request
In the General Settings tab, click Add to display a dialog box for defining parameters. Create three parameters and configure their types as shown in Table 6-2.
Table 6-2 Setting Parameters for the Client Request
Parameter Name
Type
TaskName
String
Name
String
SSN
String
LoanAmt
Long
Click the Receive Data tab to create new variables and assign them the respective parameters created in the previous step. The variable assignment details are shown in Figure 6-9.
Figure 6-9 Assigning Variables to Parameters
The four new variables of default type are: TaskName(String),Name(String), SSN(String), and LoanAmt(Long).
Click Close to continue, and the business process appears as shown in Figure 6-10.
Figure 6-10 WorkListControl Process with Client Request Start Node
Create a Task Control
In this section, you will create a Task Control that will trigger the creation of a task instance.
In the Package Explorer pane, select the Loan_Web\src\processes folder,and use Ctrl+N to display the Select a Wizard dialog box.
Select WebLogic Integration Controls > Task and click Next to display the Create Control page of the Insert Control: Task dialog box.
Enter MyControl in the Name field and ensure that the other fields have the same value as shown in Figure 6-11.
Figure 6-11 Creating a Task Control
Click Next to proceed to the Task Plan page of the Insert Control: Task dialog box.
For the Task Plan field, click Browse and select Loan_EAR\EarConten\Loan\loan_approval.task.as shown in Figure 6-12.
Figure 6-12 Selecting the Loan Approval Task Plan
Click OK to continue.
Click Finish to add the new Task Control to the business process.
Select MyControl.java from the Package Explorer, drag and drop it to Controls folder in the Data Palette.
Note:
If the Data Palette pane is not visible, go to Window > ShowView > Other > WebLogic Integration > Data Palette
Select File > Save or use Ctrl+S to save the business process.
Add Task Plan Constructor to Business Process
In this section, you will add the task instance creation constructor to the Worklist business process.
Right click the WorklistControl.java file in the Package Explorer pane and select Open With > Process Editor option. Ensure the business process is displayed in the Design view and that you are using the Process Perspective.
From the Data Palette pane, navigate to Controls > myControl and select the OfficerReviewPending NewLoan(String taskName, String SSN, Long LoanAmt, String Name) method. As shown in Figure 6-13.
Figure 6-13 Selecting the NewLoan Method
Drag and drop the selected method into the WorklistControl business process, between the Client Request and the Finish nodes. The method will be added as NewLoan (see Figure 6-14).
Figure 6-14 WorklistControl Process with NewLoan Node
Double click NewLoan and configure the Send Data properties, as shown in Figure 6-15. You can leave the General Settings and Receive Data properties as they are.
Figure 6-15 Mapping the Send Data Variables with the Control Parameters
Click Close to implement the settings.
Select File > Save or use Ctrl+S to save the business process.
Validate the WorklistControl Business Process
In this section, you will deploy the business process and after successfully deploying it, you will validate it using test values.
Ensure the WorklistControl.java is selected in the Package Explorer, and click the Run > RunAs option. After successful deployment the business process page will be launched in the IDE browser.
Click the Test Form tab of the WorklistControl process browser, as shown in Figure 6-16.
Figure 6-16 WorklistControl Process Test Form Page
Enter the test values in their respective fields, as shown in Table 6-3.
Table 6-3 Test Values for the WorklistControl Process
Parameter
Value
TaskName
Loan for John Doe
Name
John Doe
SSN
123-456
LoanAmt
20000
Click ClientRequest to execute the process with the test values. After a successful execution, the TestForm tab is refreshed (see Figure 6-17).
Figure 6-17 Successful Execution of the WorklistControl Business Process
Start a new session of the Loan_Web project in a Web browser using the URL:
http://localhost:7001/Loan_Web
Log in to the portal using the following credentials:
Username: John
Password: password
The user John is part of the loanOfficer group and the task instance created should be visible in his Assigned Tasks portlet box.
Click Login to display the Task home page for user John, as shown in Figure 6-18.
Figure 6-18 Task Home Page for User John
The Assigned Tasks portlet box displays the Loan for John Doe task. This confirms that a task instance was created by a business process using a Control.