Skip to content

cephdon/camunda-bpmn-model

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

camunda BPMN model API

The camunda BPMN model API is a simple, lightweight Java library for parsing, creating and editing BPMN 2.0 XML files. It is licensed under the Apache 2.0 license.

Note

camunda BPMN model can be used standalone, independenly of camunda BPM platform / process engine.

Features

Fluent builder API

To easily create simple BPMN 2.0 processes we provide the fluent builder API. It supports most BPMN 2.0 elements and allows you to set attributes and add some child elements. The following process is deployable and can be executed by the camunda BPM platform.

BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("processId")
  .startEvent()
  .userTask()
  .endEvent()
  .done();

For more complex examples see the docs, the tests in ProcessBuilderTest.java or this example.

Create an empty BPMN model

You can easily create a new empty BPMN model.

BpmnModelInstance modelInstance = Bpmn.createEmptyModel();
Definitions definitions = modelInstance.newInstance(Definitions.class);
definitions.setTargetNamespace("http://camunda.org/examples");
modelInstance.setDefinitions(definitions);

Validate a BPMN model

At any time you can validate your model against the BPMN 2.0 specification.

BpmnModelInstance modelInstance = [...]
Bpmn.validateModel(modelInstance);

Creating a Process using the full API

The fluent API is usually a good choice for creating a new BPMN process. However, not all elements supported by the model are exposed through fluent builders and the fluent api may not be the appropriate API style for all usecases. In such cases, the full API can be used for creating a process model. The following code creates a simple Process as a jUnit4 test using the full API: CreateModelTest.java.

Find elements inside the model

// find element instance by ID
ModelElementInstance elementInstance = modelInstance.getModelElementById("start");

// find all elements of the type task
ModelElementType taskType = modelInstance.getModel().getType(Task.class);
Collection<ModelElementInstance> elementInstances = modelInstance.getModelElementsByType(taskType);

Save the BPMN model

The model API allows you to save your model in several ways

// create BPMN model
BpmnModelInstance modelInstance = [...]

// convert to string
String xmlString = Bpmn.convertToString(modelInstance);

// write to output stream
OutputStream outputStream = new OutputStream(...);
Bpmn.writeModelToStream(outputStream, modelInstance);

// write to file
File file = new File(...);
Bpmn.writeModelToFile(file, modelInstance);

Planned features

  • extended validation support like integrity checks for broken references

FAQ

What is BPMN 2.0?

Which Java (JRE) Version is required?

Java JRE 1.6+ is required. We test camunda BPMN model API on Oracle and IBM JVMs.

Under which License is camunda BPMN model API distributed?

Apache License 2.0.

Does this API support all BPMN 2.0 Elements?

No, but support is already quite extensive. See org.camunda.bpm.model.bpmn.instance for a list of currently supported elements.

About

BPMN model API written in Java.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%