Using Filters in JavaAPI

201 views
Skip to first unread message

Ingo Richtsmeier

unread,
Jan 21, 2015, 5:42:11 AM1/21/15
to camunda-...@googlegroups.com
Hi,

we would like to use Vaadin to build the task list. How can we create and use a filter to query for tasks?

An example would be helpful how to mix the process name with the task name. 

Its missing in the JavaDoc.

Kind Regards, Ingo

thorben....@camunda.com

unread,
Jan 21, 2015, 5:52:08 AM1/21/15
to camunda-...@googlegroups.com
Hi Ingo,

What do you mean by "mix the process name with the task name"?

In the Java API, you have the FilterService which allows you to do something like this:

FilterService filterService = engine.getFilterService();
Filter newFilter = filterService.newTaskFilter("filter name");

TaskQuery taskQuery = engine.getTaskService().createTaskQuery()...;
newFilter.setQuery(taskQuery);

filterService.saveFilter(newFilter);

To execute a filter:

List<Task> filteredTasks = filterService.list("filter name");

Cheers,
Thorben

Bernd Rücker (camunda)

unread,
Jan 21, 2015, 5:53:35 AM1/21/15
to camunda-...@googlegroups.com

Hi Ingo.

 

You can use the „FilterService” – it was quite intuitive when I used it the first time… And in the webinars were a small example from Daniel – maybe that helps:

 

 

Cheers

Bernd

--
You received this message because you are subscribed to the Google Groups "camunda BPM users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/camunda-bpm-users/7f89b457-50b9-4b99-ba52-a07f0a84ea8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

image001.png

Ingo Richtsmeier

unread,
Jan 21, 2015, 6:12:31 AM1/21/15
to camunda-...@googlegroups.com
Hi Thorben,

I would like to display for each task: 

processDefinition.name, task.name, task.duedate, ... and perhaps a process variable named 'applicant'.

How will I get these attributes?

Kind Regards, Ingo

thorben....@camunda.com

unread,
Jan 21, 2015, 7:03:13 AM1/21/15
to camunda-...@googlegroups.com
Hi Ingo,

In this case you will have to make additional queries for each task. That is also what the REST API does when it fetches variables along with tasks (in fact it tries to minimize the number of variable queries by first collecting the names of all variables to fetch and then making a single query). It uses Filter.setProperties(..) and Filter.getProperties(..) to store which variables are to be fetched along with the filter. So to sum this up, the feature of fetching additional entities along with tasks is implemented on top of the Java API in the REST API and therefore not available out of the box when you directly use the Java API.

The REST API logic is implemented in [1], however the code is quite complex so I am not sure if that really helps. The fetching logic begins in the method #convertToHalTask.

Cheers,
Thorben

[1] https://github.com/camunda/camunda-bpm-platform/blob/master/engine-rest/src/main/java/org/camunda/bpm/engine/rest/sub/runtime/impl/FilterResourceImpl.java

Ingo Richtsmeier

unread,
Jan 26, 2015, 6:42:02 AM1/26/15
to camunda-...@googlegroups.com
Hi Thorben,

thanks for clarifiying. Maybe I will try to build an example how to build the logic from the rest api with the java api.

Kind Regards, Ingo
Reply all
Reply to author
Forward
0 new messages