I don't know how to access one value of the list that I use to make a parallel multy-instanciation, It is always empty value(multiInstanceIterator - son variable)

Hi all

I am a newbie at Bonita 7.2.0, and have some questions.
From one process I’m doing a parallel multi instantiation, and I’m giving a list to instantiate many time the other process as element there is in the list.
Until here it works fine.
The problem is that when I try to access from the son processes to the instance iterator I doesn’t have any value.
This is important for me because each process is assigned to one investigator, and need to know which investigador is the owner of each sub-flow.

I have this process variable in the father process:
lista_investigadores_hilo wich is a java Object: java.utils.List with these values:

[{nombre=78445632W-Pedro Rodríguez Méndez}, {nombre=45632178U-Manuel López Expósito }]

And in the son process I have created this process variable:

iteradorInvestigadores: wich is a Java Objsct: java.lang.String

This process variable has the same name and type that I put in the Iterator, which is, I suppose that has to be done.

This process variable is always empty (multiInstanceIterator), I show it in the form and I can’t see anything.

Anybody knows how to do it? I think I’m doing it according to the documentation.
http://documentation.bonitasoft.com/iteration-1
Am I doing anything wrong?

I think the type of the element I’m passing to the son ( multiInstanceIterator ) is wrong, but I don’t know why?
Isn’t the element a String or something is wrong?

Are incompatibles types, the java.util.List with java.lang.String.
Which types may I use?
Should I use a Business variable?

Thank you very much.

Any assistance would be greatly appreciated.

Kind regards,
Héctor

Hi Héctor,

Instead of saying

I am a newbie at Bonita 7.2.0, and have some doubts. can you say I am a newbie at Bonita 7.2.0, and have A question.

Doubts are a very different thing to questions.

Try using a a list of list rather than list of json, as in

[[“123”,“abc”], [“def”,“456”]]

Regards
Seán

PS: if this answers your question please mark as resolved.

Thank you very much, I’m going to try it.

I have done this, I have added a snapshoot of my screen:
https://postimg.org/image/tl7tlnl2x/

sube

https://s4.postimg.org/mhzy61fnh/2016_08_17_10_17_21_Bonita_BPM.png
I have a list of list, and I’m printing it in the sub process and always is null.
List:
INFORMACIÓN: transformada List of List, Salida_Salida: [[78445632W, Pedro Rodríguez Méndez], [45632178U, Manuel López Expósito ]]

Is this a bug? Or I’m doing something really bad.
I’m missing something really important, I suppose some body have done this.

What is your code, because we do this all the time…it works.

Ok, here is the list that is displayed in a table, and them I format this list in a list of list to use it to initialize “n” subprocesess.

This is a very simple code that creates and modifies the list to be used to init “n” multi parallel instances

Creating the list:

import static java.lang.System.out;
import groovy.sql.Sql;
import groovy.sql.ResultSetOutParameter;
import com.mysql.jdbc.Driver;
import static org.codehaus.groovy.runtime.DefaultGroovyMethods.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import groovy.json.JsonBuilder;
import com.mysql.jdbc.JDBC4ResultSet;

org.slf4j.Logger loggerJava = org.slf4j.LoggerFactory.getLogger(“org.bonitasoft.groovy.script.incioScript”);

try {

 loggerJava.info("Execute Query select investigacion_investigadores_selectedInput: "+investigacion_investigadores_selectedInput);

 loggerJava.info("ResultSet: ");	 
 List	 milista = new ArrayList();	 
 def builder = new JsonBuilder();
 List investigadores_list = investigacion_investigadores_selectedInput;
 for( String item : investigadores_list){
	 CharSequence charSeqSource = "{nombre=";
	 CharSequence charSeqTarget = "";
	 item = item.replace(charSeqSource, charSeqTarget) ;
	 charSeqSource = "}";
	 charSeqTarget = "";
	 item = item.replace(charSeqSource, charSeqTarget) ;
	  def lin1 = builder {
		nombre item
	  }
	  milista.add(lin1);
 }
 loggerJava.info("milista.toString(): "+milista.toString());
 return milista;		
} catch (e2) {
	loggerJava.error("ERROR: investigacion_investigadores_selectedInput *********************************");
	// loggerJava.error("Cause: "+		e2.getCause());
	loggerJava.error("Message Localized: "+		e2.getLocalizedMessage().toString());
	loggerJava.error("Message: "+		e2.getMessage().toString());
	loggerJava.error("GetStacktrace.ToString: "+		e2.getStackTrace().toString());
}

Code transformimg the list to a list of list:

import static java.lang.System.out; import groovy.sql.Sql; import groovy.sql.ResultSetOutParameter; // import java.util.logging.Logger; // import java.util.logging.Level; import com.mysql.jdbc.Driver; import static org.codehaus.groovy.runtime.DefaultGroovyMethods.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import groovy.json.JsonBuilder; import com.mysql.jdbc.JDBC4ResultSet;

org.slf4j.Logger loggerJava = org.slf4j.LoggerFactory.getLogger(“org.bonitasoft.groovy.script.incioScript”);

try {
loggerJava.info(“Entra en imprime Lista de Hilos ivestigacion transformada a list of list”);

 loggerJava.info("investigacion_investigadores_selected_str Entrada_Salida: "+investigacion_investigadores_selected_str);
 loggerJava.info("lista_investigadores_hilo Entrada_Salida: "+  lista_investigadores_hilo   );
 List	 milista = new ArrayList();
 List investigadores_list = investigacion_investigadores_selected_str;
 for( String item : investigadores_list){
	 CharSequence charSeqSource = "nombre:";
	 CharSequence charSeqTarget = "";
	 item = item.replace(charSeqSource, charSeqTarget) ;
	 /* I clena from the String all the rubbish*/
	 charSeqSource = "]";
	 charSeqTarget = "";
	 item = item.replace(charSeqSource, charSeqTarget) ;
	 charSeqSource = "[";
	 charSeqTarget = "";
	 item = item.replace(charSeqSource, charSeqTarget) ;
	 charSeqSource = "{";
	 charSeqTarget = "";
	 item = item.replace(charSeqSource, charSeqTarget) ;
	 charSeqSource = "}";
	 charSeqTarget = "";
	 item = item.replace(charSeqSource, charSeqTarget) ;
	 charSeqSource = "=";
	 charSeqTarget = "";
	 item = item.replace(charSeqSource, charSeqTarget) ;
	 charSeqSource = ":";
	 charSeqTarget = "";
	 
	 item = item.replace(charSeqSource, charSeqTarget) ;
	 charSeqSource = "nombre";
	 charSeqTarget = "";
	 item = item.replace(charSeqSource, charSeqTarget) ;
	 
	 List	 subLista = new ArrayList();
	 loggerJava.info("item PARSED:"+item);
	 subLista = item.split("-");
	 loggerJava.info("subLista PARSED:"+subLista);
	 milista.add(subLista);
 }
 loggerJava.info("transformada List of List, Salida_Salida: "+milista.toString());
 return milista;
} catch (e2) {
	loggerJava.error("ERROR: investigacion_investigadores_selected_str list of list *********************************");
	loggerJava.error("Message Localized: "+		e2.getLocalizedMessage().toString());
	loggerJava.error("Message: "+		e2.getMessage().toString());
	loggerJava.error("GetStacktrace.ToString: "+		e2.getStackTrace().toString());
}

Which Type is your list, java.util.List, java.util.collection, or Multivalue List.
And the iterator?
My Iterator is a process variable, is it fine? Should it be a Business Data Variable or something different?

Thank you very much

Hi,

I’m away from my desk for the next couple of days and can’t get to my computer. As I say we use this all the time, have a look at this project also…

http://community.bonitasoft.com/project/multi-instantiation-sample

We use process variable for the iterator.

Regards

Ok, thank you very much I will have a look at the example.

I’ve tried your link but I couldn’t import it into Bonita studio 7.2.
I’m trying with this other:

http://community.bonitasoft.com/project/multi-instatiated-example

I have something more complex, I have a task that is a “Call Task”, which calls another Flow, and also in the same task, I have a parallel multi instance task, and I think this is my problem in some moment the multi instance is creating multiple instance and is not setting or sending the data to the flows or processes that it calls.
I’m going to simplify it having only a call task, and into the other flow, I will put the parallel multi instance of the first task.
Thank you

You must map the call data as well in the calling process to the subprocess, this is exactly the same as a single call mechanism.

This should then fix your problem

Ok I have solved my problem, because I didn’t have the local variables in de task, the one that is mapped with the multiInstanceIterator, when I put it I solved my problem, thank you very much.

Now I have a new problem related to this:

[http://community.bonitasoft.com/questions-and-answers/why-cant-i-change-business-variables-two-different-threads-procesflow-paralell]
[http://community.bonitasoft.com/questions-and-answers/why-cant-i-change-business-variables-two-different-threads-procesflow-paralell]: http://community.bonitasoft.com/questions-and-answers/why-cant-i-change-business-variables-two-different-threads-procesflow-paralell