I am using camunda 7.4 in order to recursively generate a bpmn model in eclipse. Though I have succeed in creating and writing a BPMN model in 7.1 alpha, in 7.4 there is new information added that prevents me from continuing with this work. If you could provide an example of correct usage I would be really grateful.
I provide the 7.1 source code that works (I guess it works because it passes through the validate method):
flownoderef = createElement(lane1, "endref", FlowNodeRef.class);
endEvent = createElement(process, "end", EndEvent.class);
flownoderef.setTextContent("end");
endEventShape = modelInstance.newInstance(BpmnShape.class);
endEventShape.setId("endShape");
endEventShape.setBpmnElement(endEvent);
processPlane.getDiagramElements().add(endEventShape);
//usertask created through recursion that acts as the previous node
BpmnModelElementInstance task2 = createProcessrecursively(formulas.get(leftHandSide), process, (BpmnModelElementInstance) startEvent);
// create flows
SequenceFlow flow = createSequenceFlow(process, (FlowNode)task2, endEvent);
BpmnEdge flowEdge = modelInstance.newInstance(BpmnEdge.class);
flowEdge.setId("flowEdge");
flowEdge.setBpmnElement(flow);
flowEdge.setSourceElement(previousshape);
flowEdge.setTargetElement(endEventShape);
processPlane.getDiagramElements().add(flowEdge);
Bounds endEventBounds = modelInstance.newInstance(Bounds.class);
endEventBounds.setHeight(36.0);
endEventBounds.setWidth(36.0);
endEventBounds.setX(xaxis+70.0);
xaxis=xaxis+70.0;
endEventBounds.setY(yaxis+70.0);
yaxis=yaxis+70.0;
endEventShape.setBounds(endEventBounds);
This is the 7.4 source code that throws this exception: "Caused by: org.xml.sax.SAXParseException; cvc-complex-type.4: Attribute 'x' must appear on element 'di:waypoint'." With comments are some things that I have tried but failed in creating a correct BpmnEdge:
// flownoderef = createElement(lane1, "endref", FlowNodeRef.class);
endEvent = createElement(process, "end", EndEvent.class);
// flownoderef.setTextContent("end");
endEventShape = modelInstance.newInstance(BpmnShape.class);
endEventShape.setId("endShape");
endEventShape.setBpmnElement(endEvent);
processPlane.getDiagramElements().add(endEventShape);
Bounds endEventBounds = modelInstance.newInstance(Bounds.class);
endEventBounds.setHeight(36.0);
endEventBounds.setWidth(36.0);
endEventBounds.setX(96.0);
xaxis=xaxis+70.0;
endEventBounds.setY(16.0);
yaxis=yaxis+70.0;
endEventShape.setBounds(endEventBounds);
//create process Time for recursion
// BpmnModelElementInstance task2 = createProcessrecursively(formulas.get(leftHandSide), process, (BpmnModelElementInstance) startEvent);
// create flows
SequenceFlow flow = createSequenceFlow(process, startEvent, endEvent);
//processPlane.addChildElement(flow);
Extension extention = modelInstance.newInstance(Extension.class);
Waypoint waypoint = modelInstance.newInstance(Waypoint.class);
//Attribute x = modelInstance.newInstance((Class<T>) Attribute.class);
//waypoint.getAttributeValue("x");
waypoint.setAttributeValue("x", "40");
//waypoint.getAttributeValue("x");
//waypoint.setX(40.0);
waypoint.setAttributeValue("y", "40");
// waypoint.getAttributeValue("y");
//waypoint.setY(40.0);
Waypoint waypoint2 = modelInstance.newInstance(Waypoint.class);
// waypoint.setAttributeValue("x", "x");
waypoint.getElementType();
waypoint.setAttributeValue("x", "40");
//waypoint.getAttributeValue("x");
//waypoint.setX(146.0);
waypoint.setAttributeValue("y", "40");
//waypoint.setX("40.0");
//waypoint.getAttributeValue("y");
//waypoint.setY(40.0);
// waypoint.addChildElement(startEvent);
BpmnEdge flowEdge = modelInstance.newInstance(BpmnEdge.class);
flowEdge.setId("flowEdge");
flowEdge.setBpmnElement(flow);
flowEdge.setSourceElement(startEventShape);
flowEdge.setTargetElement(endEventShape);
flowEdge.getParentElement();
flowEdge.setExtension(extention);
flowEdge.getWaypoints().add(waypoint);
flowEdge.getWaypoints().add(waypoint2);
processPlane.addChildElement(extention);
processPlane.addChildElement(flowEdge);
//flowEdge.getWaypoints();
// processPlane.addChildElement(flowEdge);
//bpmnDiagram.setUniqueChildElementByNameNs(flowEdge);
//processPlane.setUniqueChildElementByNameNs(flowEdge);
//processPlane.getDiagramElements().add(flowEdge);
I hope I do not give you a lot of trouble but since I have not found any examples of correct BpmnEdge and Waypoint creation and just trying to reverse engineer bpmn models it has become a difficult riddle to pass through the validate method unscathed and write my updated bpmn model.
I hope that you can provide me with an early answer.