First Previous Next Last

Workflow Guide  

Chapter 3   Sample Workflow Application

This chapter provides an interactive demo of a sample workflow application (Issue Tracking) and a look at the application sources. It has these sections:

NOTE   This chapter assumes:

For more information    For a general introduction to workflow terminology and building a workflow application in Director, see Basic Workflow Development.

 
Top of page

About the Issue Tracking application

Issue Tracking is a sample workflow application that simulates a bug tracking system for a software development project. It consists of an issue creation and resolution process associated with three authorized users called support, dev, and qa. The issue life cycle is defined in a workflow process that specifies an activity for each user. Each activity is associated with a specific workitem (in this case a property sheet) that the user completes.

How the application works    The support user starts a new process and completes the first workitem. This workitem consists of a form where the user describes the issue, indicates whether the issue is a bug, and forwards it to the next activity. The status of the bug property determines the next workitem. If it's a bug, it goes to the dev user's workitem queue; if it's not a bug, it goes back to the support queue. If the dev user marks the bug as fixed and forwards the work, a new workitem is added to the qa user's queue. When the qa user verifies the fix, the issue is considered resolved and the process instance is complete.

Each user has a single workitem for each issue, but multiple issues can be running at the same time. The Workflow engine manages the routing of activities for each process instance. In the case of multiple instances, the user can select which workitem to access from the workitem queue.

 
Top of page

Installation and setup

Issue Tracking is packaged as a Web archive (WAR). You can use Workbench to add it as a subproject to an existing Director EAR project.

For more information    If you need help creating a Director EAR project, see the Quick Start section of Getting Started. Use the Typical setup option.

Procedure To add Issue Tracking to your EAR project:

  1. From the main menu in Workbench, select Project>Director EAR>Setup.

  2. On the first panel of the Setup Wizard, click Add.

  3. On the next panel navigate to the Issue Tracking template directory in your Director install:

    Director_install_dir/Samples

  4. Click Next. Click Yes on the popup that asks if you want to use the Samples template.

  5. On the next panel, select Issue Tracking.

    A message informs you that the install will configure your project to use the Issue Tracking resource set for the Security and Workflow subsystems. When you are finished with he application you can change the setting back to the original configuration by editing the config.xml descriptors for the Workflow and Security services and redeploying the EAR.

    For more information    For more information, see the section on binding subsystems to a resource set in the Core Development Guide.

  6. Click Yes to continue.

  7. Click Next and Finish.

    Workbench adds the Issue Tracking WAR to your EAR project and executes a build. This will take a couple of minutes, after which you should see the IssueTrackingSample at the bottom of the Navigation Pane:

    ITInstall

 
Top of section

Starting the workflow engine

The Issue Tracking application is configured for the engine to start automatically with your application server. Now take a look at the configuration setting.

Procedure To configure the workflow engine to start automatically:

  1. In Workbench, open services.xml in your EAR directory:

  2. In the Service Entries list, click Engine.

    ITServicesConf

  3. In the Startup dropdown, automatic should be selected by default. If it is not selected, select it now.

  4. Close services.xml.

 
Top of section

Deploying the application

Procedure To deploy the EAR project:

  1. Make sure your application server is running.

  2. In Workbench, open the project that contains the application WAR.

  3. Select Deploy Archive from the Project menu.

    Workbench deploys the WAR to your server. This process takes a couple of minutes. When the deployment is completed you're ready to run the application.

 
Top of section

Adding users to your server realm

To run Issue Tracking you need to add the support, dev, and qa users to your server's directory realm. The application provides a servlet for doing this.

NOTE   If you prefer, you can use your server administration tools to add the three users described in the next procedure.

Procedure To add users to your server realm using DirectoryInitServlet:

  1. Start your application server.

  2. Open a browser and open this URL in your EAR project:

    http://server name/DirectorDB/project name/IssueTracking/DirectoryInitServlet

    This executes the servlet that adds the users and returns a confirmation message in the browser. The following users are added:

    User

    Password

    support

    support

    dev

    dev

    qa

    qa

 
Top of page

Running Issue Tracking

This section provides an interactive demo of the Issue Tracking application. You will create a couple of workflow processes and complete the workitems in each one. This requires you to open three separate browsers and log in as each of the authorized workflow users as described in About the Issue Tracking application.

Procedure To log in to the application:

  1. Open a browser and navigate to Issue Tracking in your project:

    http://server name/DirectorDB/project name/IssueTracking/main

  2. Log in as:

    This displays the process start component and workitem queue for the support user:

    ITWorkitem

    The browser displays two components; the start process component on the left and a workitem queue (which is empty) on the right. Before starting a process, you need to log in as the other two users.

  3. Open two more browser instances and log in as:

    The dev and qa user pages display the workflow queue component, but not the start process component—which in this application can only be accessed by the support user. Component access is determined by a security role descriptor, described in the table in How the application was built.

  4. Resize or minimize the browsers so you can easily access each one.

 
Top of section

Starting a process

Procedure To start a workflow process:

  1. In the support workitem Start Process box, select Issue Tracking from the dropdown list.

    Note that this is the only option available. If other workflow process definitions had been defined in the WAR, they would display in this list.

  2. Click Start.

    A new workitem appears in the support user's workitem queue:

    ITSupportQueue

    Here is how each button works:

    Button

    Function

    View Item

    Opens the selected workitem.

    Unlock Item

    Unlocks a workitem. Any selected workitem is locked for the current user. This button allows an authorized user (such as an administrator) to manually unlock an item. (This button is not used in this demonstration.)

    Refresh

    Refreshes the browser to display new workitems.

 
Top of section

Completing the workitems

Procedure To complete a support user workitem:

  1. Select the workitem and click View Item.

    This displays a form for the support user to enter information about the new issue. Here is how each button works:

    Button

    Function

    Save and Forward as Closed

    Saves the workitem and closes the issue by removing the process from the queue. This button displays when the property labeled Is this issue a product bug? is set to No.

    Save and Forward to Development

    Saves the workitem and forwards it to the dev workitem queue. This button displays when the property labeled Is this issue a product bug? is set to Yes.

    Save

    Saves the work without forwarding it.

    Cancel

    Cancels any changes and exits the form.

  2. Fill out the form as follows:

  3. Click Save and Forward to Development.

    Note that this item is removed from the support queue.

Procedure To start another process and complete the workitem:

  1. Click Start again in the Start Process box.

  2. Select the new workitem and click View Item.

  3. Complete the form:

  4. Click Save and Forward to Development.

Procedure To complete a dev user workitem:

  1. Activate the dev user browser.

  2. Click Refresh.

  3. The two items forwarded by the support user appear in the dev queue:

    ITDevQueue

  4. Select the first issue and click View Item.

    This opens the workitem window. It includes the data entered by the support user. Notice the button at lower left labeled Forward to QA.

  5. Click No for the bug status.

    Note that the button label changes to Forward to Support.

  6. In the Fixed in Build box, enter ABC-1.

  7. Change the bug status back to Yes and click Forward to QA.

    Note that this item is removed from the dev queue.

Procedure To complete the other dev item:

  1. Select the remaining item in the dev queue and click View Item.

  2. Click No for the bug status and enter the following in the Comments box:

    It's a feature!

  3. Click Forward to Support.

  4. Go back to the support browser and click Refresh.

    The forwarded item appears in the support queue.

Procedure To complete a qa user workitem:

  1. Activate the qa user browser.

  2. Click Refresh.

    The first item forwarded by the dev user appears in the qa queue.

  3. Select the item and click View Item.

    This opens the workitem window. It includes data entered by previous users. Notice the button at lower left labeled Save and Forward to Development. This is the process path when the fix approved status is No.

  4. Change the status to Yes and click Save and Forward as Completed.

    This closes the issue and removes the item from the qa queue.

  5. (Optional) Create other items and experiment with the application. You can close the browsers when you're finished.

 
Top of page

How the application was built

The basic components of the application are:

 
Top of section

List of application sources

Most of the application sources are in JAR files at this disk location:

project_name/IssueTrackingSample.war/WEB-INF/lib.

Here is a summary:

Application source/
location

Description

Issue Tracking Process.xml
(resource.jar)

Process definition created using the Workflow Designer.

IssueTrackSupportUsers.xml
(resource.jar)

Security role descriptor. This defines user access to the IssueTrackStartProcess component.

For more information    For information about securing components, see the chapter on role-based security in the User Management Guide.

activitypolicy.xml
(resource.jar)

Specifies the client type and source for each workitem.

IssueTrackTechSupport.jsp
(IssueTracking.war/jsp)

JSP page that defines the workitem for the support user. Uses a JavaBean called techSupportIssue.java.

IssueTrackDevelopment.
(resource.jar)

Portal component that defines the workitem for the dev user.

IssueTrackQA.jsp
(IssueTracking.war/jsp)

JSP page that defines the workitem for the qa user.

This page uses the Workflow JSP tag library.

For more information    For information, see Workflow Tag Library.

WorkflowStartProcess
(workflow-components.jar)

Workflow subsystem core component that starts a process selected by the user. Uses WorkflowStartProcessDefault.xsl.

WorkflowQueue
(workflow-components.jar)

Workflow subsystem core component that lists the available workitems for a user. Uses WorkflowQueueDefault.xsl.

LoginComponent
(portal_core_resource.jar)

Portal subsystem core component used to authenticate users.

ITCheckLogin
(resource.jar)

Component that verifies that the user has logged in to the application.

UserDisplay
(resource.jar)

Component used to display the current user for demo purposes.

 
Top of page

Defining the process

The process definition for this application was defined using the Workflow Designer, a graphical tool that allows you to lay out a workflow process. This section shows how the process is defined.

Procedure To open the process xml in the Workflow Designer:

  1. In Workbench, open Issue Tracking Process.xml in your EAR project:

    The process opens in the Workflow Designer.

  2. If necessary, use the scroll keys at the top and side of the window to center the graphic, as shown here:

ITProcess

 
Top of section

About the process

A workflow process begins and ends with a Start activity and a Finish activity, represented by the green and checkered flag icons respectively. You place activities on the Designer palette and draw links between them. There are different types of activities and links you can use. The Issue Tracking process defines three User Activities that are linked with XOR link types.

For more information    For information about using the tool, see Workflow Designer.

Procedure To look at the process properties:

Procedure To look at an activity's properties:

  1. Select the tech support activity.

    A colored border means the item is selected.

  2. Right-click and select Properties, then select the Activity tab.

    The Name property specifies a unique reference for this activity.

  3. Close the property sheet.

Procedure To look at link properties:

  1. Select the link labeled issue assigned (not the label itself).

    The color of the arrow changes to show it is selected.

  2. Right-click and select Properties, then select the Destination tab.

    Note the addressee and expression boxes.

  3. Click on the data in the Expression box.

    This displays the expression editor. Here the editor says send work to the dev user if the isbug property is true.

    The Workflow Designer does not create properties; this is done in the workitem code. However, the workitem can access a property value that is specified in the Designer. You will see how this works with the isbug property later in the chapter.

  4. Click Cancel to close the editor, but leave the properties window open.

  5. Select the link labeled cannot reproduce/need more info.

    Note that the default box is checked in the property editor. This means that this path will be followed if no other path evaluates to true.

  6. Click on the data in the Expression box.

    The expression editor says send work back to support if the isbug property is false.

  7. Close the expression editor and the property sheet.

  8. (Optional) Click other items in the editor and examine the property sheets.

    TIP   When finished, leave the process open in Workbench; you may want to look at it again in the course of the discussion that follows.

 
Top of page

Building the client

The Issue Tracking workflow client was built with a combination of Workflow subsystem core components and workitem code specific to this application. The core components are:

Each workitem uses the workflow API to interact with the workflow process. A workitem can be written as a portal component or JSP page: the IssueTracking application illustrates the use of both implementations.

 
Top of section

Client API classes

The Issue Tracking client implements classes in the com.ssssw.wf.client package. Click the class name below to access API documentation:

Class name

Used to

EboFactory

Instantiate a workflow engine delegate and a workflow context

EbiWorkflowEngineDelegate

Start an Issue Tracking process

EbiWorkitemDelegate

Define workitem properties

EbiQueueDelegate

Get workitems and forward work to the next activity

 
Top of section

About the WorkflowStartProcess component

WorkflowStartProcess is a Director core component that can be used in any workflow application. It uses methods on EbiWorkflowEngineDelegate to get a list of process definitions in the project resource set and allows the user to start a process instance.

Procedure To access the source for WorkflowStartProcess:

  1. In Workbench openWorkflowStartProcess.java from the following location:

    NOTE   The default web application name is "Portal".

  2. Take a few moments to scan the code, then navigate to this segment (50):

    NOTE   The number in parentheses is the approximate line number in the file. To turn on line numbering click View > Line Numbers on the main menu.

      // Get a list of processes
         getRequestParameters( context );
         wf_context = asWFContext( context );
      
         EbiWorkflowEngineDelegate m_engineDelegate = com.sssw.wf.client.EboFactory.getWorkflowEngineDelegate();
      
         m_doc = m_engineDelegate.getProcessDefinitions( wf_context );
                  
    
  3. Scroll down to this code (72):

      if( !isProcessListEmpty( m_doc ) ) {
          context.setContentType( EbiComponentConstants.MIME_TYPE_XMLDOM );
          context.setComponentContent( m_doc );
    

    This code sets the content type and returns the DOM as the content.

  4. Scroll back up to this code (56):

      if( m_start ) {
          m_start = false;
          // The user has asked to start a process
          m_engineDelegate.startProcess( m_processID, wf_context );
      }
    

 
Top of section

About the WorkflowQueue component

WorkflowQueue is a core component that displays a list of available workitems for a user. It queries the workflow engine and gets a list of available workitems in a running process. It displays the items in a dropdown list and gets the workitem selected by the user.

This component uses code logic that is similar to that of WorkflowStartProcess component.

Procedure To access the source for WorkflowQueue:

  1. In Workbench, openWorkflowQueue.java from the following location:

  2. Take a few moments to scan the code, then navigate to this segment (50):

      EbiQueueDelegate m_queueDelegate = com.sssw.wf.client.EboFactory.getQueueDelegate();
    
  3. Scroll down a couple of lines to this line:

      m_doc = m_queueDelegate.getWorklist( wf_context );
    
  4. Scroll down to this code (75):

      context.setContentType( EbiComponentConstants.MIME_TYPE_XMLDOM );
      context.setComponentContent( m_doc );
    
  5. Scroll down to this code:

         private void unlock( EbiContext context ) {
              try{
                  EbiQueueDelegate queue = com.sssw.wf.client.EboFactory.getQueueDelegate();
                  EbiWorkitemDelegate delegate = queue.getWorkitem( getWID( m_workitemID ), context );
                  delegate.unlock( context );
              }
              catch( Exception e ) {
                  // An exception means this user cannot unlock this item
                  m_wrongUser = true;
              }
         }
    

 
Top of section

Defining the workitem

The Issue Tracking application defines workitem properties for each workflow user. In the case of the support user, the application implements a JSP page and a supporting bean class.

Procedure To access the bean source for the support JSP page:

  1. In Workbench, open techSupportIssue.java from the following location:

You might also want to access the JSP page source to follow the code discussion.

Procedure (Optional) To access the source for the JSP page:

  1. In Workbench, open techSupportIssue.java from the following location:

  2. In the bean source navigate to this code segment (70):

      public void setWfid( String newWfid , HttpServletRequest request, HttpServletResponse response)
          {
              try {
                  m_wfid = newWfid;
                  EbiQueueDelegate queue = com.sssw.wf.client.EboFactory.getQueueDelegate();
                  com.sssw.wf.api.EbiContext WFcontext = com.sssw.wf.client.EboFactory.createEbiContext(request, response);
                  m_delegate = queue.getWorkitem( m_wfid , WFcontext);
      
              }
              catch( Exception e ) {
                  e.printStackTrace();
              }        
      
          }
      
    

    This code shows how to instantiate the basic objects you need to define workitem properties.

  3. Navigate to this code (215).

              try {
                  EbiProperty isbugProp = null;
                  EbiProperty issueidProp = null;
                  EbiProperty issuenameProp = null;
                  EbiProperty companynameProp = null;
                  EbiProperty issuedescProp = null;
                  EbiProperty commentsProp = null;
      
                  m_workitemID = request.getParameter( "wfid" ).trim();
                  m_issueid = request.getParameter("issueid").trim();
                  m_issuename = request.getParameter("issuename").trim();
                  m_companyname = request.getParameter("companyname").trim();
                  m_issuedescription = request.getParameter("issuedescription").trim();
                  m_isbug = request.getParameter("isbug").trim();
                  m_comments = request.getParameter("issuecomments").trim();   
                  //EbiWorkitemDelegate delegate = queue.getWorkitem( m_wfid, context );
      
                  if( m_delegate.hasProperty("isbug")) {
                      isbugProp = m_delegate.getProperty("isbug");
      
                      isbugProp.setPropertyValue(m_isbug);
                  }
                  else {
                      isbugProp = (EbiProperty) new EboProperty("isbug", m_isbug, EbiProperty.TYPE_BOOLEAN, false);
                  }
      ...
    
  4. Navigate to this code (280)

      m_delegate.setProperty(isbugProp, context);
      m_delegate.setProperty(issueidProp, context);
      m_delegate.setProperty(issuenameProp, context);
      m_delegate.setProperty(companynameProp, context);
      m_delegate.setProperty(issuedescProp, context);
      m_delegate.setProperty(commentsProp, context);        
    

    Locking a workitem    The lock() method locks a workitem for the current user. This prevents conflicts between multiple users authorized to access a workitem. This method must be called before the user can update the workitem.

  5. Navigate to this code (295):

      public void lockWorkitem(HttpServletRequest request, HttpServletResponse response)
          {
            try {
      
                  EbiQueueDelegate queue = com.sssw.wf.client.EboFactory.getQueueDelegate();
                  com.sssw.wf.api.EbiContext WFcontext =                 com.sssw.wf.client.EboFactory.createEbiContext(request, response); 
                  getStrings(m_delegate);
                  m_delegate.lock( WFcontext );
          
              }
            catch( Exception e ) {
                  e.printStackTrace();
              }
          }
    

    Forwarding a workitem    Each workitem calls the forward() method to forward work to the next activity in the process.

  6. Navigate to this code (320):

      private void forwardWorkitem(  EbiQueueDelegate queue ) {
              try {
                  queue.forward( m_delegate );
              }
              catch( Exception e ) {
                  e.printStackTrace();
              }
          }
      
    

 
Top of section

Binding an activity to a client

The Workflow subsystem allows you to define a client type and class association for each workitem. The client is specified as an URL in a descriptor called activitypolicy.xml.

NOTE   This file name is hard-coded and should not be changed.

Procedure To access the activity policy descriptor for Issue Tracking:

  1. In Workbench open activitypolicy.xml from the following location:

      <?xml version="1.0"?>
      <activitypolicy>
          <activity name="TechSupport">
              <client type="portal" uri="/jsp/issueTrackTechSupport.jsp">Portal</client>
          </activity>
          <activity name="Development">
              <client type="portal" uri="/main/comp/IssueTrackDevelopment">Portal</client>
          </activity>
          <activity name="QA">
              <client type="portal" uri="/jsp/issueTrackQA.jsp">Portal</client>
          </activity>
      </activitypolicy>
    

    The activity policy feature allows you to define other client types (such as a Java client) and specify its URL in this descriptor.

    For more information    For more information, see Binding activities to client types.

 
Top of page

Administering workflow

The Workflow subsystem includes core portal components for Workflow administration.

Procedure To access WorkflowAdminClient:

  1. In your browser go to the URL for WorkflowClientAdmin:

    server name/DirectorDB/project name/web application name/main/component/WorkflowAdminClient

    The Client Administration Panel displays, where you can change the status of a process and get information about process activities:

    ITAdminClient

  2. Select the Issue Tracking process from the Process Pane.

    Information about the process activities in the Activities Pane displays. An activity status can be:

    Status

    Description

    Completed

    The workitem for this activity has been completed and forwarded to the next activity

    Running

    This workitem is active and has not yet been forwarded

    Open

    There is currently no workitem for this activity

  3. With the process selected, click Terminate Process.

    This terminates this process instance.

Procedure To access WorkflowEngineAdmin:

  1. In your browser go to the URL for WorkflowClientAdmin:

    server name/DirectorDB/project name/web application name/main/component/WorkflowEngineAdmin

  2. The Engine Administration Panel displays where you can start, suspend, or shut down the engine and queue:

    ITAdminEngine

  3. Click Shutdown All.

    This shuts down the engine and queue.

  4. Click Start All to restart.

For more information    For more information about the administration components, see Workflow Administration.


    First Previous Next Last

Workflow Guide  

Copyright © 2002, SilverStream Software, LLC, a wholly owned subsidiary of Novell, Inc. All rights reserved.