Create TaskDto from FlowNode


#1

Hi

How can I create TaskDto (“org.camunda.bpm.engine.rest.dto.task”) from a FlowNode (“org.camunda.bpm.model.bpmn.instance”)

Thanks


#2

Hi @inconnu,

The TaskDto class is a data transfer object for the Rest API. The TaskEntity is usually used to create Tasks.

Can you elaborate a bit more on what you want to do?

Best,
Nikola


#3

hi,
the idea is to expose a web service REST that allows to return a Map <TaskTdo, Set '<‘TaskDto’>> in the key is a TaskDto and value their list of the next taskTdo. So from processId I created a Map <FlowNode, Set '<‘FlowNode’>> and my question how can I convert a FlowNode to a TaskDto
thanks


#4

Hi @inconnu,

I’m not sure that I completely understand what you’re trying to do. In order to create a TaskDto, you first need to obtain the TaskEntity. TaskEntities are associated with Executions, and Executions with Activities, which in turn are mapped to FlowNodes. This is pretty high level, but I think it should point you in the right direction.

Best,
Nikola


#5

Hi @nikola.koevski

I would develop a REST client which allows to expose the list of the next Tasks for each Task.
From BpmnModelInstance I have determined the list of the next FlowNode by FlowNode.
And now I need to convert this list as a DTO and expose it to JSON format.

Thanks.


#6

Hi inconnu,

Could you elaborate on the problem you are actually trying to solve? Your approach seems like an anti-pattern that will lead to trouble … so if you take one step back and tell us what you want to achieve there might be other options.

Just a guess: Do you try to run a wizard-like screen flow?

and: welcome to the forum!
Jan


#7

Hi

Below my method

import org.camunda.bpm.model.bpmn.instance.Task

@GetMapping(value = "/{processId}/nodesMap")
public ResponseEntity<Map<Task, Set<Task>>> prepareMapElement(@PathVariable(value = "processId") String processId) {
	BpmnModelInstance modelInstance = camundaService.getRepositoryService().getBpmnModelInstance(processId);
	Map<Task, Set<Task>> nodesMap = new HashMap<Task, Set<Task>>();
	Collection<Task> nodes = modelInstance.getModelElementsByType(Task.class);
	Set<Task> tasks;
	for (Task task : nodes) {
		tasks = new HashSet<Task>();
		nextFlowsNodes(task, tasks);
		nodesMap.put(task, tasks);
	}
	/*to convert nodesMap elements*/
	return new ResponseEntity<Map<Task, Set<Task>>>(nodesMap, HttpStatus.OK);
}

so the idea is to convert “org.camunda.bpm.model.bpmn.instance.Task” to TaskDto to be able to display the result in JSON format

Thanks