[jBPM 4]
Is there a simple mean to differentiate the differente possible ends of a process?
For instance in the example
org.jbpm.examples.end.multiple.EndMultipleTest
that comes with the distribution, a process may have three different ends. But once the
process is ended, how can we know what end it reached?
The Unit Test only tests that the process ended correctly, not that it reached the
intended end ("ok", "bad request" or "internal server
error") that are defined in the JPDL :
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process name="EndMultiple"
xmlns="http://jbpm.org/4.0/jpdl">
|
| <start g="16,96,48,48">
| <transition to="get return code" name=""/>
| </start>
|
| <state g="96,94,111,52" name="get return code">
| <transition g="151,60:-36,11" name="200"
to="ok"/>
| <transition g=":-16,-27" name="400" to="bad
request"/>
| <transition g="151,183:-33,-32" name="500"
to="internal server error"/>
| </state>
|
| <end g="238,37,48,48" name="ok"/>
| <end g="238,98,48,48" name="bad request"/>
| <end g="240,160,48,48" name="internal server error"/>
|
| </process>
|
I did not find how to query about it with the API.
here is what I tried, in EndMultipleTest :
| public void testEndMultipleOk() {
| ProcessInstance processInstance =
executionService.startProcessInstanceByKey("EndMultiple");
| String pid = processInstance.getId();
| processInstance = executionService.signalExecutionById(pid, "200");
| assertTrue(processInstance.isEnded());
| // end of the official test
|
|
| assertEquals("ended", processInstance.getState());//state is
"ended", not "ok"
|
| //HistoryActivity
| HistoryActivityInstanceQuery historyActivityInstanceQuery =
historyService.createHistoryActivityInstanceQuery();
| historyActivityInstanceQuery.executionId(pid);
| List<HistoryActivityInstance> list = historyActivityInstanceQuery.list();
| System.out.println("list for pid size : " + list.size());
| for (HistoryActivityInstance historyActivityInstance : list) {
| System.out.println("history activity for pid: " +
historyActivityInstance.getActivityName());
| }
|
| historyActivityInstanceQuery =
historyService.createHistoryActivityInstanceQuery();
| historyActivityInstanceQuery.activityName("get return code");
| list = historyActivityInstanceQuery.list();
| System.out.println("list for \"get return code\" size : " +
list.size());
| for (HistoryActivityInstance historyActivityInstance : list) {
| System.out.println("history activity for \"get return code\": "
+ historyActivityInstance.getActivityName());
| }
|
| historyActivityInstanceQuery =
historyService.createHistoryActivityInstanceQuery();
| historyActivityInstanceQuery.activityName("ended");
| list = historyActivityInstanceQuery.list();
| System.out.println("list for \"ended\" size : " + list.size());
| for (HistoryActivityInstance historyActivityInstance : list) {
| System.out.println("history activity for \"ended\": " +
historyActivityInstance.getActivityName());
| }
|
| historyActivityInstanceQuery =
historyService.createHistoryActivityInstanceQuery();
| historyActivityInstanceQuery.activityName("ok");
| list = historyActivityInstanceQuery.list();
| System.out.println("list for \"ok\" size : " + list.size());
| for (HistoryActivityInstance historyActivityInstance : list) {
| System.out.println("history activity for \"ok\": " +
historyActivityInstance.getActivityName());
| }
|
|
| //Job
| JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pid);
| List<Job> listJobs = jobQuery.list();
| System.out.println("listJobs size : " + listJobs.size());
| for (Job job : listJobs) {
| System.out.println("job : " + job.getId());
| }
|
|
| //HistoryProcessInstance
| HistoryProcessInstanceQuery historyProcessInstanceQuery =
historyService.createHistoryProcessInstanceQuery();
| historyProcessInstanceQuery.state("ok");
| List<HistoryProcessInstance> listHPI = historyProcessInstanceQuery.list();
| System.out.println("IP list for \"ok\" size : " +
listHPI.size());
|
| historyProcessInstanceQuery = historyService.createHistoryProcessInstanceQuery();
| historyProcessInstanceQuery.state("get return code");
| listHPI = historyProcessInstanceQuery.list();
| System.out.println("IP list for \"get return code\" size : " +
listHPI.size());
|
| historyProcessInstanceQuery = historyService.createHistoryProcessInstanceQuery();
| historyProcessInstanceQuery.state("ended");
| listHPI = historyProcessInstanceQuery.list();
| System.out.println("IP list for \"ended\" size : " +
listHPI.size());
| }
|
and here the output :
anonymous wrote :
| 18:23:17,388 FIN | [BaseJbpmTestCase] === starting testEndMultipleOk
=============================
| 18:23:17,481 FIN | [ProcessDefinitionImpl] creating new execution for process
'EndMultiple'
| 18:23:17,497 FIN | [DefaultIdGenerator] generated execution id EndMultiple.20
| 18:23:17,497 FIN | [ExecuteActivity] executing activity(24150744)
| 18:23:17,497 FIN | [ExecuteActivity] executing activity(get return code)
| 18:23:17,544 FIN | [Signal] signalling activity(get return code), signalName=200
| 18:23:17,544 FIN | [ExecuteActivity] executing activity(ok)
| 18:23:17,544 FIN | [ExecutionImpl] execution[EndMultiple.20] ends with state ended
| 18:23:17,606 FIN | [DbSessionImpl] deleting process instance EndMultiple.20
| list for pid size : 1
| history activity for pid: get return code
| list for "get return code" size : 1
| history activity for "get return code": get return code
| list for "ended" size : 0
| list for "ok" size : 0
| listJobs size : 0
| IP list for "ok" size : 0
| IP list for "get return code" size : 0
| IP list for "ended" size : 1
| 18:23:17,950 FIN | [DeleteDeploymentCmd] deleting deployment 15
| 18:23:18,044 FIN | [BaseJbpmTestCase] === ending testEndMultipleOk
=============================
|
I tried a bit in all directions, but did not find a clue on how to get more precision
other than the fact that my process is in "ended" state. I have seen that I
could have "cancel" or "error" too (cf
org.jbpm.examples.end.state.EndStateTest), but I would have been interested in finding
some history about the names of the end nodes. For exemple find all process that ended
with "bad request". Is it possible with the API ?
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4252117#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...