bea.com | products | dev2dev | support | askBEA

Download Docs | Site Map | Glossary
Search

Programming BPM Client Apps

Using Value Objects

This section explains how to access object data using business process management (BPM) value objects. It includes the following topics:

- Introduction to Value Objects

- Creating Value Objects

- Using Value Objects to Access Object Data

- Sorting Value Objects

- Example of Using a Value Object

Introduction to Value Objects

Three BPM packages—com.bea.wlpi.common, com.bea.wlpi.common.security, and com.bea.eci.repository.helper—provide classes, or value objects, for obtaining object data at both definition and run time. For more information about each of these packages, see BPM API.

Each value object shares the following characteristics:

- Maintains various BPM server-side objects, including session EJBs (for example, templates, template definitions, and business calendars) and entity EJBs that are used internally. Also allows you to obtain data values from these objects.

- Is represented by an individual Java class, the members of which are collectively referred to as values

- Is serializable: can be exchanged between client and server

- Overrides the equals() method for testing two objects of the same type for equality, as follows:

>     public boolean equals(Object obj)

- Implements the java.lang.comparable interface for comparing two objects of the same type, as follows:

>     public int compareTo(Object obj)

- When part of a homogeneous list, a class can be searched and sorted using the following methods:

- java.util.Collection.contains(Object o)

- java.util.List.indexOf(Object o)

- java.util.Collections.sort(List list)

- java.util.Collections.sort(List list, Comparator c)

For more information about these classes, see the Sun Microsystems, Inc. Java Web site, available at the following URL:

>      http://java.sun.com

- If the natural ordering of an object (as implemented by the boolean compareTo(Object o) method) is based on the same field used by the boolean equals(Object o) method, the following method

int java.util.Collections.binarySearch(List list, Object o)

can be used for rapidly searching a list that was sorted earlier, using the java.util.Collections.sort(List list) method.

- Implement the com.bea.wlpi.common.Publishable interface, if the import and export of the object data is supported.

Note: If the importing and exporting of data is supported, the object also implements the com.bea.wlpi.common.Publishable interface. For more information, see Publishing Workflow Objects.

The following table lists the value objects that can be used to access object data.

Table 5-1 Value Objects

Use This Value Object . . . | To access . . .
--- | ---
com.bea.wlpi.common.BusinessCalendarInfo | Business calendar data
com.bea.wlpi.common.EventKeyInfo | Event key data
com.bea.wlpi.common.InstanceInfo | Workflow instance data
com.bea.wlpi.common.OrganizationInfo | Organization data
com.bea.wlpi.common.security.PermissionInfo | Permission data
com.bea.wlpi.common.RepositoryFolderHelperInfo | XML repository folder data
com.bea.eci.repository.helper.RepositoryFolderInfo | XML repository folder data
com.bea.wlpi.common.RerouteInfo | Task rerouting data
com.bea.wlpi.common.RoleInfo | Role data
com.bea.wlpi.common.RolePermissionInfo | Role permission data
com.bea.wlpi.common.TaskInfo | Workflow task data
com.bea.wlpi.common.TemplateDefinitionInfo | Template definition data
com.bea.wlpi.common.TemplateInfo | Template data
com.bea.wlpi.common.UserInfo | User data
com.bea.wlpi.common.security.UserPermissionInfo | User permission data
com.bea.wlpi.common.VariableInfo | Variable data
com.bea.wlpi.common.VersionInfo | Version number data
com.bea.wlpi.common.XMLEntityHelperInfo | XML repository entity data
com.bea.eci.repository.helper.XMLEntityInfo | XML repository entity data

Creating Value Objects

To create a value object, use the associated constructor. Each of the BPM value objects described in the table Value Objects, provides one or more constructors for creating object data. The constructors for creating value objects are described in Value Object Summary.

For example, the following code creates an OrganizationInfo object, sets the organization ID to ORG1, and assigns the resulting object to organization.

>     OrganizationInfo organization = new OrganizationInfo("ORG1");

Using Value Objects to Access Object Data

Each BPM value object described in the table Value Objects provides various methods for accessing object data. The methods for getting and setting object data for each value object are described in Value Object Summary.

For example, the following code gets the organization ID for the specified OrganizationInfo object, organization.

>     String id = getOrgId(organization);

Sorting Value Objects

As described in Introduction to Value Objects, you can sort a list of value objects that implement the java.lang.Comparable interface using sort() methods available to the java.util.Collections class, as follows:

- java.util.Collections.sort(java.util.List list)

- java.util.Collections.sort(java.util.List list, java.util.Comparator c)

The first method enables you to sort a specified list of elements into ascending order based on the natural ordering of the elements, as described for java.lang.Comparable:

>     http://java.sun.com/j2se/1.3/docs/api/java/lang/Comparable.html

The second method enables you to sort a specified list of elements using a custom comparator that sorts on keys other than the default.

Note: The com.bea.wlpi.client.common.SortTableModel class provides a set of methods for sorting the value object data within a column of a JTable by clicking the column header. For more information, see the com.bea.wlpi.client.common.SortableTableModel Javadoc.

Example of Using a Value Object

This section provides an excerpt from the command-line worklist example showing how to use a value object to access task object data. It also demonstrates the use of the TaskInfo class methods to get a task name, template definition ID, instance ID, and task ID.

The get actions are highlighted in bold.

>                 /* Any task assigned ? */
>                 if( taskList.size( ) == 0 )
>                    System.out.println( "\nNo task assigned" );
>                 else
>                    System.out.print( "\nAssigned Tasks:" );

>                 /* Process the list to display the tasks */
>                 for( int i = 0; i < taskList.size( ); i++ ) {
>                    /* Retrieve an element from the list */
>                    TaskInfo taskInfo = ( TaskInfo )taskList.get( i );

>                    /* WLPI Public API Methods */
>                    /* Retrieve and display a sub-set of available attributes */
>                    System.out.println( "\n- Name: " + taskInfo.getName( ) );
>                    System.out.println( "  Template Definition ID: " +
>                       taskInfo.getTemplateDefinitionId( ) );
>                    System.out.println( "  Workflow Instance ID: " +
>                       taskInfo.getInstanceId( ) );
>                    System.out.println( "  Task ID: " + taskInfo.getTaskId( ) );
>                    System.out.print( "  Status: " + taskInfo.getStatus( ) );

>                    /* Retrieve and display the task status */
>                    if( taskInfo.getStatus( ) == taskInfo.STATUS_PENDING )
>                       System.out.println( " (Pending)" );
>                    else if( taskInfo.getStatus( ) == taskInfo.STATUS_COMPLETE )
>                       System.out.println( " (Complete)" );
>                    else if( taskInfo.getStatus( ) == taskInfo.STATUS_OVERDUE )
>                       System.out.println( " (Overdue)" );
>                    else if( taskInfo.getStatus( ) == taskInfo.STATUS_INACTIVE )
>                       System.out.println( " (Inactive)" );
>                    else
>                       System.out.println( " (Unknown)" );
>                 }
>                 break;|
>                 .
>                 .
>                 .