<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Visualize workflow and it's current state
</h3>
<span style="margin-bottom: 10px;">
    reply from <a href="http://community.jboss.org/people/achitaley">Adwait Chitaley</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/558278#558278">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>To Eugene Dzhurinsky, HuiSheng Xu and other JBPM Users who desire to view the Current Status of a Process Instance in a Graphical Mode / PNG Image.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have received a generous assistance of Roberto Harihar from Brazil, who has developed this code in viewing the Current Status of A Process Instance Graphically.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>With the attached files and steps mentioned below, we can generate an Image of the Current Status of Process Instance. This can be integrated into our application as well.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>1) Use the attached File (jbpm_image_sample.jar) and extract it. This JAR Contains the necessary code to generate PNG Image of Current Process Instance at Runtime. This also contains the required images to generate the PNG Image.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>2) In addition to above, in the same package, create a Java Class File named <strong>Render.java</strong> and insert the following code in it:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>import</b></font> java.io.File;
<font color="navy"><b>import</b></font> java.util.List;
<font color="navy"><b>import</b></font> javax.imageio.ImageIO;
<font color="navy"><b>import</b></font> org.jbpm.api.Configuration;
<font color="navy"><b>import</b></font> org.jbpm.api.ProcessEngine;
<font color="navy"><b>import</b></font> org.jbpm.api.model.OpenExecution;
<font color="navy"><b>import</b></font> com.airsanchay.jbpm.JBPMUtilities;
<font color="navy"><b>import</b></font> org.jbpm.api.ExecutionService;
<font color="navy"><b>import</b></font> org.jbpm.api.HistoryService;
<font color="navy"><b>import</b></font> org.jbpm.api.IdentityService;
<font color="navy"><b>import</b></font> org.jbpm.api.ManagementService;
<font color="navy"><b>import</b></font> org.jbpm.api.RepositoryService;
<font color="navy"><b>import</b></font> org.jbpm.api.TaskService;
</code></pre><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> Render <font color="navy">{</font>
&#160;
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * @param args
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>void</b></font> main(String[] args) <font color="navy"><b>throws</b></font> Exception <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; String processInstanceId = <font color="red">"AIRSanchayWorkflow.1870001"</font>;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">/** if you are running as a java application - outside a j2ee container */</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ProcessEngine processEngine = <font color="navy"><b>new</b></font> Configuration().setResource(<font color="red">"jbpm.cfg.xml"</font>).buildProcessEngine();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; List historyActivities = processEngine.getHistoryService().createHistoryActivityInstanceQuery().processInstanceId(processInstanceId).list();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; RenderImage_JpdlModel jpdlModel = <font color="navy"><b>new</b></font> RenderImage_JpdlModel(JBPMUtilities.class.getResourceAsStream(<font color="red">"AIRSanchayWorkflow.jpdl.xml"</font>), historyActivities);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ImageIO.write(<font color="navy"><b>new</b></font> RenderImage_JpdlModelDrawer().draw(jpdlModel), <font color="red">"png"</font>, <font color="navy"><b>new</b></font> File(<font color="red">"/root/Desktop/myprocess.png"</font>));
&#160;&#160;&#160; <font color="navy">}</font>
<font color="navy">}</font>
</code></pre><table border="0" cellpadding="0" cellspacing="0"><tbody><tr></tr><tr><td></td></tr></tbody></table></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/558278#558278">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>