Hello everyone,
I’m trying to programmatically create edges between two tasks in two lanes. I already managed to get two lanes with the tasks in them, but I can’t create the edge between them.
I have a method called createEdge which is responsible for drawing the edge between to shapes. This works great if I try to create an edge between a Task and a Document (in the same lane), but it doesn’t work if I try to create an Edge between two tasks in different lanes.
private BpmnEdge createEdge(BaseElement sequenceFlow, String id, Shape source, Shape target) {
// create edge for sequence flow
BpmnEdge flowEdge = modelInstance.newInstance(BpmnEdge.class);
flowEdge.setId(id);
flowEdge.setBpmnElement(sequenceFlow);
flowEdge.setSourceElement(source);
flowEdge.setTargetElement(target);
processPlane.getDiagramElements().add(flowEdge);
// create waypoints for sequence flow edge
Waypoint startWaypoint = modelInstance.newInstance(Waypoint.class);
startWaypoint.setX(source.getBounds().getX() + source.getBounds().getWidth() / 2);
startWaypoint.setY(source.getBounds().getY() + source.getBounds().getHeight() / 2);
flowEdge.getWaypoints().add(startWaypoint);
Waypoint endWaypoint = modelInstance.newInstance(Waypoint.class);
endWaypoint.setX(target.getBounds().getX());
endWaypoint.setY(target.getBounds().getY() + source.getBounds().getHeight() / 2);
flowEdge.getWaypoints().add(endWaypoint);
return flowEdge;
}
The error I’m getting is:
org.camunda.bpm.model.xml.ModelValidationException: DOM document is not valid
, so it has something to do with this method.
If I don’t create the Edge between the tasks, I get this XML Structure, which I think is correct:
<process id="process_main" name="process">
<laneSet id="laneset_main" name="">
<lane id="lane9" name="Rolle 1">
<flowNodeRef>act23</flowNodeRef>
</lane>
<lane id="lane10" name="Rolle 2">
<flowNodeRef>act22</flowNodeRef>
</lane>
</laneSet>
<task id="act23" name="AKT 1">
<outgoing>act23-act22</outgoing>
</task>
<task id="act22" name="AKT 2">
<incoming>act23-act22</incoming>
</task>
<sequenceFlow id="act23-act22" name="" sourceRef="act23" targetRef="act22"/>
</process>
Can someone help me with this?