Querying the Tasks

The methods getTasksAssignedAsPotentialOwner and getTasksOwned can be used to perform basic searches of the Tasks which are in charge for one particular user. Should you need a more complex search over the Task List you can use the query method of the TaskClient Api.

 

When using the query method of the TaskClient, you can issue queries using the Hibernate QL on the mapped entities

 

Using the query method requires a few parameters

 

public void query(String qlString,
     Integer size,
     Integer offset,
     QueryGenericResponseHandler responseHandler)

 

The qlString parameter is the Hibernate query

The size contains the total size of the elements retrieved

The offset is the initial offset (which can be used for paginating the data)

The responseHandler will hold the Resultset retrieved by the query.

 

Here's an example which returns all the Tasks whose name is "task1":


BlockingQueryGenericResponseHandler  responseHandler =
                new BlockingQueryGenericResponseHandler(); 

client.query("select count(t) from Task t left join t.names as name where name.text = 'Task1'",
                Integer.MAX_VALUE, 0,responseHandler);
           
List  tasks = responseHandler.getResults();

Here's another which returns a collection of Tasks, which are created by user "john" and are in status "Ready" or "Reserved":


BlockingQueryGenericResponseHandler  responseHandler =
                 new BlockingQueryGenericResponseHandler();

client.query(" from Task t where t.taskData.createdBy.id = 'john' and t.taskData.status in ('Ready', 'Reserved')",
            Integer.MAX_VALUE, 0,responseHandler);

List  tasks = responseHandler.getResults();

If you want to check the other properties of the org.jbpm.task.Task class you can have a look at GitHub repository:

0
0
0
s2smodern