cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a Activiti Multiinstance Task programmatically

tschiela
Champ in-the-making
Champ in-the-making
Hello,

i try to create a multiinstance workflow programmatically.

I got these BPMN xml that works fine:

<userTask id="multiTask" name="Review task ${loopCounter}" activiti:assignee="${reviewer}">
  <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="reviewersList" activiti:elementVariable="reviewer">
    <completionCondition>${nrOfCompletedInstances > maxReviewer }</completionCondition>       
  </multiInstanceLoopCharacteristics>
</userTask>

How i can do these with pure Java?
I started with these:

MultiInstanceLoopCharacteristics loopChar = new MultiInstanceLoopCharacteristics();   

but i dont know how to go on.

Greets Thomas
7 REPLIES 7

tschiela
Champ in-the-making
Champ in-the-making
Ok, now i know how to set the inputDataItem. But how i can set the LoopDataInputRef?


Property value = new Property();
value.setName("reviewer");
loopChar.setInputDataItem(value);

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Why do you want this? What is the goal?

tschiela
Champ in-the-making
Champ in-the-making
We need a adhoc modelling component like in kickstart. At the moment its possible to generate simple workflows with parallel tasks like in kickstart. But we need also a multiInstance-Task to modell "review"-tasks on the fly. 

So we importet the kickstart packages to convert the workflow dto to xml and deploy it to the server. All works fine, except the multiinstance-task. The problem here is that kickstart use a xml-element "loopDataInput" inside of "multiInstanceLoopCharacteristics"-Element, but activiti uses "loopDataInputRef".

greets Thomas

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Ok,  will have to think about it…

classic example of 'first describe the goal, then the step' : http://catb.org/~esr/faqs/smart-questions.html#goal

tschiela
Champ in-the-making
Champ in-the-making
Ok, i got a quick and dirty solution. I just renamed the attribute loopDataInput to loopDataInputRef in MultiInstanceLoopCharacteristics class of the kickstart BPMN 2.0 xml Model.

naag
Champ in-the-making
Champ in-the-making
Instead of generating the task programmatically via Activiti internal Java APIs (which can change anytime and aren't supposed to be used anyway), why don't you use the other main Activiti "API", namely BPMN 2.0 XML?

Wouldn't that be possible?  🙂

bernd_ruecker
Champ in-the-making
Champ in-the-making
Yeah, sounds more reasonable for me as well: create the BPMN 2.0 XML programatically: You could easily use a Java API for this, we described that in a tutorial: https://app.camunda.com/confluence/display/foxUserGuide/Java+API+to+read+and+write+BPMN+2.0+XML+Intr.... Send me a mail if you want to read it, I can do a PDF export as this tutorial is limited to enterprise support customers…

Cheers
Bernd