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 JPDs with Worklist

This section describes details on how to use JPDs 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. So, 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 NewArrow symbolFolder. This will display the New Folder dialog box.
  2. Enter processes in the Folder name field and click Finish.
  3. Select the processes folder and use Ctrl+N to display the Select a Wizard dialog box.
  4. Select WebLogic IntegrationArrow symbolProcess and click Next to display the New Process File dialog box.
  5. In the Name field, enter Loan_jpd. This will create a JPD process file Loan_jpd.java under the newly created processes folder (see Figure 6-1).
  6. Figure 6-1 Defining a New JPD File


    Defining a New JPD File

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

    Figure 6-2 Creating a New JPD


    Creating a New JPD

  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 JPD 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, select /WorklistEvent as the Channel Name.
  16. In the Specify Filter tab, select eventType from the TaskEventMetadata xml tree, and type CREATE as the filter value.
  17. 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 TaskEventMetadataDocumentx1 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.
  18. 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 JPD 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 InsertArrow symbolPerform 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 JPD 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 JPD.
  8. import java.io.ByteArrayInputStream; 
    import java.io.ObjectInputStream; 
    import com.bea.wli.worklist.api.events.data.*; 
  9. Select FileArrow symbolSave 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 AsArrow symbolRun 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 JPD 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 JPD 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 JPD. During this process, you will create a Worklist JPD (WorklistControl), a Task Control (MyControl), deploy the process, and subsequently create a sample task to validate the task instance creation.

Create a Worklist JPD

This section details steps on how to create a Worklist JPD.

  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 IntegrationArrow symbolProcess 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 JPD process file WorklistControl.java under the processes folder.
  4. Click Finish to complete the process.

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

    Figure 6-7 New JPD Using Worklist Control


    New JPD 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 JPD 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
    java.lang.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 JPD appears as shown in Figure 6-10.
  15. Figure 6-10 WorkListControl JPD with Client Request Start Node


    WorkListControl JPD 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 the other fields have 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 JPD.
  10. 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 WindowArrow symbolShow ViewOtherArrow symbolWebLogic IntegrationArrow symbolData Palette
  1. Select FileArrow symbolSave or use Ctrl+S to save the JPD.

Add Task Plan Constructor to JPD

In this section, you will add the task instance creation constructor to the Worklist JPD.

  1. Right click the WorklistControl.java file in the Package Explorer pane and select Open WithArrow symbolProcess Editor option. Ensure the JPD is displayed in the Design tab and that you are using the Process Perspective.
  2. From the Data Palette pane on the bottom right corner of the IDE, navigate to ControlsArrow symbolmyControl 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 JPD, between the Client Request and the Finish nodes. The method will be added as NewLoan (see Figure 6-14).
  5. Figure 6-14 WorklistControl JPD with NewLoan Node


    WorklistControl JPD 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 FileArrow symbolSave or use Ctrl+S to save the JPD.

Validate the WorklistControl JPD

In this section, you will deploy the JPD and after successfully deploying the JPD, you will validate it using test values.

  1. Ensure the WorklistControl.java is selected in the Package Explorer, and click the RunArrow symbolRun As option. After successful deployment the JPD 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 JPD


    Successful Execution of the WorklistControl JPD

  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 JPD using a Control.


  Back to Top       Previous  Next