Accessing custom BPMN extension elements in a strongly-typed way

503 views
Skip to first unread message

spasst...@gmail.com

unread,
Dec 21, 2015, 3:13:54 PM12/21/15
to camunda BPM platform contributors
Hi!

I'm following this tutorial (https://github.com/camunda/camunda-bpm-examples/tree/master/cmmn-model-api/typed-custom-elements) and I'm trying to transfer it to be usable in BPMN.

In the bpmn file I created this task:
[...]
<bpmn2:task id="Task" name="Task">
<bpmn2:extensionElements>
<foo:bar id="someID"/>
</bpmn2:extensionElements>
</bpmn2:task>
[...]

The namespace was declared in the root element:
xmlns:foo="http://www.someURI.com"


Registering my new Type is no problem. But I don't know how to access it in the parse listener. The getExtensionElements-function (see: https://github.com/camunda/camunda-bpm-examples/blob/master/cmmn-model-api/typed-custom-elements/src/main/java/org/camunda/bpm/example/modelapi/KPITransformListener.java) is not available in the parseTask function (see https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/parser/AbstractBpmnParseListener.java).

How do i access the extension elements?

In the CMMN example the humanTask is giving you this functionality (https://github.com/camunda/camunda-bpm-examples/blob/master/cmmn-model-api/typed-custom-elements/src/main/java/org/camunda/bpm/example/modelapi/KPITransformListener.java).

Cheers.

Philipp Ossler

unread,
Dec 22, 2015, 2:25:38 AM12/22/15
to camunda BPM platform contributors
Hi,

the BpmnParseListener have a different API. But you can use the Model API as well. 

You need to get the repository service from the process engine. In the parse method you can create the model with the id of the process definition. For example:

public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
   
    BpmnModelInstance bpmnModelInstance = repositoryService.getBpmnModelInstance(activity.getProcessDefinition().getId());
    UserTask userTask = bpmnModelInstance.getModelElementById(activity.getActivityId());
    
    // ...
  }

See [1] for an example how to use the Model API for BPMNs.

Greetings,
Philipp

Reply all
Reply to author
Forward
0 new messages