Multi instantiate over multiple processes

I have an orders and items data setup. There are multiple items per order. 

After the orders with items are recorded I want to push the items through multiple processes individually. However, multi instantiating each process requires me to wait for all of the items to finish one task before the next starts. I prefer that each item can make its way through all tasks at their own pace. 

Could someone advise on how to complete this? I'm using BonitaSoft version 7.10.

Thanks in advance. 

Hi Joni,

If I am not mistaken what you want to achieve is to multi-instantiate a Call Activity to which you will delegate the treatment of each Item in your collection.

If my understanding is correct, what you could do is:

  • Create a process named "handle_item" that takes the id of the item to handle as contract input
  • On the master process where your created your order and items, call the "handle_item" process with a Call Activity with Parallel multi-instantiation initiated from your Multiple<Business Object> collection of Items

So that all items will be handled in parallel at their own pace.

HTH

Captain Bonita

Thank you for the quick response. 
I am a little lost on the visualisation of this. 


The 'handle_item' process is not in sequence with the other processes but master process does contain the full sequence from submit order to completing processing items? 

Or the master process is to submit order, and then we call a child process of instantiating items? 

And how do I define a call activity? Is it a 'throw-message' process? 

Hi Joni,

What I had in mind was:

Master process creates the Order and Items.

Then for each items you want to process in parallel, you can add a Call Activity task in your master process that you multi-instantiate with the collection of items. Which means that all the tasks related to items handling have to be extracted from the master process into the "handle_item" process. (That is good as the master process becomes smaller and easier to read and maintain)

The master process can wait for all the items to be processed before moving on with the order.

See those documentation pages for reference:

https://documentation.bonitasoft.com/bonita/2021.2/process/iteration

https://documentation.bonitasoft.com/bonita/2021.2/process/called-processes

Hope this helps,

Captain Bonita

Ahh, this helps a lot. I wasn't familiar with call activities but am grasping them more now. 

So, if I then separate the items data to a separate diagram. 
Do I require an initialising script for the item data? (itemDataVar.etd = itemDataInput?.etd) 
And should the item list from the parent process be the items defined in the initial contract?

Thank you so much for your help on this. 

So what I'm trying to do at the moment: 

Parent process initiate: 

(Given contract is a COMPLEX OrderInput, within which there is another COMPLEX itemInformation). 


def OrderVar = new nds.model.Order()
OrderVar.customerCode = OrderInput?.customerCode
OrderVar.saleRep = OrderInput?.saleRep
OrderVar.itemInformation = {
    def itemInformationPList = []
    //For each item collected in multiple input
    OrderInput?.itemInformation.each{
        //Add a new composed ItemInformationP instance
        itemInformationPList.add({ currentItemInformationPInput ->
            def itemInformationPVar = new nds.model.ItemInformationP()
            itemInformationPVar.itemID = currentItemInformationPInput.itemID
            itemInformationPVar.itemNameP = currentItemInformationPInput.itemNameP
            itemInformationPVar.itemSizeP = currentItemInformationPInput.itemSizeP
            itemInformationPVar.buccP = OrderInput?.bucc
            return itemInformationPVar
        }(it))
    }
    return itemInformationPList}()
OrderVar.bucc = OrderInput?.bucc
return OrderVar

 

Then there is a list in the pool vars of itemInformation, and the following process sets itemInformation (the list) equal to order.itemInformation (I don't know if it's necessary). 

Then in the call activity, I instantiate on itemID. 

In the child process I initiate the itemInformation:

(Given contract is a COMPLEX itemInformationP). 


def ItemInformationVar = new nds.model.ItemInformationP()
itemInformationPVar.itemID = ItemInformationPInput?.itemID
itemInformationPVar.itemNameP = ItemInformationPInput?.itemNameP
itemInformationPVar.itemSizeP = ItemInformationPInput?.itemSizeP
itemInformationPVar.buccP = ItemInformationPInput?.bucc
return ItemInformationVar

I understand here that I don't want this to be a new record in the model as we have already set it previously, so how do I call the correct record? 

Also then, the Call Activity is linked by

itemInformation    |    Assigned to Contract Input    |    itemInformationPInput


So I understand that my initiating of the item information in the child process needs corrected, but I also get the following error related to the call activity process:

 

Error while validating expected inputs: [[nds.model.ItemInformationP@7748fcfb, nds.model.ItemInformationP@2d986585] cannot be assigned to COMPLEX type]

 

Very grateful in advance for your response. 

 

Hi,

I believe you are very close to the solution.

What I would do is:

* The child process should only take the ItemID (which is a simple value, Long probably or String I guess) as contract input

* The child process should initialize a ItemInformationP by doing a findByItemId() query on the BDM ==> that way you get a reference to an existing object of your BDM (not creating a new entry)

 

With that, you should be able to complete your use case. Let me know if it works for you.

Captain Bonita

Thank you immensely for taking the time to read my questions and get back to me quickly. 

(Unfortunately, still more questions),

I have altered contract inputs so that the ID is sent to the contract of the child process, and then that contract value uses a findByItemID() query. (Although whether it is correct I am yet to find out). 
However, now I get 2 further errors: 

Firstly, (on the parent call activity task)


Error while validating expected inputs:  [nds.model.ItemInformationP@cf0a4af cannot be assigned to TEXT]

Which worries me that the itemIDs read as a list instead of already being multi instantiated? The multi instantiation is also performed with the itemID as the iterator (is this okay?). 

 

I also get a new error: 


org.bonitasoft.engine.business.data.SBusinessDataNotFoundException: Impossible to get data of type nds.model.Order with id: 47

 

Hi,

I believe you've made the following mistakes (I'll let you check if my assumptions are correct or not):

In the parent process on the call activity you provided the ItemInformation object reference, where you should provide itemID only. What I would do:

On the call activity in the "Data to Send" tab, I would fetch the contract expected by the "handle_item" child process.

On the left operand I would use something like:

((ItemInfomationP)multiInstanceIterator).itemID ==> That way I only send to the child process the ID of the object it has to handle.

 

In the child process it looks like you are searching an Order based on the itemID where you should be looking of an ItemInformationP object instead.

 

Hope This helps,

Captain Bonita

Yes, I ended up only sending ID information for child and parent processes (childID to get the relevant row with ChildObjectDAO, and parentID to use within forms to display parent object information). 

Thanks for the support on this!