Wednesday, September 05, 2012

Displaying jBPM diagram of the current process

In large enough processes, user might need to see where in the diagram process stopped. Now jBPM console comes with this, but to actually integrate it with front end application, I had to change it slightly. Code base used was from bpm-console. First part is setting up properties with the location of your Guvnor (jbpm.console.properties):


Following is the code (you can remove static if you want):


To run everything I use JIBX to compile XSD schemas for BPMN2 (you can find them in jbpm-bpmn2-5.2.0.Final.jar). You will need to slightly modify JIBX output with extending classes to compile it, but after that it should work OK.

Before running this, you will need BPMN2 file and PNG in you resources directory (named same as process ID). In case that in the future versions of Designer positioning of the elements inside BPMN2 becomes absolute, then JIBX will not be needed as PNG you can get from Guvnor directly and source will not be parsed as positions are already in the metadata of the node. Currently, as positions are relative we need to calculate the offset to overlay the arrow correctly over PNG. Please also note that I only offset positions for the Lanes and not, for example, from the  Sub-process. You can extend this code to fit your needs.

Usage in xhtml:

And not to forget, you need to initialize JPAWorkingMemoryDbLogger and add corresponding Entities to persistence.xml (ProcessInstanceLog, NodeInstanceLog, VariableInstanceLog).

As always, if you have any suggestions, please drop me a note.

Thanks to tsurdilo for help!

6 comments:

  1. Is it possible to create the process instance active nodes diagram without guvnor.

    ReplyDelete
  2. Yes,

    You can use bpmn2 and png file as local resources. Check parameter "bpm.type" local/remote.

    Regards.

    ReplyDelete
  3. Hi Branislav,

    thanks for your post, it's very interesting.
    I would like to know if your code is compatible with jBPM 5.4

    Thanks a lot!

    Emilio

    ReplyDelete
  4. It should be possible with 5.X version with small code adjustments where needed as far as I can remember. You can copy it locally and try to compile and if there are errors you can always download source for jBPM and take a look what is different there (packages and structure).

    ReplyDelete
  5. /**
    * Gets the bPM active nodes diagram.
    *
    * @param processInstance the process instance

    Can you tell me what function is described by the above declaration.. Is it a function from the bpm-console api

    ReplyDelete
  6. Hi, can you please post your pom for displaying ActiveNode classes as there are lot of inter dependenices of jbpm classes

    ReplyDelete