Creating process definition - flowable java code snippet required

I want to create bpmn process file pragmatically by using flowable source code
I have put the flowable dependent jar file in our application class path.

our requirement is,in our web application we have to create process definition and deploy the bpmn file using flowable-rest api .

firstly i want to create some tasks and multiple exclusive gateways in the process definition.

Please send me the code snippet to use the existing flowable code to generate xml file for the same

Hi,

So you already have the BpmnModel code that creates the tasks?
Something like this would work for that purpose:

Process process = new Process();
StartEvent startEvent = new StartEvent();
startEvent.setId(“start”);
process.addFlowElement(startEvent);
UserTask task1 = new UserTask();
task1.setId(“task1”);
process.addFlowElement(task1);
SequenceFlow flow1 = new SequenceFlow();
flow1.setSourceRef(“start”);
flow1.setTargetRef("task1);
process.addFlowElement(flow1);

BpmnModel bpmnModel = new BpmnModel();
bpmnModel.addProcess(process);

BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
xmlConverter.convertToXML(bpmnModel);

Best regards,

Tijs

How can i will add flow condition if its approved/reject

You can set a conditionExpression on a Sequenceflow instance. The expression could be something like ${approved}, where approved is a process variable.

Hi,
In the above case, will the BPMN model be created with BPMNDiagram, or should I create it manually?
Thanks.

If you create a model using a visual tool like the Flowable Modeler, the BPMNDiagram information will be created automatically. Otherwise, you’d have to do it yourself.