bea.com | products | dev2dev | support | askBEA

Download Docs | Site Map | Glossary
Search

Programming BPM Client Apps

Managing Task Routing

Tasks can be rerouted from one role or user to another for a specified period of time.

This section describes how to manage task routing, including the following topics:

- Adding a Task Reroute

- Getting Task Reroutes

- Updating a Task Reroute

- Deleting a Task Reroute

- Example of Managing Task Routing

For more information about the methods described in this section, see the com.bea.wlpi.server.admin.Admin Javadoc. For information about managing task routing using the WebLogic Integration Studio, see "Administering Task Routings" in Administering Data in Using the WebLogic Integration Studio.

Adding a Task Reroute

To add a task reroute, use the following com.bea.wlpi.server.admin.Admin method:

>     public java.lang.String addReroute(
>       java.lang.String orgId,
>       java.lang.String from,
>       java.lang.String to,
>       int type,
>       java.sql.Timestamp effective,
>       java.sql.Timestamp expiry
>     ) throws java.rmi.RemoteException,
>       com.bea.wlpi.common.WorkflowException

The following table describes the parameters for the addReroute() method for which you must specify values.

Table 16-1 addReroute() Method Parameters

Parameter | Description | Valid Values
--- | --- | ---
orgId | ID of the organization for which you want to reroute a task. | String specifying a valid organization ID. For information about getting a list of organization IDs, see Getting All Organizations.
from | ID of the assignee (role or user) for whom you want to reroute a task. | String specifying a valid role or user. For information about getting a list of current users or roles, see Configuring the Security Realms.
to | ID of the assignee (role or user) to whom you want to reroute a task. | String specifying a valid role or user. For information about getting a list of current users or roles, see Configuring the Security Realms.
type | Type of reroute. | Integer specifying one of the following static variable values: TYPE_USER: Reroute tasks to a user. TYPE_USERINROLE: Reroute tasks to a user in a role, using load-balancing. TYPE_ROLE: Reroute tasks to a role. The static variable values are defined as part of the com.bea.wlpi.common.RerouteInfo object:
effective | Date and time that the reroute becomes effective. | Valid java.sql.Timestamp object.
expiry | Date and time that the reroute expires. | Valid java.sql.Timestamp object.

This method returns the ID of the new reroute object.

For example, the following code adds a reroute from user joe to user mary. In this example, admin represents the EJBObject reference to the Admin EJB.

>     List rerouteId = admin.addReroute( "ORG1", "joe", "mary",
>       TYPE_USER, tsEffective, tsExpiry);

The type parameter is set to TYPE_USER, indicating that the task is being rerouted to a user. The reroute becomes effective on the date and time specified by the tsEffective timestamp and expires on the date and time specified by the tsExpiry timestamp.

For more information about the addReroute() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

Getting Task Reroutes

To get task reroutes that are defined within an organization, use the following com.bea.wlpi.server.admin.Admin method:

>     public java.util.List getReroutes(
>       java.lang.String orgId
>     ) throws java.rmi.RemoteException,
>       com.bea.wlpi.common.WorkflowException

The following table describes the parameter for the getReroutes() method for which you must specify a value.

Table 16-2 getReroutes() Method Parameter

Parameter | Description | Valid Values
--- | --- | ---
orgId | ID of the organization for which you want to get reroutes. | String specifying a valid organization ID. For information about getting a list of organization IDs, see Getting All Organizations.

Each method returns a list of com.bea.wlpi.common.TaskInfo objects. To access information about each task, use the TaskInfo object methods described in TaskInfo Object.

For example, the following code gets the rerouted tasks for the ORG1 organization. In this example, admin represents the EJBObject reference to the Admin EJB.

>     List taskList = admin.getReroutes("ORG1");

For more information about the getReroutes() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

Updating a Task Reroute

To update a task reroute, use one of the following com.bea.wlpi.server.admin.Admin methods.

Method 1

>     public void updateReroute(
>       java.lang.String rerouteId,
>       java.lang.String to,
>       int type,
>       java.sql.Timestamp effective,
>       java.sql.Timestamp expiry
>     ) throws java.rmi.RemoteException,
>       com.bea.wlpi.common.WorkflowException

Method 2

>     public void updateReroute(
>       java.lang.String rerouteId,
>       java.lang.String from,
>       java.lang.String to,
>       int type,
>       java.sql.Timestamp effective,
>       java.sql.Timestamp expiry
>     ) throws java.rmi.RemoteException,
>       com.bea.wlpi.common.WorkflowException

These methods are identical, except that in the second case, you specify the from parameter to define the assignee for whom you want to reroute a task.

The following table describes the parameters for the updateReroute() methods for which you must specify values.

Table 16-3 updateReroute() Method Parameters

Parameter | Description | Valid Values
--- | --- | ---
rerouteId | ID of the task reroute that you want to update. | String specifying a valid reroute ID. For information about getting a list of all task reroute IDs, see Getting Task Reroutes.
from | ID of the assignee (role or user) for whom you want to reroute a task. | String specifying a valid role or user. For information about getting a list of current users or roles, see Configuring the Security Realms.
to | ID of the assignee (role or user) to whom you want to reroute a task. | String specifying a valid role or user. For information about getting a list of current users or roles, see Configuring the Security Realms.
type | Type of reroute. | Integer value specifying one of the following static variable values: TYPE_USER: Reroute tasks to a user. TYPE_USERINROLE: Reroute tasks to a user in a role, using load-balancing. TYPE_ROLE: Reroute tasks to a role. The static variable values are defined as part of the com.bea.wlpi.common.RerouteInfo object:
effective | Date and time that the reroute becomes effective. | Valid java.sql.Timestamp object.
expiry | Date and time that the reroute expires. | Valid java.sql.Timestamp object.

For example, the following code updates the specified task reroute, rerouting the task from user Mary to joe. In this example, admin represents the EJBObject reference to the Admin EJB.

>     List rerouteId = admin.addReroute( "ORG1", "mary", "joe",
>       TYPE_USER, tsEffective, tsExpiry);

The type parameter is set to TYPE_USER, indicating that the task is being rerouted to a user. The reroute becomes effective starting on the date and time specified by the tsEffective timestamp and expires on the date and time specified by the tsExpiry timestamp.

For more information about the updateReroutes() methods, see the com.bea.wlpi.server.admin.Admin Javadoc.

Deleting a Task Reroute

To delete a task reroute, use the following com.bea.wlpi.server.admin.Admin method:

>     public void deleteReroute(
>       java.lang.String rerouteId
>     ) throws java.rmi.RemoteException,
>       com.bea.wlpi.common.WorkflowException

The following table describes the deleteReroute() method parameter for which you must specify a value.

Table 16-4 deleteReroute() Method Parameter

Parameter | Description | Valid Values
--- | --- | ---
rerouteId | ID of the task reroute that you want to delete. | String specifying a valid reroute ID. For information about getting a list of all task reroute IDs, see Getting Task Reroutes.

For example, the following code deletes the specified reroute. In this example, admin represents the EJBObject reference to the Admin EJB.

>     admin.deleteReroute(reroute.getId());

The reroute ID is obtained using the methods associated with the com.bea.wlpi.common.RerouteInfo object, reroute. The reroute object can be obtained using the methods described in Getting Task Reroutes.

For more information about the deleteReroute() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

Example of Managing Task Routing

This section provides excerpts from the command-line Studio example showing how to manage task routing.

Note: For more information about the command-line Studio example, see Command-Line Studio Example.

In this example, an input stream is defined to communicate with the user, and the user is prompted to specify one of the following actions to be performed:

- Adding a Task Reroute

- Deleting a Task Reroute

- Getting Task Reroutes

Important lines of code are highlighted in bold. In this example, admin represents the EJBObject reference to the Admin EJB.

>     /* Create an input stream to communicate with the user */
>     stdIn = new BufferedReader( new InputStreamReader( System.in ) );

>     /* Display Tool Title */
>     System.out.print( "\n---      Command Line Studio v1.0      ---" );

>     /* Display the main menu and interact with user */
>     while( true ) {
>     /* Display the menu */
>        System.out.println( "\n---             Main Menu            ---" );
>        System.out.println( "\nEnter choice:" );
>        System.out.println( "1) Templates" );
>        System.out.println( "2) Task Reroutes" );
>        System.out.println( "Q) Quit" );
>        System.out.print( ">> " );
>           .
>           .
>           .
>     /**
>      * Method that interacts with the user to get all the required information
>      * to illustrate the Public API Methods available in the Admin interface
>      * that are related to WLPI Task Reroutes.
>      */
>     public static void mngReroutes() {
>        int assigneeType;
>        List rerouteList;
>        RerouteInfo rerouteInfo;
>        String orgId;
>        String rerouteId;
>        String answer;
>        String fromAssignee;
>        String toAssignee;
>        Timestamp effectiveDate;
>        Timestamp expiryDate;

>        /* Create an input stream to communicate with the user */
>        BufferedReader stdIn = new BufferedReader( new InputStreamReader(
>           System.in ) );

>        try {
>           /* Display the menu and interact with user */
>           while( true ) {
>              /* Display the menu */
>              System.out.println( "\n\n---          Task Routings           ---" );
>              System.out.println( "\nEnter choice:" );
>              System.out.println( "1) Add a Task Reroute" );
>              System.out.println( "2) Delete a Task Reroute" );
>              System.out.println( "3) List all Task Reroutes" );
>              System.out.println( "B) Back to previous menu" );
>              System.out.println( "Q) Quit" );
>              System.out.print( ">> " );

>              /* Get user's selection */
>              String line = stdIn.readLine();

>              /* User pressed enter without making a selection ? */
>              if( line.equals( "" ) )
>                 continue;
>                 /* User entered more than one char ? */
>              else if( line.length() > 1 ) {
>                 System.out.println( "*** Invalid selection" );
>                 					continue;
>              }

>              /* Convert to uppercase and to char */
>              char choice = line.toUpperCase().charAt( 0 );

>              /* Process user's selection */
>              switch( choice ) {
>              .
>              .
>              .

Adding a Task Reroute

The following excerpt shows how to add a task reroute:

>              /* Add a Task Reroute */
>              case '1' :
>                 /* Get Organization ID where to add the reroute */
>                 if( ( orgId = askQuestion( "\nEnter Organization ID where to
>                    add the Reroute" ) ) == null ) {
>                    /* User cancelled the operation */
>                    System.out.println( "*** Cancelled" );
>                    break;
>                 }

>                 /* Prompt user for User ID to reroute from */
>                 if( ( fromAssignee = askQuestion( "Enter User to reroute from" ) )
>                    == null ) {
>                    /* User cancelled the operation */
>                    System.out.println( "*** Cancelled" );
>                    break;
>                 }

>                 /* Prompt user for Assignee to reroute to */
>                 if( ( toAssignee = askQuestion( "Enter Assignee to reroute to" ) )
>                    == null ) {
>                    /* User cancelled the operation */
>                    System.out.println( "*** Cancelled" );
>                    break;
>                 }

>                 /* Prompt user to determine if the assignee is a user */
>                 if( ( answer = askQuestion( "- Is this a user (y/n)?" ) ) == null ) {
>                    /* User cancelled the operation */
>                    System.out.println( "*** Cancelled" );
>                    break;
>                 }

>                 /* Parse the answer */
>                 if( answer.equals( "y" ) || answer.equals( "Y" ) )
>                    assigneeType = RerouteInfo.TYPE_USER;
>                 else {
>                    /* Prompt user to determine if the assignee is user in a role */
>                    if( ( answer = askQuestion( "- Reroute to user in role (y/n)?" )
>                       ) == null ) {
>                       /* User cancelled the operation */
>                       System.out.println( "*** Cancelled" );
>                       break;
>                    }

>                    /* Parse the answer */
>                    if( answer.equals( "y" ) || answer.equals( "Y" ) )
>                       assigneeType = RerouteInfo.TYPE_USERINROLE;
>                    else
>                       assigneeType = RerouteInfo.TYPE_ROLE;
>                 }

>                 /* Get Effective Date */
>                 /* Note: The Effective Date is a Timestamp. To keep
>                  * things simple, I have decided to deal with dates only. */
>                 if( ( answer = askQuestion( "Enter Effective Date (yyyy-mm-dd)" )
>                    ) == null ) {
>                    /* User cancelled the operation */
>                    System.out.println( "*** Cancelled" );
>                    break;
>                 }

>                 /* Convert to a timestamp */
>                 effectiveDate = Timestamp.valueOf( answer + " 0:0:0.0" );

>                 /* Get Expiry Date */
>                 /* Note: The Expiry Date is a Timestamp. To keep things simple,
>                  *       I have decided to deal with dates only. */
>                 if( ( answer = askQuestion( "Enter Expiry Date (yyyy-mm-dd)" ) )
>                    == null ) {
>                 /* User cancelled the operation */
>                    System.out.println( "*** Cancelled" );
>                    break;
>                 }

>                 /* Convert to a timestamp */
>                 expiryDate = Timestamp.valueOf( answer + " 0:0:0.0" );

>                 try {
>                    /* WLPI Public API Method */
>                    /* Add the Task Reroute */
>                    admin.addReroute( orgId, fromAssignee, toAssignee,
>                       assigneeType, effectiveDate, expiryDate );

>                    /* Success (No exception trown) */
>                    System.out.println( "- Added" );
>                 }
>                 catch( Exception e ) {
>                    System.out.println( "*** Unable to add Task Reroute" );
>                    System.err.println( e );
>                 }

>                 break;
>                 .
>                 .
>                 .

Deleting a Task Reroute

The following excerpt shows how to delete a task reroute:

>              /* Delete a Task Reroute */
>              case '2' :
>                 /* Get ID for the Task Reroute to delete */
>                 if( ( rerouteId = askQuestion( "\nEnter Task Reroute ID to delete"
>                    ) ) == null ) {
>                    /* User cancelled the operation */
>                    System.out.println( "*** Cancelled" );
>                    break;
>                 }

>                 try {
>                    /* WLPI Public API Method */
>                    /* Delete the Task Reroute */
>                    admin.deleteReroute( rerouteId );

>                    /* Success (No exception trown) */
>                    System.out.println( "- Deleted" );
>                 }
>                 catch( Exception e ) {
>                    System.out.println( "*** Unable to delete Task Reroute" );
>                    System.err.println( e );
>                 }
>                 break;

Getting Task Reroutes

The following excerpt shows how to get tasks routes:

>              /* List all Task Reroutes */
>              case '3' :
>                 /* Get Organization ID for the organization to query */
>                 if( ( orgId = askQuestion( "\nEnter Organization ID to list Task
>                    Reroutes" ) ) == null ) {
>                    /* User cancelled the operation */
>                    System.out.println( "*** Cancelled" );
>                    break;
>                 }
>                 try {
>                    /* WLPI Public API Method */
>                    /* Retrieve all Task Reroutes */
>                    rerouteList = admin.getReroutes( orgId );

>                    /* Any Task Reroutes defined ? */
>                    if( rerouteList.size() == 0 )
>                       System.out.println( "\nNo Task Reroute defined" );
>                    else
>                       System.out.println( "\nDefined Task Reroutes:" );

>                    /* Process the list to display Task Reroutes and attributes */
>                    for( int i = 0; i < rerouteList.size(); i++ ) {
>                       /* Retrieve an element from the list */
>                       rerouteInfo = ( RerouteInfo )rerouteList.get( i );

>                       /* WLPI Public API Method */
>                       /* Retrieve and display the task reroute ID */
>                       System.out.println( "- ID:       " + rerouteInfo.getId() );

>                       /* WLPI Public API Method */
>                       /* Retrieve and display Assignee for whom the task will be
>                        * reassigned */
>                       System.out.println( "  From user: " + rerouteInfo.getFrom() );

>                       /* Retrieve and display Assignee to whom the rerouted task
>                        * will be assigned */
>                       System.out.print( "  To" );

>                       /* WLPI Public API Method */
>                       /* Retrieve reroute type */
>                       assigneeType = rerouteInfo.getType();

>                       if( assigneeType == RerouteInfo.TYPE_ROLE )
>                          System.out.print( " role: " );
>                       else if( assigneeType == RerouteInfo.TYPE_USER )
>                          System.out.print( " user: " );
>                       else if( assigneeType == RerouteInfo.TYPE_USERINROLE )
>                          System.out.print( " user in role: " );
>                       else
>                          System.out.print( ": " );

>                       /* WLPI Public API Method */
>                       /* Retrieve and display Assignee to whom the rerouted task
>                        * will be assigned */
>                       System.out.println( rerouteInfo.getTo() );

>                       /* WLPI Public API Method */
>                       /* Retrieve and display the period when this reroute
>                        * is valid */
>                       System.out.println( "  Valid From " +
>                          rerouteInfo.getEffective().toString() +
>                          " to " + rerouteInfo.getExpiry().toString() );
>                    }
>                 }
>                 catch( Exception e ) {
>                    System.out.println( "*** Unable to retrieve Task Reroutes" );
>                    System.err.println( e );
>                 }
>                 break;
>                 .
>                 .
>                 .