Here is the code snippet I am writing to generate simple .bpmn file
public void testDynamicDeploy() throws Exception {
BpmnModel model = new BpmnModel();
Process process = new Process();
model.addProcess(process);
process.setId("process");
process.addFlowElement(createStartEvent());
process.addFlowElement(createUserTask("task1", "First task", "fred"));
process.addFlowElement(createUserTask("task2", "Second task", "john"));
process.addFlowElement(createEndEvent());
process.addFlowElement(createSequenceFlow("start", "task1"));
process.addFlowElement(createSequenceFlow("task1", "task2"));
process.addFlowElement(createSequenceFlow("task2", "end"));
Pool newPool = ActivitiElements.createPool("LMS", "LMS1");
newPool.setProcessRef(process.getId());
Lane lane = ActivitiElements.createLane("Booking1", "Booking");
lane.getFlowReferences().add("start");
lane.getFlowReferences().add("task1");
lane.getFlowReferences().add("task3");
lane.getFlowReferences().add("end");
lane.setParentProcess(process);
process.getLanes().add(lane);
model.getPools().add(newPool);
new BpmnAutoLayout(model).execute();
byte[] xml = new BpmnXMLConverter().convertToXML(model);
FileUtils.writeByteArrayToFile(targetFile, xml);
}
The Output file contents are:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<collaboration id="Collaboration">
<participant id="LMS" name="LMS1" processRef="process"></participant>
</collaboration>
<process id="process" isExecutable="true">
<laneSet id="laneSet_process">
<lane id="Booking1" name="Booking">
<flowNodeRef>start</flowNodeRef>
<flowNodeRef>task1</flowNodeRef>
<flowNodeRef>task3</flowNodeRef>
<flowNodeRef>end</flowNodeRef>
</lane>
</laneSet>
<startEvent id="start"></startEvent>
<userTask id="task1" name="First task" activiti:assignee="fred"></userTask>
<userTask id="task2" name="Second task" activiti:assignee="john"></userTask>
<endEvent id="end"></endEvent>
<sequenceFlow id="sequenceFlow-4a461f4a-832b-4e7b-b7dd-cfed3465bfc4" sourceRef="start" targetRef="task1"></sequenceFlow>
<sequenceFlow id="sequenceFlow-6b1d6c76-bdc9-421e-befe-ca86eb6c347e" sourceRef="task1" targetRef="task2"></sequenceFlow>
<sequenceFlow id="sequenceFlow-fbcaae10-830b-4e47-a824-96743644c2ab" sourceRef="task2" targetRef="end"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_Collaboration">
<bpmndi:BPMNPlane bpmnElement="Collaboration" id="BPMNPlane_Collaboration">
<bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
<omgdc:Bounds height="30.0" width="30.0" x="0.0" y="15.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
<omgdc:Bounds height="30.0" width="30.0" x="380.0" y="15.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="task1" id="BPMNShape_task1">
<omgdc:Bounds height="60.0" width="100.0" x="80.0" y="0.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="task2" id="BPMNShape_task2">
<omgdc:Bounds height="60.0" width="100.0" x="230.0" y="0.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-6b1d6c76-bdc9-421e-befe-ca86eb6c347e" id="BPMNEdge_sequenceFlow-6b1d6c76-bdc9-421e-befe-ca86eb6c347e">
<omgdi:waypoint x="180.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="192.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="192.0" y="30.000000000000007"></omgdi:waypoint>
<omgdi:waypoint x="230.0" y="30.000000000000007"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-fbcaae10-830b-4e47-a824-96743644c2ab" id="BPMNEdge_sequenceFlow-fbcaae10-830b-4e47-a824-96743644c2ab">
<omgdi:waypoint x="330.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="342.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="342.0" y="30.000000000000004"></omgdi:waypoint>
<omgdi:waypoint x="380.0" y="30.000000000000004"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-4a461f4a-832b-4e7b-b7dd-cfed3465bfc4" id="BPMNEdge_sequenceFlow-4a461f4a-832b-4e7b-b7dd-cfed3465bfc4">
<omgdi:waypoint x="30.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="42.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="42.0" y="30.000000000000007"></omgdi:waypoint>
<omgdi:waypoint x="80.0" y="30.000000000000007"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
If you notice the above generated file missing <bpmndi:BPMNShape> element for
<participant id="LMS" name="LMS1" processRef="process"></participant>
And
<lane id="Booking1" name="Booking">
I checked model.getLocationMap() it contains all FlowElement GraphicInfo But participant and lane
Please help to solve this issue
Many thanks
Looking at the source for the DI Export here:
Activiti/BPMNDIExport.java at activiti-5.22.0 · Activiti/Activiti · GitHub
This is called by the BpmnXMLConverter.convertToXML() method.
I don't see any DI code to capture the pool or lane information.
Likely this was considered too difficult when given a bare BPMN model such as what you have.
Your only real option would be to overload this class and add your own pool and lane code to add these shapes.
Sorry,
Greg
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.