Search code examples
javajbpmbpmn

How to create bpmn2 process flow programmatically in Eclipse?


I use the Eclipse bpmn2 plugin :

enter image description here

To modelize my workflow:

enter image description here

How can we create workflows programaticaly, in something that looks like this:

public void CreateFlow() {
    StartEvent  StartEvent1;
    EndEvent    EndEvent1;
    Task        Task1;

    StartEvent1.linkTo (Task1);
    Task1.linkTo(EndEvent1);
}

Solution

  • You can use Fluent API [1][2] to programatically create process definition. I am not sure if you can set X-Y coordinates of respective nodes, so can't confirm that importing *.BPMN file generated with this API into a BPMN designer will render properly - but it will be definitely executable.

    [1] https://github.com/kiegroup/jbpm/blob/master/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ProcessFactoryTest.java#L70

    [2] https://docs.jboss.org/jbpm/release/7.33.0.Final/jbpm-docs/html_single/#_process_fluent_api