about the mutilple instance

1
0
-1

I use the bonita studio 7.0.1 When it comes to the mulitple instance regarding to the task, I go to the general -->iteration and I find the "Iterator" field is disabled and I couldn't input or change anything in this field. It takes me a while to get aware of this field use the variable called "multiInstanceIterator", but I couldn't get this kind of variable in the actor filter even I call the API processAPI.getProcessDataInstance("multiInstanceIterator",getExecutionContext().getProcessInstanceId()).getValue()), I found something very interstring , this variable could be found and used in the connector. So the background is that I generate the muliti instance from the list (list of bonita user id)and I'd like to use this kind of variable to set the different assignee in the actor filter since this task is for consign. How can I achive it ? Thanks in advance.

Comments

Submitted by Sean McP on Wed, 08/05/2015 - 08:24

I think you've misunderstood the Iterator.

It has nothing to do with Actors it is purely a java LIST of (anything).

What you want here is a list = multiInstanceIterator = [a,c,f,h,u]

the process will be initiated as

process a process c process f process h process u

I also think you are misunderstanding the Actor in the sense of process and API, in this case you want to do the following

Main process

Var = userid
List = multiInstanceIterator = [1,2,6,8,22]
calling process multiInstanceIterator
                      userid (as the iterator)

subProcess Instance(s) MAP userid to the subprocess

your code will then be

startProcess(userid, processed)

This will assign the process to the defined users with the subprocess (in this case) executing 5 times.

regards

3 answers

1
+1
-1

Got it , it works , Thanks.

1
+1
-1

Here is a sample subprocess that would do what you want.

This code is cut down to not very good as it is used in company code so you will have to work on it but it will give you the idea of starting multiple processes and assigning a user to each

SubProcess startAndAssignProcesses Step1 = STARTTask timer = 10 seconds Step 2 = AssignTask

It must be done in two steps...very important, you could do it in one Step but you have to add a loop into Step1 to wait for the task to become available and then proceed. We've found it easier this way. But we will be changing it in due course.

It does work, but you will need to change it to your needs, regards Seán

String processes; //Pool variable

STEP1

String procName = "process1" //processName
String latestVersion = "0.0"; //holder for process Versions not always in order
double topValue = 0.0; //

List users = [1,5,7,9,12];

StringBuilder sb = new StringBuilder(); // list of started processes

// get the latest processToStart definition
                       
List<ProcessDeploymentInfo> processSet = processAPI.getProcessDeploymentInfos(0, 2000, ProcessDeploymentInfoCriterion.NAME_ASC); //get process names
List<ProcessDeploymentInfo> shortProcessSet;

String slp = ""; //init temp values
String slp2s = "";
                       
for (int processSetCount=0; processSetCount<processSet.size(); processSetCount++){

ProcessDeploymentInfo p = processSet.get(processSetCount); //get the process

if(processToStart.compareTo(p.getName()) == 0){ //test the name

Int thisProcessCount = processSetCount;
while(processToStart.compareTo(p.getName()) == 0){

if (Double.parseDouble(p.getVersion()) > topValue){ //keep the current top value - not always in order
topValue = Double.parseDouble(p.getVersion());
}
thisProcessCount++;
p = processSet.get(thisProcessCount);
}
break; //break out when we have reached the last of the process list and got the highest version
}
else if(processToStart.compareTo(p.getName()) < 0){
//debug}
else if(processToStart.compareTo(p.getName()) > 0){
//debug}
}

latestVersion = new DecimalFormat("#0.00").format(topValue); //keep the latest version of the process

// get the process id
processId = processAPI.getProcessDefinitionId(processToStart, latestVersion);

for (int usern : users){

Map<String, Serializable> processData = new HashMap<String, Serializable>();
processData.put("data1", var1); // for data you want to send to the process
processData.put("data2", var2);
processData.put("data3", var3);
etc...

ProcessInstance processInstance = processAPI.startProcess(processId, processData); //start the process
sb.append(processInstance.getName()+"-"+processId+":"+processInstance.getId()+":"+usern+";"); //save to processes started list
}

return sb.toString();  //return to pool variable processes

STEP 2 The assign step

//using process pool variable
activityId = 0;
String[] processProcessId = process.split(":"); // get the processID
String[] processIdent = processProcessId[0].split("-");

//get all human tasks
SearchOptionsBuilder searchOptionsBuilder = new SearchOptionsBuilder(0, 100);
searchOptionsBuilder.filter(HumanTaskInstanceSearchDescriptor.NAME, processIdent[0]);
SearchOptions searchOptions = searchOptionsBuilder.done();
SearchResult<HumanTaskInstance> searchHumanTaskInstances = processAPI.searchHumanTaskInstances(searchOptions);

for (HumanTaskInstance pendingTask : searchHumanTaskInstances.getResult()) {

if (pendingTask.getParentProcessInstanceId().toString().equals(processProcessId[1].toString())){
if (pendingTask.getId()>activityId){
activityId = pendingTask.getId(); //get the activityID
}
}
} //for

//finally assign the task...
processAPI.assignUserTask(activityId, userid.getId());
processAPI.updateDueDateOfTask(activityId, dueDate);  //otherwise c?

1
0
-1

Appreciate for your prompt reply, I know the iterator is purely the jave list to generate the sub-process as many as the size in this list. However , My concern is how to set the task assignee for the sub-process when it comes to use the actor filter to do so.
eg: If there is the list {A,B,C,D} which each element is the assignee It will definitely generate the 4 sub-process , I used to set the assignee by actor filter , but I couldn't get the variable called "iterator " in the actor filter. On the other hand, why can I get it directly in the connect by using groovy. Can you please elaborate how to set assinee A,B,C,D seperately to each sub-process

Comments

Submitted by pablo.pombo on Tue, 10/27/2015 - 14:53

Hola, gracias por este foro..
Les comento que soy nuevo en Bonita (1 mes) y estoy trabajando en un proceso que usa subprocesos. Para armar la lista sobre la cual se iterara para crear cada subproceso estoy usando un objeto de negocio que representa a los candidatos para una posición. Esto funciona bien y se generan tantos subprocesos como candidatos tengo.
El problema es que no se como leer el valor de la variable MULTIINSTANCEITERATOR en cada uno de los subprocesos. Yo se que la variable esta en la tabla DATA_INSTANCE, pero no se como leer su valor.

Desde ya, agradezco la ayuda.

Notifications