1 Reply Latest reply on Mar 16, 2015 9:07 PM by Abhijit Humbe

    How can I get the process instance image?

    a_nat Newbie

      In JBPM 5 we had a rest URL to get the process instance image, though it required some scripting to get the active nodes and overlay that on the image, is there anything available on JBPM 6 to get the process instance image so that I can present it from our own UI?

        • 1. Re: How can I get the process instance image?
          Abhijit Humbe Master


          In jbpm 6 we dont have any REST API to check process image, you can open 'Enhancement' request for this. But we can capture process image using API's like as:



          -- First of all, you need to prepare the icons. I have decided to go with the following:



          -- Then you need to get ALL node names for the process, for example:


          WorkflowProcess process = (WorkflowProcess) this.processBean.getSingletonManager() .getRuntimeEngine(EmptyContext.get()).getKieSession().getKieBase().getProcess(name);

          Node[] nodes = process.getNodes();



          if you have this, you have all the node names available.


          Now, in order to differentiate between ACTIVE/PROCESSED and TO BE PROCESSED NODE you can make use of auditLogService, like this:


          List<NodeInstanceLog> nodeLog = this.processBean.getAuditLogService().findNodeInstances(pid);


          This will give you a list of ACTIVE/PROCESSED nodes for the process.


          Next step would be to sort this list, ascending by NodeInstanceId. First node will be the first processed, the last node will be actually ACTIVE node.Now you have both information available - node name and node state. Then you just need to render this image for which I have used following classes:


          import java.awt.Color;

          import java.awt.FontMetrics;

          import java.awt.Graphics;

          import java.awt.Graphics2D;

          import java.awt.geom.Rectangle2D;

          import java.awt.image.BufferedImage;


          This approach will work when we use jBPM libraries in embedded mode, but  I haven't interacted with server via rest API, therefore I can't really confirm that this is viable approach but hopefully it will help at least to some extent.