cancel
Showing results for 
Search instead for 
Did you mean: 

Complete (including subprocesses) process history

mlegnani
Champ in-the-making
Champ in-the-making
I'm trying to implement what I suppose to be a very simple and common functionality for my application: the complete (including subprocesses) process history of a process that is not completed. This could be very useful to the user, making him understand what happened before.

I'm realizing that its very difficult to implement since:
    * there is no way to obtain the processInstanceId of a completed subprocess (while the parent process is still alive) from the callActivity that generated it from the API;
    * I then looked the DB schema trying to implement that functionality by myself but I discovered that such data is not kept in activiti tables. Once completed the subprocess is removed from runtime tables and remains only in history tables but act_ru_execution has a super_exec_ field allowing to know which is the parent, while there is no such information in any historic table (am I right?);
    * I decided to add a new custom table to keep track of the parent-child relation in historic tables, adding an executionListener to populate it on start of any subprocess but then I read on the forum http://forums.activiti.org/en/viewtopic.php?f=6&t=1353 that using API in listeners is discouraged since "You shouldn't use activiti API from within TaskListeners (nor from ExecutionListeners or JavaDelegates), this can mess up transactions.". So I can't know the parent process since I cannot use a simple line like:
    ProcessInstanc parentProcess = runtimeService.createProcessInstanceQuery().subProcessInstanceId(execution.getProcessInstanceId()).list().get(0);
    Am I right?
Does anybody have any suggestion to solve my problem?
Thanks,
Massimo
6 REPLIES 6

trademak
Star Contributor
Star Contributor
Hi,

I understand the issue. What you could do is set the process instance id of the callActivity as a process variable. With the in and out parameters construction you can provide input and output parameters for a call activity like:

<callActivity id="test" calledElement="testProcess">
  <extensionElements>
    <activiti:in source="test" target="test2" />
    <activitiSmiley Surprisedut source="test2" target="test" />
</extensionElements>
</callActivity>

Then you can easily connect the two processes.

Best regards,

campa
Champ in-the-making
Champ in-the-making
Hi guys,

I have modified activity engine, adding superProcessInstanceId to the HistoricProcessInstanceEntity .

So you can query historic process instances using syntax like:
historyService.createHistoricProcessInstanceQuery().superProcessInstanceId(ID).list();It seems working, you can find a svn diff file attached ( created using the 5.6 tag revision ) so the team can ( if it likes this feature ) insert it into next releases.

I have added a simple unit test, to test it. Tested only with H2 db, but probably it work also with others dbms …

Hoper this helps you.

Bye
Stefano
Tinvention.net

trademak
Star Contributor
Star Contributor
Hi,

The change looks good and is certainly something we can add.
Although, we also need an upgrade script like the ones you can find in activiti-engine/src/main/resources/org/activiti/db/upgrade.
If you can add those also in a diff script then I can try to integrate it into trunk.

Thanks,

campa
Champ in-the-making
Champ in-the-making
Hi,

The change looks good and is certainly something we can add.
Although, we also need an upgrade script like the ones you can find in activiti-engine/src/main/resources/org/activiti/db/upgrade.
If you can add those also in a diff script then I can try to integrate it into trunk.
Thanks,

Here the svn diff file ( from 5.6 tag ) , with upgrade files added ( but, not tested ).
Bye
Stefano
Tinvention.net

trademak
Star Contributor
Star Contributor
Hi Stefano,

I committed the patch, see JIRA issue http://jira.codehaus.org/browse/ACT-880.

Thanks,

mlegnani
Champ in-the-making
Champ in-the-making
Thanks a lot to Stefano for his excellent work. I'm using it in my project and the new feature works fine! Smiley Very Happy
Thanks again,
Massimo.