Tutorial: Building a Worklist Application

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Step 5: Using Business Processes with Worklist

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.

  1. In the Package Explorer pane, right-click the Loan_Web\src folder, and select New > Folder. This will display the New Folder dialog box.
  2. Enter process in the Folder name field and click Finish.
  3. Select the process folder and use Ctrl+N to display the Select a Wizard dialog box.
  4. Select WebLogic Integration > Process and click Next to display the New Process File dialog box.
  5. 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).
  6. Figure 6-1 Defining a New Process


    Defining a New Process

  7. Click Finish to complete the process.
  8. The new business process appears in the Design view (see Figure 6-2).

    Figure 6-2 Creating a New Process


    Creating a New Process

  9. Double-click the Select Start Event (see Figure 6-2).
  10. The node builder displays.

  11. 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.
  12. Click on Subscription and replace it with Subscribe worklist event.
  13. Double-click the Start node to configure it (see Figure 6-3).
  14. Figure 6-3 Configuring the Start Node


    Configuring the Start Node

  15. In the General Settings tab, click View Code and replace the following code:
  16. @com.bea.wli.control.broker.MessageBroker.StaticSubscription(xquery = "", filterValueMatch = "", channelName = "", messageBody ="{x0}")
    public void subscription(org.apache.xmlbeans.XmlObject x0) {

    with

    @com.bea.wli.control.broker.MessageBroker.StaticSubscription(xquery = "", filterValueMatch = "", channelName = "/WorklistEvent", messageBody = "{x0}", messageMetaData = "{x1}")
    public void subscription(com.bea.data.RawData x0, com.bea.wli.worklist.xml.TaskEventMetadataDocument x1) {
  17. Click Save, and select Design to return to the Design view.
  18. 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.
  19. 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 and in 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.
  20. 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:

  1. In the Design view, select Insert > Perform to insert an action node between Subscription and the Finish nodes.
  2. Name the node as Print Messages, as shown in Figure 6-4.
  3. Figure 6-4 Adding the Perform Node


    Adding the Perform Node

  4. Click the Source tab of the business process and it should highlight the perform method definition.
  5. Enter the following code into the perform method:
  6. 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()); 
  7. Enter the following import statements to the beginning of the process.
  8. import java.io.ByteArrayInputStream; 
    import java.io.ObjectInputStream; 
    import com.bea.wli.worklist.api.events.data.*; 
  9. Select File > Save or use Ctrl+S to save the file.

Deploy the Loan_JPD

  1. In the Package Explorer pane, right-click the Loan_jpd.java project that you created previously and select Run As > Run on Server.
  2. The Run on Server dialog box is displayed.

  3. Select Choose an existing server and from the Select the server that you want to use: list, select the myworklist server and click Next.
  4. This will display the Add and Remove Projects dialog box.

  5. click Next.
  6. 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.
  7. 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:

  1. Start a new session of the loan web project in a Web browser using the URL:
  2. http://localhost:7001/Loan_Web
  3. Log in to the portal using the following credentials:
  4. Username: weblogic 
    Password: weblogic 
  5. Click Login to display the Task home page for user weblogic (see Figure 6-5).
  6. Figure 6-5 View Task Home Page for User weblogic


    View Task Home Page for User weblogic

  7. Click the /Loan/loan_approval 1.0 option in the Create Task portlet. The Create New Task page is displayed.
  8. Ensure that NewLoan is selected as the task plan constructor.
  9. Specify the details listed in Table 6-1 for the other fields on the page:
  10. 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

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

  1. Open a Web browser and enter the following URL to open the WebLogic Worklist Console:
  2. http://localhost:7001/worklistconsole 
  3. Use the following credentials to log in to the Worklist Console, with administrator rights:
  4. Username: weblogic 
    Password: weblogic 
  5. Click View Tasks for the Loan_EAR Worklist System Instance.
  6. 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.
  7. The Worklist Task Details is displayed (see Figure 6-6).

    Figure 6-6 Worklist Task Details - Maggie JPD


    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.

  1. In the Package Explorer pane, select the Loan_Web\src\processes folder, and use Ctrl+N to display the Select a Wizard dialog box.
  2. Select WebLogic Integration > Process and click Next to display the New Process File dialog box, similar to Figure 6-1.
  3. In the Name field, enter WorklistControl. This will create a business process file WorklistControl.java under the processes folder.
  4. Click Finish to complete the process.

    The new business process appears in the design view (see Figure 6-7).

    Figure 6-7 New Process Using Worklist Control


    New Process Using Worklist Control

  5. Double-click Select Start Event (see Figure 6-7).
  6. The node builder displays.

  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.
  8. Double-click Client Request node to invoke the node builder for the Client Request node as shown in Figure 6-8.
  9. Figure 6-8 Configuring Client Request


    Configuring Client Request

  10. 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.
  11. Table 6-2 Setting Parameters for the Client Request
    Parameter Name
    Type
    TaskName
    String
    Name
    String
    SSN
    String
    LoanAmt
    Long

  12. 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.
  13. Figure 6-9 Assigning Variables to Parameters


    Assigning Variables to Parameters

    The four new variables of default type are: TaskName(String),Name(String), SSN(String), and LoanAmt(Long).

  14. Click Close to continue, and the business process appears as shown in Figure 6-10.
  15. Figure 6-10 WorkListControl Process with Client Request Start Node


    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.

  1. In the Package Explorer pane, select the Loan_Web\src\processes folder,and use Ctrl+N to display the Select a Wizard dialog box.
  2. Select WebLogic Integration Controls > Task and click Next to display the Create Control page of the Insert Control: Task dialog box.
  3. Enter MyControl in the Name field and ensure that the other fields have the same value as shown in Figure 6-11.
  4. Figure 6-11 Creating a Task Control


    Creating a Task Control

  5. Click Next to proceed to the Task Plan page of the Insert Control: Task dialog box.
  6. For the Task Plan field, click Browse and select Loan_EAR\EarConten\Loan\loan_approval.task.as shown in Figure 6-12.
  7. Figure 6-12 Selecting the Loan Approval Task Plan


    Selecting the Loan Approval Task Plan

  8. Click OK to continue.
  9. Click Finish to add the new Task Control to the business process.
  10. Select MyControl.java from the Package Explorer, drag and drop it to Controls folder in the Data Palette.
  11. Note: If the Data Palette pane is not visible, go to Window > Show View > Other > WebLogic Integration > Data Palette
  12. 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.

  1. 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.
  2. 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.
  3. Figure 6-13 Selecting the NewLoan Method


    Selecting the NewLoan Method

  4. 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).
  5. Figure 6-14 WorklistControl Process with NewLoan Node


    WorklistControl Process with NewLoan Node

  6. 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.
  7. Figure 6-15 Mapping the Send Data Variables with the Control Parameters


    Mapping the Send Data Variables with the Control Parameters

  8. Click Close to implement the settings.
  9. 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.

  1. Ensure the WorklistControl.java is selected in the Package Explorer, and click the Run > Run As option. After successful deployment the business process page will be launched in the IDE browser.
  2. Click the Test Form tab of the WorklistControl process browser, as shown in Figure 6-16.
  3. Figure 6-16 WorklistControl Process Test Form Page


    WorklistControl Process Test Form Page

  4. Enter the test values in their respective fields, as shown in Table 6-3.
  5. Table 6-3 Test Values for the WorklistControl Process
    Parameter
    Value
    TaskName
    Loan for John Doe
    Name
    John Doe
    SSN
    123-456
    LoanAmt
    20000

  6. Click ClientRequest to execute the process with the test values. After a successful execution, the TestForm tab is refreshed (see Figure 6-17).
  7. Figure 6-17 Successful Execution of the WorklistControl Business Process


    Successful Execution of the WorklistControl Business Process

  8. Start a new session of the Loan_Web project in a Web browser using the URL:
  9. http://localhost:7001/Loan_Web 
  10. Log in to the portal using the following credentials:
  11. 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.

  12. Click Login to display the Task home page for user John, as shown in Figure 6-18.
  13. Figure 6-18 Task Home Page for User John


    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.


  Back to Top       Previous  Next