Subprocess & BDM

1
+2
-1

Hello.

I've found no example of subprocesses that share BDM objects with the main calling process.

I've tried to define a subprocess with a BDM and a contract of the same type that the business object that should be shared from the calling process, but I've an exception at runtime. Here is the log :

org.bonitasoft.engine.core.process.instance.api.exceptions.SContractViolationException: Error while validating expected inputs: [fr.fv.WorkData@3a48f4c8 cannot be assigned to COMPLEX type]
at org.bonitasoft.engine.execution.StateBehaviors.handleCallActivity(StateBehaviors.java:540)

In the main process I set a BDM object : mainWorkData
In the subprocess I've a contract for initialization : subWorkDataInput
In the subprocess, the BDM is : subWorkData, and the initialization script is just a return of the subWorkDataInput, since the reference that is given by the main process by the contract should be used as is to set the subprocess business data.

Any example, idea or help about such cases ?

Thanks.

Regards.

Comments

Submitted by maurimolina75 on Thu, 03/03/2016 - 17:04

I have the same issue. I have an iterator on the main process that maps a contract on subprocess. The error is:

Error while validating expected inputs: [ec.gob.xxx.xxx.xxx.BOType003@fa6a5091 cannot be assigned to COMPLEX type]"

Could you solve this?

Thanks in advance.

Mauricio

Submitted by ephemeris.lappis on Fri, 03/04/2016 - 12:50

Hello.

I've found a way to pass th BDM from the main process to the sub-process : it seems to be a nice workaround, but not a good final way...

In the calling task of the main process, I set a task variable of type Long (mainWorkDataId), and initialize it with the BDM persistance ID : theWorkData.getPersistenceId()

In the sub-process, I've a process variable, not a BDM (subWorkDataId), of type Long and a BDM of the target business type : subWorkData. This sub-process BDM initializer is done by a finder query :
SELECT w
FROM WorkData w
WHERE w.persistenceId= :persistenceId
where the persistenceId parameter is the process Long variable.

As Bonita doesn't seem to let us define contract attributes of type Long, in the calling task I pass the mainWorkDataId to set the subWorkDataId, and thus the sub-process starts binding its BDM with the correct business object.

All the operations done on the sub-process BDM are committed to the shared business object...

What about this way ?

An idea of a better, clearer way ?

2 answers

1
+1
-1

1
0
-1

Hello,

Hope this helps someone!

I was able to solve this by creating a variable(local or process works well) of type org.json.simple.JSONObject and then initialize/set the value with all the field names as key and values based on the parent process in the contract required to instantiate the sub process, like below

def ob = new org.json.simple.JSONObject();
ob.put("name", "Raji Malla");
ob.put("details", "sample details");
ob.put("email", "cyz@gmail.com");
return ob;

I mapped this variable to the contract input name specified in the sub process under 'Assigned to Contract input' type and then it worked.

Thanks!

Notifications