-
1. Re: How can I get the process instance image?
abhijithumbe Mar 16, 2015 9:07 PM (in response to a_nat)Hi,
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:
- START NODE, ACTIVE TASK, PROCESSED TASK, TO BE PROCESSED TASK, END NODE
-- 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.