www.codeguru.com/cpp/sample_chapter/article.php/c10789/

Back to Article

Home >> Visual C++ / C++ >> Sample Chapter


Oracle BPEL Process Manager
Rating:

Packt Publishing (view profile)
October 19, 2005

Go to page: Prev  1  2  3  4  5  6  7  8  9  10  11  12  13  Next

Developing the Custom User Interface

After we have successfully modified the BPEL code we are ready to develop the custom user interface through which the user will approve the airline tickets. We will develop three JSPs:

  • One to display the tasks waiting for approval
  • One to display and enter the airline ticket information
  • One to make the ticket confirmation

(continued)




To simplify the data management we will use the XML façade for the TravelResponse message. For this we use the schemac tool on the Airline WSDL. Let us now develop the first JSP.

Displaying Tasks

To display the tasks that are waiting for approval, we use the BPEL Server Locator through which we connect to the BPEL default domain. Next we connect to the Worklist service and get the list of tasks that require approval:

<%@page import="java.util.Date" %>
<%@page import="com.oracle.bpel.client.Locator" %>
<%@page import="com.oracle.services.bpel.task.IWorklistService" %>
<%@page import="com.oracle.services.bpel.task.ITask" %>

<%
   // This page should not be cached
   response.setHeader("Pragma", "no-cache");
   response.setHeader("Cache-Control", "no-cache");

   // Connect to the default BPEL domain using Locator
   // Please set the password (bpel is initial password)
   Locator locator = new Locator("default", "bpel");

   // Look up the worklist service
   IWorklistService worklist =
   (IWorklistService)locator.lookupService(IWorklistService.SERVICE_NAME);

   // List of tasks assigned to confirm
   ITask[] tasks = worklist.listTasksByAssignee("travel@packtpub.com");
   %>
...

Next we list the tasks in the table and make a hyperlink to the next JSP through which we display the ticket information. Note that we use the task ID to identify which task the user has selected:

...
<html>
   <head>
      <meta http-equiv="PRAGMA" content="NO-CACHE" />
      <meta http-equiv="EXPIRES" content="-1" />
   </head>
   <body>
      <h1>BPEL Travel process tasks waiting for approval</h1>
      <table>
      <%
         for ( int i = 0; i < tasks.length; i ++ )
         {
            ITask thisTask = tasks[i];

            // Select only tasks that belong to us
            if ( ! "TravelUserTask".equals( thisTask.getCreator() ) )
            {
               continue;
            }

            // Get the task title
            String title = thisTask.getTitle();

            // Get the task ID
            String taskId = thisTask.getTaskId();

            // Get the task expiration date
            Date expiration = null;
            if( thisTask.getExpirationDate() != null )
               expiration = thisTask.getExpirationDate().getTime();
      %>
         <tr>
            <td>
            <%= expiration %>
            </td>
            <td>
            <a href="displayTicket.jsp?taskId=<%= taskId %>"><%= title %></a>
            </td>
         </tr>
      <%
         }
      %>
      </table>
   </body>
</html>

Displaying and Entering Ticket Information

In the second JSP we display information about the airline ticket and allow the user to edit the approval field (which can be true or false). We again use the Locator to connect to the BPEL domain. Then we connect to the Worklist service and locate the task by ID. We use the XML façade to obtain the ticket data:

<%@ page import="java.util.*" %>
<%@ page import="org.w3c.dom.Element" %>
<%@ page import="com.oracle.bpel.client.Locator" %>
<%@ page import="com.oracle.services.bpel.task.IWorklistService" %>
<%@ page import="com.oracle.services.bpel.task.ITask" %>
<%@ page import="com.packtpub.service.airline.FlightConfirmationType" %>
<%@ page import="com.packtpub.service.airline.FlightConfirmationTypeFactory"
%>

<html>
   <head>
      <meta http-equiv="PRAGMA" content="NO-CACHE" />
      <meta http-equiv="EXPIRES" content="-1" />
   </head>
   <body>
<%
   String taskId = request.getParameter( "taskId" );
   if( taskId == null || "".equals( taskId ) )
   {
%>
   <a href="displayTasks.jsp">
      List of BPEL Travel process tasks to approve.</a>
<%
   }
   else
   {
      // Connect to the default BPEL domain using Locator
      // Please set the password (bpel is initial password)
      Locator locator = new Locator( "default", "bpel" );

      // Lookup the worklist service
      IWorklistService worklist =
         (IWorklistService)locator.lookupService(
            IWorklistService.SERVICE_NAME );

      // Lookup the specific task the user has to confirm
      ITask task = worklist.lookupTask( taskId );

      // Get the data using XML facade
      Element rsElement = (Element) task.getAttachment();
      FlightConfirmationType fc =
         FlightConfirmationTypeFactory.createFacade(rsElement);
      String flightNo = fc.getFlightNo();
      String travelClass = fc.getTravelClass();
      float price = fc.getPrice();
      boolean approved = fc.getApproved();
%>
...

We display the ticket data in a form and allow the user to edit the approved field. The form is linked to the third JSP:

...
      <h1>Travel Ticket Approval User Task</h1>

      <form action="confirmTicket.jsp" method="POST">

         <!-- The task ID is passed from page to page -->
         <input type="hidden" name="taskId" value="<%=taskId%>" />

         <table>
            <tr>
               <td>Flight number</td>
               <td><%= flightNo %></td>
            </tr>
            <tr>
               <td>Travel class</td>
               <td><%= travelClass %></td>
            </tr>
            <tr>
               <td>Price</td>
               <td><%= price %></td>
            </tr>
            <tr>
               <td>Approved</td>
               <td>
                  <input type="text" name="approved" value="<%= approved %>"/>
               </td>
            </tr>
         </table>

         <input type="submit" alt="Confirm Ticket" value="Confirm Ticket"/>
      </form>

      <%
         }
      %>

   </body>

</html>

Ticket Confirmation

In the third JSP we set the user input regarding the ticket approval. We again use the XML façade. Then we notify the Task Manager that the user task is completed. The Task Manager will invoke the callback to the BPEL process:

<%@ page import="java.util.*" %>
<%@ page import="org.w3c.dom.Element" %>
<%@ page import="com.oracle.bpel.client.Locator" %>
<%@ page import="com.oracle.services.bpel.task.ITask" %>
<%@ page import="com.oracle.services.bpel.task.IWorklistService" %>
<%@ page import="com.packtpub.service.airline.FlightConfirmationType" %>
<%@ page import="com.packtpub.service.airline.FlightConfirmationTypeFactory"
%>

<html>
   <head>
      <meta http-equiv="PRAGMA" content="NO-CACHE" />
      <meta http-equiv="EXPIRES" content="-1" />
   </head>
   <body>
   <h1>Travel Ticket Approval User Task</h1>
<%
      String taskId = request.getParameter( "taskId" );
      if( taskId == null || "".equals( taskId ) )
      {
%>
      <a href="displayTasks.jsp">List of BPEL Travel process tasks to
         approve.</a>
<%
      }
      else
      {
         // Connect to the default BPEL domain using Locator
         // Please set the password (bpel is initial password)
         Locator locator = new Locator( "default", "bpel" );

         // Lookup the worklist service
         IWorklistService worklist =
            (IWorklistService)locator.lookupService
            (IWorklistService.SERVICE_NAME);

      // Lookup the specific task the user has selected
      ITask task = worklist.lookupTask( taskId );

      // Set the approved field using XML facade
      Element rsElement = (Element) task.getAttachment();
      FlightConfirmationType fc =
         FlightConfirmationTypeFactory.createFacade(rsElement);
      if ((request.getParameter("approved")).equalsIgnoreCase("true")) {
         fc.setApproved(true);
      } else {
         fc.setApproved(false);
      }

      // Update the attachment so that it reflects the user changes
      task.setAttachment(fc.getRootElement());

      // Complete the task to activate the callback
      worklist.completeTask(task);

      out.println("Ticket approved status: "+fc.getApproved()+".");
   }
%>
   </body>
</html>

Go to page: Prev  1  2  3  4  5  6  7  8  9  10  11  12  13  Next

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed






internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers