Extension elements in JavaDelegate implementations

1,163 views
Skip to first unread message

matany...@gmail.com

unread,
Apr 17, 2014, 10:46:53 AM4/17/14
to camunda-...@googlegroups.com
Dear Camunda Team,

I have added some extension variables to a ServiceTask and would like to get these element values from a JavaDelegate implementation. How should I solve this problem?

Best regasds,
Tom

Christian Lipphardt

unread,
Apr 17, 2014, 10:50:58 AM4/17/14
to camunda-...@googlegroups.com
Hi Tom,

Could you please some code so I can see what you mean by the term
extension variables?
If you refer to custom extension elements inside the bpmn.xml model, you
shoud be able to access them using the BPMN Model API. An example can be
found here (
http://docs.camunda.org/latest/guides/user-guide/#bpmn-model-api-extension-elements
)

Cheers,
Christian

matany...@gmail.com

unread,
Apr 25, 2014, 11:16:24 AM4/25/14
to camunda-...@googlegroups.com
Hi Christian,

Yes, I have inserted a custom extension element into bpmn.xml model. (Please find it below.)

<serviceTask id="ServiceTask_1" camunda:delegateExpression="${DelegateAS400Call}" name="Calling OV003A prg">
<extensionElements>
<camunda:properties>
<camunda:property value="OV003A_H" name="XMLInputName"/>
</camunda:properties>
</extensionElements>
<incoming>SequenceFlow_6</incoming>
<outgoing>SequenceFlow_1</outgoing>
</serviceTask>

I wanna get back the value ("OV003A_H") property from BPMN model API where name property = "XMLInputName".
I read the example You linked in, but couldn't solve this simple task. I always get empty value back.

Thanks in advance,
Tom

Sebastian Menski

unread,
Apr 25, 2014, 11:42:53 AM4/25/14
to
Hey Tom,

the new camunda property extension elements where introduced with the last modeler update and are not yet fully supported by the
bpmn model api. But you can access the attributes with the general xml api.

So you can do something like:

public void execute(DelegateExecution execution) throws Exception {
  CamundaProperties camundaProperties = execution.getBpmnModelElementInstance().getExtensionElements().getElementsQuery()
       
.filterByType(CamundaProperties.class).singleResult();

 
Collection<CamundaProperty> properties = camundaProperties.getCamundaProperties();
 
for (CamundaProperty property : properties) {
   
System.out.println(property.getCamundaValue()); // --> "OV003A_H"
   
System.out.println(property.getAttributeValue("name")); // --> "XMLInputName"
 
}
}



Does this help you?

Cheers
Sebastian

matany...@gmail.com

unread,
Apr 26, 2014, 4:27:21 PM4/26/14
to camunda-...@googlegroups.com
Hey Sebastian,

Yes, this code works properly!
That's what I need.

Thanks for Your help!

Cheers,
Tom

Reply all
Reply to author
Forward
0 new messages