bea.com | products | dev2dev | support | askBEA |
![]() |
![]() |
|
![]() |
e-docs > WebLogic Platform > WebLogic Integration > BPM Topics > Programming BPM Client Apps > Managing Tasks |
Programming BPM Client Apps
|
Managing Tasks
Tasks are defined as part of the template definition creation process, as described in Creating a Template Definition.
This section describes how to manage tasks, including the following topics:
For more information about the methods described in this section, see the com.bea.server.admin.Admin Javadoc. For information about managing tasks using the WebLogic Integration Studio, see Defining Workflow Templates in Using the WebLogic Integration Studio.
Getting Tasks
To get a list of the tasks defined for a particular workflow template, use one of the following com.bea.wlpi.server.admin.Admin methods:
public javautil.List getTasks(
java.lang.String assigneeId,
java.lang.String orgId,
boolean role
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
public javautil.List getTasks(
java.lang.String assigneeId,
java.lang.String orgId,
boolean role,
boolean incompleteonly,
boolean sortAscending
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
The following table describes the parameters for the getTasks() method for which you must specify values.
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 a list of the tasks for the ROLE1 role (notice that the role parameter is set to true) in the ORG1 organization. In this example, admin represents the EJBObject reference to the Admin EJB. For more information about the getTasks() method, see the com.bea.wlpi.server.admin.Admin Javadoc.
List taskList = admin.getTasks("ROLE1", "ORG1", true);
Assigning a Task
To change the user or role to which a task is assigned, or to unassign a task, use the following com.bea.wlpi.server.admin.Admin methods, respectively:
public void taskAssign(
java.lang.String templateDefinitionId,
java.lang.String instanceId,
java.lang.String taskId,
java.lang.String assignTo,
boolean bRole,
boolean bLoadBalance
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
public void taskUnassign(
java.lang.String templateDefinitionId,
java.lang.String instanceId,
java.lang.String taskId
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
The following table describes the parameters required by the taskAssign() and taskUnassign() methods for which you must specify values.
The actual assignee to whom the task is assigned depends on the following:
For example, the following code assigns a task to the user joe. In this example, admin represents the EJBObject reference to the Admin EJB.
admin.taskAssign(
task.getTemplateDefinitionId(),
task.getInstanceId(),
task.getTaskId(),
"joe",
false,
false
);
The following code unassigns the same task.
admin.taskUnassign(
task.getTemplateDefinitionId(),
task.getInstanceId(),
task.getTaskId(),
"joe",
false,
false
);
The template definition, workflow instance, and task IDs are obtained using the methods associated with the com.bea.wlpi.common.TaskInfo object, task. The task object can be obtained using the methods described in Getting Tasks.
For more information about the com.bea.wlpi.common.TaskInfo methods, see TaskInfo Object, or the com.bea.wlpi.common.TaskInfo Javadoc.
For more information about the taskAssign() and taskUnassign() methods, see the com.bea.wlpi.server.admin.Admin Javadoc.
Getting Task Counts
To get the number tasks assigned to a particular user, use the following com.bea.wlpi.server.admin.Admin method:
public int[] getTaskCounts(
java.lang.String assigneeId,
java.lang.String orgId,
boolean isRole
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
The following table describes the parameters for the second getTaskCounts() method for which you must specify values.
This method returns an array of five elements, as defined in the following table.
For example, the following code gets the task counts for the current user, and stores the counts in the taskCounts[] array. In this example, admin represents the EJBObject reference to the Worklist EJB. Task counts are stored in the elements fo the taskCounts[] array. For example, taskCounts[TASKCOUNT_TOTAL] specifies the task count total, taskCounts[TASKCOUNT_PENDING] specifies the pending task count total, and so on. For more information about the getTaskCounts() method, see the com.bea.wlpi.server.admin.Admin Javadoc.
int taskCounts[] = admin.getTaskCounts("ROLE1", "ORG1", true);
Marking a Task Complete or Incomplete
To mark a task as complete (done) or incomplete (undone), use the following com.bea.wlpi.server.admin.Admin methods, respectively:
public void taskMarkDone(
java.lang.String templateDefinitionId,
java.lang.String instanceId,
java.lang.String taskId
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
public void taskUnmarkDone(
java.lang.String templateDefinitionId,
java.lang.String instanceId,
java.lang.String taskId
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
The following table describes the taskMarkDone() and taskUnmarkDone() method parameters for which you must specify values.
The taskMarkDone() method sets the task Completed value to the current date and time, and results in the sequential execution of all the actions associated with the specified task's Marked Done event. The taskMarkDone() method, however, has no effect on a task that has already been marked complete. For information about defining the Marked Done event for a task, see "Working with Nodes" in Defining Workflow Templates in Using the WebLogic Integration Studio. The taskUnmarkDone() method clears the Completed date. The method does not result in the execution of the actions associated with the specified task's Activated event. For example, the following code marks the specified task as complete, sets the Completed value to the current date and time, and executes the actions associated with the specified task's Marked Done event. In this example, admin represents the EJBObject reference to the Admin EJB. The following code marks the same task as incomplete, and clears the Completed date: The template definition, workflow instance, and task IDs are obtained using the methods associated with the com.bea.wlpi.common.TaskInfo object, task. The task object can be obtained using the methods described in Getting Tasks. For more information about the com.bea.wlpi.common.TaskInfo methods, see TaskInfo Object, or the com.bea.wlpi.common.TaskInfo Javadoc. For more information about the taskMarkDone() and taskMarkUndone() methods, see the com.bea.wlpi.server.admin.Admin Javadoc.
admin.taskMarkDone(
task.getTemplateDefinitionId(),
task.getInstanceId(),
task.getTaskId()
);admin.taskMarkUndone(
task.getTemplateDefinitionId(),
task.getInstanceId(),
task.getTaskId()
);
Setting Task Properties
To set task properties, use following com.bea.wlpi.server.admin.Admin method:
public void taskSetProperties(
java.lang.String templateDefinitionId,
java.lang.String instanceId,
java.lang.String taskId,
int priority,
boolean doneWithoutDoit,
boolean doitIfDone,
boolean unmarkDone,
boolean modify,
boolean reassign
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
The following table describes the taskSetProperties() method parameters for which you must specify values.
For example, the following code sets the default task priority to medium (1) and enables (sets to true) all other task properties. In this example, admin represents the EJBObject reference to the Admin EJB. The template definition, workflow instance, and task IDs are obtained using the methods associated with the com.bea.wlpi.common.TaskInfo object, task. The task object can be obtained using the methods described in Getting Tasks. For more information about the com.bea.wlpi.common.TaskInfo methods, see TaskInfo Object, or the com.bea.wlpi.common.TaskInfo Javadoc. For more information about the taskSetProperties() method, see the com.bea.wlpi.server.admin.Admin Javadoc.
admin.taskSetProperties(
task.getTemplateDefinitionId(),
task.getInstanceId(),
task.getTaskId(),
1,
true,
true,
true,
true,
true
);
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |