Creating Models Programmatically (C8)

Thanks @Zelldon

I managed to do a small test.

  • Imported the required maven dependency as below
<dependency>
	<groupId>io.camunda</groupId>
	<artifactId>zeebe-bpmn-model</artifactId>
	<version>8.0.2</version>
</dependency>
  • Code is identical to C7 code
BpmnModelInstance modelInstance;
File file;

modelInstance = 
		Bpmn.createProcess()
			.name("Example process")
			.id("example-process")
			.executable()
		.startEvent()
		.userTask()
			.name("Task 1")
			.id("ut-task1")
			.zeebeAssignee("test-user")
		.endEvent()
		.done();

file = new File("C:\\model-api-test\\example-c8-process.bpmn");

try {
	
	file.createNewFile();
	
} catch (IOException e) {

	System.out.println("Error: " + e.getMessage());
}

Bpmn.writeModelToFile(file, modelInstance);
4 Likes