Retrieve value of business object use Bonita Engine API

1
+2
-1

Hello, i'm new Bonita, i have a case need idea for project Spring boot retrieve value on business object.

The first, i seen that how can get value of business object with add file jar entitis and DAO in link :

https://community.bonitasoft.com/questions-and-answers/access-business-d...

And it work good. But this way is very dependencies file jar export from Bonita and just static attribute for external project.

So when i need change (add, modify) business data object, i must reset bdm and build again to project, it not real for release.

Anyone have idea retrieve value of business object use Java API not dependency 2 file jar DAO and entity?.

Thanks.

1 answer

1
+1
-1

The subscription version of Bonita lets you add up to 5 "Search Keys" to a process, allowing one to attribute String data to your process instances. You can then access through the API like so:

processInstance.getStringIndex1()

Not sure if this is the intended use for Search Keys, and if you need access to the entire BDM object, non-String data, or more than 5 fields this won't work for you. In my project, each process has 1 BDM object associated with it. When I start a process, I set the value of it's StringIndex1 to the ID of my BDM object, so later I can easily find process instances by my BDM object ID's.

Ultimately, I think the correct way to access BDM data in your Java application requires you to rely on the exported dependencies from Bonita like you found. Seeing as modifying the BDM in any way completely resets it, it seems like one shouldn't really be doing it often.

Comments

Submitted by nampham97se_1390962 on Fri, 03/15/2019 - 02:51

Thank you very much for answer,

I will find other solution with rest api or customize it and currently, I use Community version :)

Can you give your contract like email or facebook, i want to direct message for support faster about problems?

And now is Bonita not suport for retrieve value in archived case? I have easy retrieved business object from open case but when it case complete, i seen fail with error:Not found reference Business name "xx" with processInstanceId "yy" althought i put direct caseId and like function of open case(true function) . That very sad when client who want to see detail a task done in my Spring boot UI. Can you have idea for it?

Thanks.

Submitted by rtumminelli_1394599 on Fri, 03/15/2019 - 16:23

How are you currently getting business objects from open cases? Are you doing something like this?

ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI(session);

Map context = processAPI.getProcessInstanceExecutionContext(processInstanceId);

SimpleBusinessDataReferenceImpl objectRef = (SimpleBusinessDataReferenceImpl) context.get("object_ref");

BusinessObjectDAOFactory daoFactory = new BusinessObjectDAOFactory();

ObjectDAO objectDao = daoFactory.createDAO(session, ObjectDAO.class);

Object object = objectDao.findByPersistenceId(objectRef.getStorageId());

(Where object is your business object).

getProcessInstanceExecutionContext is used for active processes, and getArchivedProcessInstanceExecutionContext is used for archived processes (and must be provided an archivedProcessInstanceId). From the ArchivedProcessInstanceContext, you should be able to get your business object.

Submitted by nampham97se_1390962 on Fri, 03/15/2019 - 16:59

Thanks for answer,

archivedProcessInstanceId This image is that right archivedProcessInstanceId you mean?

I have create two function with your example code. And i just fine with active task (This image test success Active task). But with archived task, i alway get error like this Image error archived task. I have try other way, search archived process -> get BDM. But still fail with error other way.

Is you have try get business object with archived?. Can you give your contract info like email or fb, twiter, etc for support, I will be very grateful :).

Submitted by rtumminelli_1394599 on Fri, 03/15/2019 - 18:09

Yes, that is a little misleading. The ID you see in the portal (41002) is not the archivedProcessInstanceId. An archived process has a rootprocessinstanceid (41002), and a separate Archive ID. I think you will have to use getArchivedProcessInstances, which will return a List of ArchivedProcessInstance.

Something like:

getArchivedProcessInstances(41002L, 0, 100);

Maybe then iterate through that list and do getArchivedProcessInstanceExecutionContext(ArchivedProcessInstance.getId()) for each.

Submitted by nampham97se_1390962 on Wed, 03/20/2019 - 03:29

Hello, today i tried example List getArchivedProcessInstaces, it give empty list but in portal i have task archived (41002). So currently i'm still choke with retrieve value in archived process mean find archived process. Any idea for solution will be help me more.
Thanks.

Notifications