How to access initialized BDM variables in Bonita BPM from java code using Bonita Engine API.

1
0
-1

Need to access initialized BDM variables in Bonita 7.3.0 BPM from my java code using Engine API.

Following is the code that I have implemented:

                        loginAPI = TenantAPIAccessor.getLoginAPI();
                        session = loginAPI.login("walter.bates", "bpm");
                        processAPI = TenantAPIAccessor.getProcessAPI(session);
                        List<ProcessInstance> processes = processAPI.getProcessInstances(0, 20, ProcessInstanceCriterion.STATE_ASC);
                        for(ProcessInstance p : processes) {
                                if(p.getName().equalsIgnoreCase("My Task")) {
                                        processId = p.getId();
                                }
                        }
                        Map<String, Serializable> context = processAPI.getProcessInstanceExecutionContext(processId);
                        SimpleBusinessDataReferenceImpl procOrderStorageId = (SimpleBusinessDataReferenceImpl) context.get("procedureOrderMaster_ref");  //procedureOrderMaster is a BDM variable created in bonita
                        BusinessObjectDAOFactory daoFactory = new BusinessObjectDAOFactory();                  
                        MasterProcedureOrderDAO procedureOrderDao = daoFactory.createDAO(session, MasterProcedureOrderDAO.class);
                        MasterProcedureOrder procedureOrder = procedureOrderDao.findByPersistenceId(procOrderStorageId.getStorageId());
                        System.out.println("Procedure Order Id: "+procedureOrder.getProcId()+" Status: "+procedureOrder.getStatus());

Also added bonita-client-pojo.jar file.

Encountering ClassNotFoundException :

**org.bonitasoft.engine.bdm.BusinessObjectDaoCreationException: java.lang.ClassNotFoundException: com.company.clinivantage.MasterProcedureOrderDAOImpl
        at org.bonitasoft.engine.bdm.BusinessObjectDAOFactory.createDAO(BusinessObjectDAOFactory.java:55)**
        at spark.template.handlebars.HandlebarsTest.main(HandlebarsTest.java:79)
**Caused by: java.lang.ClassNotFoundException: com.company.clinivantage.MasterProcedureOrderDAOImpl**
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.bonitasoft.engine.bdm.BusinessObjectDAOFactory.loadClass(BusinessObjectDAOFactory.java:89)
        at org.bonitasoft.engine.bdm.BusinessObjectDAOFactory.createDAO(BusinessObjectDAOFactory.java:53)
        ... 1 more

Comments

Submitted by Sean McP on Mon, 12/26/2016 - 19:04

A Tip on displaying CODE/LOGS correctly in Posts:

Do not use the Supplied Buttons above, for some reason they refuse to work correctly, and despite bringing it to Bonitasofts attention, it's low priority.

To Show Code/Logs correctly use

< code >
your code/log
< /code >

removing the spaces to allow the showing of code/logs correctly as here:

your code/log

You should still be able to edit your post to ensure the correct formatting of the code to help us understand it easier.

Thanks and regards
Seán

1 answer

1
0
-1

As this is an external program rather than an internal Connector I suspect you have to include the necessary class file into your programs build directory.

regards
Seán

PS: If this reply answers your question, please mark as resolved.

Notifications