[BONITA 6.2.6] Accessing process data once it has been closed

Hi there,

There’s something I don’t understand with Bonita.
How can we access data or documents once the process they were saved in got closed ?

Thanks for any hints !
Regards,
Paul

Hi Paul33,

Once a case is closed/completed all information/data of the process is stored in the archived tables.

Please use associated APIs to get the history of case :
http://documentation.bonitasoft.com/get-history-case

And if you want to manipulate archived documents, associated API functions :
http://documentation.bonitasoft.com/javadoc/api/6.3/org/bonitasoft/engine/bpm/document/ArchivedDocument.html

Hopefully it helps.
Best regards,
LL

The way Bonita handle archive is a little bit tricky.

First you need to know that a process instance will go through various states : initializing, executing, finishing…

In the main database table with “live” information, you will find only one row for this process instance, with a unique unmodified id. In this row you can find the process instance status. So the row get updated each time process instance status change.

Each time status change, the information located in table with “live” data will be moved (before update) to another table with “archived” information. Each time we have a change in status we have a new insertion in “archived” table. Each of this new row inserted will generated a new unique id.

So now, how do you connect your archived data to the original id from “live” data table? Answer is that you use " source object id "

Once a process is finished, row is deleted in “live” data table and you have multiple row in “archived” data table. Rows related to a single process instance all shared the same “source object id”.

Hi there,

I have seen a function that is supposed to do exactly what I want :
processAPI.getArchivedProcessDocument(sourceObjectId)

But I tried it whith the sourceObjectId and it doesn’t work.
So I tried it with id that I found in the arch_document_mapping table and it works…

I’m sorry but I don’t understand … we’re asked to put the sourceObjectId in parameter but it works with the table id ? How can we get the id from the sourceObjectId ?

Thanks again for any help

Hi bos2013,
Thanks for the help.
I already tried it and in don’t understand why I can’t make it work.
During the process, I save its processInstanceId. Afterward, when the process has been close, i tried :

final ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI(apiSession); final ArchivedProcessInstance archivedProcessInstance = processAPI.getArchivedProcessInstance(processInstanceID); where processInstanceId is the value I saved during the process. I get a : org.bonitasoft.engine.bpm.process.ArchivedProcessInstanceNotFoundException: org.bonitasoft.engine.core.process.instance.api.exceptions.SProcessInstanceNotFoundException: Process instance with id <14009> not found I really don't understand why it doesn't work ... Has the processInstanceId changed when it was archived ?

Thanks again,
Regards,
Paul

HI Paul,

good question and I’ll be using this as reference later,

I think though in this instance “source object id” is different from processInstanceID, but what it is is another matter. I don’t know. The examples sometimes use “cross-use” words I’ve found (and processInstanceID is a favorite).

What I’ve done in the past is have a look at the actual database to figure out the real column name, there are several good H2 database viewers out there.

regards
Seán

Thanks antoine.mottier and Sean McP
I took a look at the database but i didn’t make the connexion… Indeed it’s a little bit tricky. I’ll take some time to figure out how to handle it now.