Generating process diagram from Java code

5 posts / 0 new
Last post
alexbt
Offline
Last seen: 9 months 2 days ago
Joined: 12/16/2010 - 18:09
Posts: 29
Generating process diagram from Java code

Hi folks,

My question is about generating Activiti BPMN 2.0 XML.
Based on user interaction with our UI we need:
1) Create in-memory representation of a BPMN process,
2) Out of those Java objects generate an Activiti BPMN 2.0 xml that will/can be imported into Activiti Designer for further enhancements.

The generated process will be a sequence of simple tasks, so there will be no forks/joins, splits, etc. (at least at the first stage of this module development)
E.g. startState->taskA->taskB->taskC->taskD->endState

I've looked at classes in org.activiti.engine.impl.pvm.process package and it seems I understand how to create such an in-memory process representation, but I'd prefer to get some direction from you, guys, to be on the safe side.
Moreover, I didn't find a way to generate XML representation out of Java objects.
Can you please suggest the way to make it?
It would be even better if I could add graphics related data (x and y points of a task square) to the generated XML, so that when importing it into the Activiti Designer I'd get a more or less good looking process graphic representation and not a mess of all tasks in the same place.

Thanks in advance,
Alex

ingo_ri
Offline
Last seen: 1 year 2 months ago
Joined: 02/25/2011 - 20:22
Posts: 22

In older version there was Activiti-Kickstart, a web application for building (simple) bpmn-processes from user input.

It is included in Activiti 5.6, the code is now here: http://www.jorambarrez.be/blog/2011/08/31/activiti-kickstart-moved-to-github/

After deploying the processes, the engine will generate a diagram for you. You can extract it from the database. An example is here: http://forums.activiti.org/en/viewtopic.php?f=6&t=2644

Ingo Richtsmeier

http://www.claresco.de - The BAM Experts

tiesebarrell
Offline
Last seen: 2 weeks 3 days ago
Joined: 11/09/2010 - 08:09
Posts: 426

Alternatively, you could generate a bunch of Java classes for the BPMN 2.0 schema (see the kickstart project for an example) and generate a process model in Java using those classes. Marshalling that to XML using jaxb should get you quite close to something you can import directly into Designer to edit further. That's the way I'd go. You can also mix in the BPMN Diagram Interchange model there which will allow you to transfer the basic layouting data to Designer.

Activiti Designer Developer
Follow me on Twitter: http://twitter.com/tiesebarrell

alexbt
Offline
Last seen: 9 months 2 days ago
Joined: 12/16/2010 - 18:09
Posts: 29

Tiese and ingo_ri (sorry, I don't know your real name),
Thank you for your answers.
You pointed me to code that really fits my needs.
And, of course, thanks to Joram for his code.

Alex

tiesebarrell
Offline
Last seen: 2 weeks 3 days ago
Joined: 11/09/2010 - 08:09
Posts: 426

Good to hear. Good luck!

Activiti Designer Developer
Follow me on Twitter: http://twitter.com/tiesebarrell