How to copy / add StandardLoopCharacteristics element to a Subprocess using Camunda BPMN Model API?

I’m currently using Camunda BPMN Model Java API to process a BPMN XML and copy it the BPMN elements into another XML. In my source XML, I have elements with “StandardLoopCharacteristics” element type as children. (See below for snippet). I want to be able to read/identify this StandardLoopCharacteristics element and create the same in the target XML. How can I do this?

<bpmn2:userTask id="Activity_1iujgr0" name="a"> <bpmn2:incoming>Flow_0w2ossk</bpmn2:incoming> <bpmn2:outgoing>Flow_09y8wss</bpmn2:outgoing> <bpmn2:outgoing>Flow_02cs0fi</bpmn2:outgoing> <bpmn2:standardLoopCharacteristics /> </bpmn2:userTask>

@Saumya_Upadhyay You can try something like this:

BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();
...
....
.....
StandardLoopCharacteristics loopCharacteristics = bpmnModelInstance.newInstance(StandardLoopCharacteristics.class);
loopCharacteristics.setLoopMaximum(5);
...
.....
task.setLoopCharacteristics(loopCharacteristics);

Thanks @aravindhrs! I’m aware of this approach and in fact I’m following the same method for MultiInstanceLoopCharacteristics. But for some reason, I don’t seem to find the StandardLoopCharacteristics class in the Java package that I’m using. This is the Java docs that I’m referring to - org.camunda.bpm.model.bpmn.instance (Camunda Platform Javadocs 7.22.4-ee)

Do you know which package contains this class StandardLoopCharacteristics?

@aravindhrs - It doesn’t look like the Camunda BPMN Model API exposes StandardLoopCharacteristics class. Is there any other way I can do this?

@Saumya_Upadhyay Which library version are you using? Can you share that dependency version, artifact id, etc?

@aravindhrs - Thanks for the detailed explanation. I appreciate it! In my project, I’m using Camunda BPMN Model API version 7.22.0. Is there a way I can accomplish this in the version that I’m currently using instead of downgrading it to version 7.20 or below?

@aravindhrs - As mentioned before, I have tried this but I’m unable to import the class at all. Additionally, I wanted to mention that the way I’m importing this package in my Java project is by including the following two jars directly into my project -

camunda-bpmn-model-7.22.0.jar
camunda-xml-model-7.22.0.jar

I’m not sure if I’m missing any jar files? Or if this might be the reason that it’s somehow incorrectly configured? It’s super confusing why I would be able to import MultiInstanceLoopCharacteristics but not StandardLoopCharacteristics.

Would it not be part of LoopCharacteristics (Camunda Platform Javadocs 7.22.4-ee)

@GotnOGuts / @Saumya_Upadhyay , I checked the library but unfortunately StandardLoopCharacteristics.class doesn’t exists even in v7.20

MultiInstanceLoopCharacteristicsImpl (Impl) extends LoopCharacteristicsImpl.java (abstract) implements LoopCharacteristics (Interface).

While modelling it allows to define the loop.

<bpmn:userTask id="Activity_0xvzgi6">
  <bpmn:incoming>Flow_0qs5p62</bpmn:incoming>
  <bpmn:outgoing>Flow_0agmqev</bpmn:outgoing>
  <bpmn:standardLoopCharacteristics />
</bpmn:userTask>

I guess camunda has never implemented this feature or not supported the loop characteristics.

Camunda engine doesn’t support loop markers. You can model it in the Camunda Modeler but the marker is ignored in the engine.

The suggestion was to use XOR gateway to perform the looping. Only multi-instance loop characteristics was supported.

@aravindhrs - That’s what I’m seeing as well, that it does not exist. Given this is the situation, how do I handle this? Is there a workaround? Which version of the API actually has this class anyway?

@Saumya_Upadhyay Refer the updates above How to copy / add StandardLoopCharacteristics element to a Subprocess using Camunda BPMN Model API? - #11 by aravindhrs

@aravindhrs - Thanks for clarifying! So it looks like there’s no way to actually identify or create a StandardLoopCharacteristics element in the BPMN xml using the Camunda BPMN Model API.

That’s correct.