<!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;">
Evaluation sample help
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/delbacca">Derek Pang</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/635655#635655">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span>I want to ask the difference between the 2 versions of the Evaluation sample project I currently have. One came default with the Eclipse installation and the other I downloaded (from </span><a class="jive-link-external-small" href="http://sourceforge.net/projects/jbpm/files/jBPM%205/jbpm-5.1.0.Final/" target="_blank">http://sourceforge.net/projects/jbpm/files/jBPM%205/jbpm-5.1.0.Final/</a><span>)</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The downloaded one doesnt seem to do anything whereas the default one creates the tasks for you to execute in the console.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>In the User task components, there scripts in the entry value field whereas theres nothing in the downloaded one. Having said that theres alot more code in the Java class file in the downloaded one, so I thought its all scripted there. But it doesnt generate the task, the code is below.</p><p>Does the top version execute the task automatically through code?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>downloaded version. - nothign in the user task component</p><p>----------------------------------------------</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>package org.jbpm.examples.evaluation;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import java.util.ArrayList;</p><p>import java.util.HashMap;</p><p>import java.util.List;</p><p>import java.util.Map;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.drools.KnowledgeBase;</p><p>import org.drools.SystemEventListenerFactory;</p><p>import org.drools.builder.KnowledgeBuilder;</p><p>import org.drools.builder.KnowledgeBuilderFactory;</p><p>import org.drools.builder.ResourceType;</p><p>import org.drools.io.ResourceFactory;</p><p>import org.drools.logger.KnowledgeRuntimeLogger;</p><p>import org.drools.logger.KnowledgeRuntimeLoggerFactory;</p><p>import org.drools.runtime.StatefulKnowledgeSession;</p><p>import org.jbpm.process.workitem.wsht.WSHumanTaskHandler;</p><p>import org.jbpm.task.query.TaskSummary;</p><p>import org.jbpm.task.service.TaskClient;</p><p>import org.jbpm.task.service.mina.MinaTaskClientConnector;</p><p>import org.jbpm.task.service.mina.MinaTaskClientHandler;</p><p>import org.jbpm.task.service.responsehandlers.BlockingTaskOperationResponseHandler;</p><p>import org.jbpm.task.service.responsehandlers.BlockingTaskSummaryResponseHandler;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>/**</p><p> * This is a sample file to launch a process.</p><p> */</p><p>public class EvaluationExample2 {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    public static final void main(String[] args) {</p><p>        try {</p><p>            // load up the knowledge base</p><p>            KnowledgeBase kbase = readKnowledgeBase();</p><p>            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();</p><p>            KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);</p><p>            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());</p><p>            // start a new process instance</p><p>            Map<String, Object> params = new HashMap<String, Object>();</p><p>            params.put("employee", "krisv");</p><p>            params.put("reason", "Yearly performance evaluation");</p><p>            ksession.startProcess("com.sample.evaluation", params);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>            SystemEventListenerFactory.setSystemEventListener(new SystemEventListener());</p><p>            TaskClient taskClient = new TaskClient(new MinaTaskClientConnector("MinaConnector",</p><p>                new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));</p><p>            taskClient.connect("127.0.0.1", 9123);</p><p>            Thread.sleep(1000);</p><p>            </p><p>            // "krisv" executes his own performance evaluation</p><p>            BlockingTaskSummaryResponseHandler taskSummaryHandler = new BlockingTaskSummaryResponseHandler();</p><p>            taskClient.getTasksAssignedAsPotentialOwner("krisv", "en-UK", taskSummaryHandler);</p><p>            TaskSummary task1 = taskSummaryHandler.getResults().get(0);</p><p>            System.out.println("Krisv executing task " + task1.getName() + "(" + task1.getId() + ": " + task1.getDescription() + ")");</p><p>            BlockingTaskOperationResponseHandler taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.start(task1.getId(), "krisv", taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.complete(task1.getId(), "krisv", null, taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            Thread.sleep(1000);</p><p>            </p><p>            // "john", part of the "PM" group, executes a performance evaluation</p><p>            taskSummaryHandler = new BlockingTaskSummaryResponseHandler();</p><p>            List<String> groups = new ArrayList<String>();</p><p>            groups.add("PM");</p><p>            taskClient.getTasksAssignedAsPotentialOwner("john", groups, "en-UK", taskSummaryHandler);</p><p>            TaskSummary task2 = taskSummaryHandler.getResults().get(0);</p><p>            System.out.println("John executing task " + task2.getName() + "(" + task2.getId() + ": " + task2.getDescription() + ")");</p><p>            taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.claim(task2.getId(), "john", groups, taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.start(task2.getId(), "john", taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.complete(task2.getId(), "john", null, taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            Thread.sleep(1000);</p><p>            </p><p>            // "mary", part of the "HR" group, delegates a performance evaluation</p><p>            taskSummaryHandler = new BlockingTaskSummaryResponseHandler();</p><p>            groups = new ArrayList<String>();</p><p>            groups.add("HR");</p><p>            taskClient.getTasksAssignedAsPotentialOwner("mary", groups, "en-UK", taskSummaryHandler);</p><p>            TaskSummary task3 = taskSummaryHandler.getResults().get(0);</p><p>            System.out.println("Mary delegating task " + task3.getName() + "(" + task3.getId() + ": " + task3.getDescription() + ") to krisv");</p><p>            taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.claim(task3.getId(), "mary", groups, taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.delegate(task3.getId(), "mary", "krisv", taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            </p><p>            // "administrator" delegates the task back to mary</p><p>            System.out.println("Administrator delegating task back to mary");</p><p>            taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.delegate(task3.getId(), "Administrator", "mary", taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            </p><p>            // mary executing the task</p><p>            taskSummaryHandler = new BlockingTaskSummaryResponseHandler();</p><p>            taskClient.getTasksAssignedAsPotentialOwner("mary", "en-UK", taskSummaryHandler);</p><p>            TaskSummary task3b = taskSummaryHandler.getResults().get(0);</p><p>            System.out.println("Mary executing task " + task3b.getName() + "(" + task3b.getId() + ": " + task3b.getDescription() + ")");</p><p>            taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.start(task3b.getId(), "mary", taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            taskOperationHandler = new BlockingTaskOperationResponseHandler();</p><p>            taskClient.complete(task3b.getId(), "mary", null, taskOperationHandler);</p><p>            taskOperationHandler.waitTillDone(1000);</p><p>            Thread.sleep(1000);</p><p>            </p><p>            logger.close();</p><p>            System.exit(0);</p><p>        } catch (Throwable t) {</p><p>            t.printStackTrace();</p><p>        }</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    private static KnowledgeBase readKnowledgeBase() throws Exception {</p><p>        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();</p><p>        kbuilder.add(ResourceFactory.newClassPathResource("evaluation/Evaluation2.bpmn"), ResourceType.BPMN2);</p><p>        return kbuilder.newKnowledgeBase();</p><p>    }</p><p>    </p><p>    private static class SystemEventListener implements org.drools.SystemEventListener {</p><p>        public void debug(String arg0) {</p><p>        }</p><p>        public void debug(String arg0, Object arg1) {</p><p>        }</p><p>        public void exception(Throwable arg0) {</p><p>        }</p><p>        public void exception(String arg0, Throwable arg1) {</p><p>        }</p><p>        public void info(String arg0) {</p><p>        }</p><p>        public void info(String arg0, Object arg1) {</p><p>        }</p><p>        public void warning(String arg0) {</p><p>        }</p><p>        public void warning(String arg0, Object arg1) {</p><p>        }</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>the default version - less code with scripts in the user task component.</p><p>---------------------------------------</p><p>package org.jbpm.examples.evaluation;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import java.util.HashMap;</p><p>import java.util.Map;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.drools.KnowledgeBase;</p><p>import org.drools.builder.KnowledgeBuilder;</p><p>import org.drools.builder.KnowledgeBuilderFactory;</p><p>import org.drools.builder.ResourceType;</p><p>import org.drools.io.ResourceFactory;</p><p>import org.drools.logger.KnowledgeRuntimeLogger;</p><p>import org.drools.logger.KnowledgeRuntimeLoggerFactory;</p><p>import org.drools.runtime.StatefulKnowledgeSession;</p><p>import org.jbpm.process.workitem.wsht.WSHumanTaskHandler;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>public class EvaluationExample {</p><p>    </p><p>    public static final void main(String[] args) {</p><p>        try {</p><p>            // load up the knowledge base</p><p>            KnowledgeBase kbase = readKnowledgeBase();</p><p>            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();</p><p>            KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);</p><p>            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());</p><p>            // start a new process instance</p><p>            Map<String, Object> params = new HashMap<String, Object>();</p><p>            params.put("employee", "krisv");</p><p>            params.put("reason", "Yearly performance evaluation");</p><p>            ksession.startProcess("com.sample.evaluation", params);</p><p>            logger.close();</p><p>        } catch (Throwable t) {</p><p>            t.printStackTrace();</p><p>        }</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    private static KnowledgeBase readKnowledgeBase() throws Exception {</p><p>        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();</p><p>        kbuilder.add(ResourceFactory.newClassPathResource("evaluation/Evaluation.bpmn"), ResourceType.BPMN2);</p><p>        return kbuilder.newKnowledgeBase();</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p></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/635655#635655">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>