Assign list type business variables

1
0
-1

Hi;

I have to assign a complex business variable: oml_O21 with another one : adt_A04, in a groovy script, like this:

oml_O21.msg_Content.pv1=adt_A04.msg_Content.pv1; /where Pv1 is an business variable with attributes.

1- Is this assignment correct or do I have to assign each attribute with the one that matches it?

Also I have to assign:

oml_O21.msg_Content.obx=adt_A04.msg_Content.obx; /where obx is a list type business variable with attributes .

2- How can i make this assignment?

thank

2 answers

1
0
-1
This one is the BEST answer!

Hello,

It's depends of the BDM architecture.

What you have to know is:

* you can't assign anything in a groovy script. A groovy script is here to calculated a value, not to realize operation (technicaly speaking, the execution of a Groovy Script does not start by a "Begin transaction" and finish by a "Commit" ==> That's depend the Bonita Version, but it's definitively not the spirit of the product

* use OPERATION or "Output of connector" to realise that.

Saying that, solution will show up more easy.

So, in your process, you should have 2 Business Variables : oml_O21 and "adt_A04" isn't ?

What about "oml_O21.msgContent : it's another BDM isn't ? Is the msg_content link in the oml_O21 by a COMPOSITION or by a AGGREGATION?

And the pv1 must be AN AGGREGATION (can't be a composition, you reference it in oml_21 and in adt_04)

COMPOSITION : msgContent is "part of oml_21", so the modification is on oml_21.

Use an operation, saying "OML_21" as modification, click on expression, and choose "setmsg_content"

In the groovy script, do something like

var msgContentVar = OLM_21.getMsgContent();

msgContentVar.pv1 = adt_A04.msg_content.pv1

AGGREGATION

Then you must have a variable named "msg_Content"

so, do a first operation

MsgContent / setpv1 / groovy : "return adt_A04.msg_content.pv1"

Second operation (not needed if msgContent is already linked)

OML_21 / setMsgContent / variable: MsgContent

Hope this is clear

Comments

Submitted by maouachria on Tue, 12/31/2019 - 20:23

Yes. It's. Thank you so much Pierre and happy new year to you and all bonita team.

Submitted by Pierre-yves Monnet on Tue, 12/31/2019 - 21:40

Happy new year to you too!

Did this resolve your question?

Don't hesitate to mark the answer as "Yes" then it's marked resolved in the list (that's help to detect the non-answered question).

Submitted by maouachria on Sun, 01/05/2020 - 15:17

sir Pierre;

Also I have to assign:

oml_O21.msg_Content.obx=adt_A04.msg_Content.obx; /where obx is a list type business variable with attributes .

2- How can i make this assignment, with OBX list type business variable with attributes? how to assign the various elements of this list ?.

Submitted by Pierre-yves Monnet on Mon, 01/06/2020 - 09:53

Hello,

Same answer: the list is a COMPOSITION or an AGGREGATION?

Aggregation : you have to declare a Business Variable saying "Multiple". You initialize the value by a Groovy Script, returning a List

Composition? Don't declare the business variable, and return the value in the same way (List)

Submitted by maouachria on Mon, 01/06/2020 - 10:27

I created under BDM:
a business variable named "message", which contains other business variables (composition relation). Among these variables: "msg_Content" of type "segment". "segment" is another business variable which contains the different segments: "pv1", "obx" ...... (composition relation)
"pv1" and "obx": each one has its own attributes. "obx" is of type list (multiple).

So:

1--- i must used setmsg_content and In the groovy script, i do :

var msgContentVar = oml_21.getMsgContent();

msgContentVar.pv1 = adt_A04.msg_content.pv1

or

I must assign each variable attribute ''adt_A04.msg_content.pv1'' to the one that matches it in the variable '' msgContentVar.pv1''?

adt_A04.msg_content.pv1.attribute1== msgContentVar.pv1.attribute1

adt_A04.msg_content.pv1.attribute2== msgContentVar.pv1.attribute2

...

2---- what about obx :

how i can browse this list to make the assignment?

I'm sorry, these are new concepts for me.

Submitted by Pierre-yves Monnet on Mon, 01/06/2020 - 11:51

Hello,

Could you create a simple process, create the Business Object and script, and join it?

I will be more simple than speak in a theoretical way.

I understand that the top BDM is "message", all another BDM are linked in COMPOSITION.

So, your groovy script must return a MESSAGE content. is "oml_21 a message variable?

In the Groovy script, you can update the content.

ar msgContentVar = oml_21.getMsgContent();

msgContentVar.pv1 = adt_A04.msg_content.pv1

is correct, assuming

* oml_21 is a message content

* adt_04 is an another Business Variable declared in your process.

* msgContentVar.pv1 is an AGGREGATION, not a composition

If msgContentVar.pv1 is a COMPOSITION, you must do something like

msgContentVar.pv1 = new MyBDMKids()

What you have to know:

COMPOSITION : the variable is managed by itself. You muse not do any assignment to any another BDM. Only NEW() is acceptable. It's like a PRIVATE member. it's like a Order / Orders Line : you don't affect in the ORDER N° 334 some lines from ORDER 111 : each order has it's onw lines.

AGGREGATION: it's a LINK to an another BDM. For example, in ORDER, you have a reference to a CUSTOMER. You can't create a CUSTOMER from an ORDER. You manage the ORDER and the CUSTOMER independately, and in a ORDER, you REFERENCE a CUSTOMER.

Hope this help

PS: Bonitasoft propose different training, it will help a lot to understand and play with all theses concepts. What about contact the company, and join a training?

Regards

Submitted by maouachria on Mon, 01/06/2020 - 12:11
Submitted by maouachria on Tue, 01/07/2020 - 14:01
Submitted by maouachria on Wed, 01/08/2020 - 11:40

Sir Pierre ;

avez_vous une proposition pour ce .bos?

https://www.dropbox.com/s/yh5q6ekwn24c1dd/Parcours%20De%20Soint-8.bos?dl=0

1
0
-1

Hello,
Thanks you for the BOS file.

it is too complex to analyze and execute it in the community Please provide a process with one task, one operation, and one line in the operation to focus on the issue. At import, you have some issue because some password for a user Fatima is not provided.

If you need more help, keep in mind Bonitasoft services does this kind of follow up.

I don't find a variable OML_21 but a oml_O21 : is that the one we speak?

This variable contains a value "mgs_content"; which is a segment / COMPOSITION.

msg_content contains a value "pv1" which is a "PV1" / COMPOSITION.

So, as I told you, a composition CAN'T be referenced in two objects. So, doing something like

oml_O21.msg_Content.pv1= new PV1()

oml_O21.msg_Content.pv1.setIDPV1 = adt_A04.msg_content.setIDPV1

and so on...

If you want oml_021.msg_content and adt_A04.msg_content point to the SAME RECORD pv1, then

* you must declare the relation as an AGGREGATION

* you muse create a variable myPV1, then you update this variable

* then you can say

oml_O21.msg_Content.pv1 = myPV1;

adt_A04.msg_content.pv1 = myPV1;

Hope this help,

Comments

Submitted by maouachria on Wed, 01/15/2020 - 08:26

thanks sir

Notifications