Hi,
I have a situation where I need to display multiple work queues based on the attribute of input object. Assume a situation where I have process input variable namely “Claim” and “status” as the attribute of the “Claim” object. Now that “status” attribute will have multiple values like “processed”, “in-progress”, “opinions” etc… I am going to define one work queue for each state of the “Claim” object.
I have some default workqueues needed(for ex: “processed”, “in-progress” like that). So I thought of creating filters while staring up the camunda springboot and associate criteria from Java api for those filters. I am not able to get how to do that.
You could take a look at the DemoDataGenerator of the invoice process.
Tryout something like that in your SpringBootApplication:
@Autowired
private TaskService taskService;
@Autowired
private FilterService filterService;
@PostConstruct
public void createFilters() {
Map<String, Object> filterProperties = new HashMap<String, Object>();
filterProperties.put("description", "All Tasks with State X");
//You could use that for ordering
filterProperties.put("priority", -10);
//you can add more variables that can be used for display. (method is from DemoDataGenerator)
addVariables(filterProperties);
// Here you can create the task filter.
//Take a look at the taskService - you have lot a more possibilities
TaskQuery query = taskService.createTaskQuery().processVariableValueEquals("variable", "value");
Filter myTasksFilter = filterService.newTaskFilter().setName("My Tasks").setProperties(filterProperties).setOwner("demo").setQuery(query);
filterService.saveFilter(myTasksFilter);
//Do the same for every filter
}
protected void addVariables(Map<String, Object> filterProperties) {
List<Object> variables = new ArrayList<Object>();
//example process variables
addVariable(variables, "amount", "Invoice Amount");
addVariable(variables, "invoiceNumber", "Invoice Number");
filterProperties.put("variables", variables);
}
protected void addVariable(List<Object> variables, String name, String label) {
Map<String, String> variable = new HashMap<String, String>();
variable.put("name", name);
variable.put("label", label);
variables.add(variable);
}
Hi @dominikh,
Thank you very much. Will try this and will update you.
Here are some questions in this context.
Can I use the “Claim” Object from the task input variable, in my filter?
taskService.createTaskQuery().processVariableValueEquals("status", "processed");
instead of using the variable namely “status”, can I use claimobj.status… someting like this? I do not see any such provision in the task list app.
2. How can I define the assignee as logged in user for the filter from Java Api? This serves the purpose of “myFilter”, which is one of the common filters in my application.
3. To get the specific filter, I need to fetch the ID of the filter based on the name looping through the filter list, then I need to call the Filter Rest Api to get the details of that filter. is there a better way to do this?
4. If I need to display the contents of the filer as claimNumber, ClaimStatus etc… which are essentially attributes of the “claim” input object of the task, how can I do that?
Haven’t done that before. Don’t think that it is possible. Maybe you can provide the xml of your process. Or someone from Camunda can answer that? @thorben
If you want to query the tasks of the current user you can use .taskAssigneeExpression("${currentUser()}"); Therefore you have to turn on authentication, because it uses the identityService. taskService.createTaskQuery().taskVariableValueEquals("status", "processed").taskAssigneeExpression("${currentUser()}");
if I understand you correctly you do know the name of the filter that you have created. So you can query that via REST API http://localhost:8080/engine-rest/filter?name=NameOfTheFilter
After that you have to execute the filter http://localhost:8080/engine-rest/{id}/singleResult
If you don’t know the id it isn’t possible to execute it directly. However you could provide an own REST CALL for that.
Same as 1. With complex objects it is getting more difficult.
Hi @dominikh,
Thank you very much for the quick response. As you said point 2 and 3 are clear. Possibly point 1 might not be a best fit for the Filter. I might have to have my own rest service something like the following.
@GetMapping(value = "/inprogressclaims")
public List<ClaimRow> getInprogressClaims() {
List<Task> tasklist = processEngine.getTaskService()
.createTaskQuery().processVariableValueEquals("status", "inprogress").orderByTaskCreateTime().desc().list();
if (!CollectionUtils.isEmpty(tasklist)) {
//Here prepare the workqueue with the required attributes from ClaimObj
return prepareWorkqueueBeanList(tasklist);
}
return new ArrayList<>();
}