Creating custom tasks

43 views
Skip to first unread message

spasst...@gmail.com

unread,
Dec 21, 2015, 3:25:49 PM12/21/15
to camunda BPM platform contributors
Hi,

Is it possible to create custom task that can be parsed and used in the camunda engine?

I tried extending the XML schema definition by adding my new type like this:


<?xml version="1.0"?>
<xs:schema xmlns="http://someURI.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" targetNamespace="http://someURI.com">
<xs:import namespace="http://www.omg.org/spec/BPMN/20100524/MODEL" schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"/>

<xs:element name="myTask" type="tMyTask" substitutionGroup="flowElement"/>
<xs:complexType name="tMyTask">
<xs:complexContent>
<xs:extension base="bpmn2:tTask">
<xs:attribute name="atOne" type="xsd:string" use="required"/>
<xs:attribute name="atTwo" type="xsd:string" use="required"/>
<xs:attribute name="atThree" type="xsd:string" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

And in my bpmn file i added a new element in the process:

<foo:myTask atOne="1" atTwo="2" atThree="3" />


Additionally I added my new xsd file to the schemaLocation of the bpmn file, but it is not working. The parser complains that myTask is not correct.

Do you have an idea how to achieve my goal?

Cheers

Philipp Ossler

unread,
Dec 23, 2015, 9:06:49 AM12/23/15
to camunda BPM platform contributors
Hi,

what do you want to do with the custom task? Do you want that it can be executed by the process engine or should it be ignored?
Please describe your use case.

Note that you can use a simple "task" element with extension elements and attributes. Using a BpmnParseListener, you can hook into the parsing and modify the behavior that is invoked when the "task" is executed.
Or simply use a service task [1] in combination with extensions.

Greetings,
Philipp

 

spasst...@gmail.com

unread,
Dec 23, 2015, 11:00:27 AM12/23/15
to camunda BPM platform contributors
Hi,

I should have been more specific.

The goal is, to allow the user to model a task with very specialized Task-Elements e.g. a Task that performes the rotation of a connected robot arm. This task should be represented in bpmn by a unique FlowObject just like common tasks do but living in its own namespace ("foo:myTask" in the example above).

So the activity represented by the task has its own behavior with its own parameters e.g. the speed at which to move the robot arm. I guess the right way to achieve the correct parsing of the new elements is to add your own xsd file (see above) but I'm near to no experience with XML schemas.

Currently I'm actually doing it the way you describe it:
Use a regular Task and add extension Elements to inject the type of the task ("moveRobotArm") and the different parameters. But I'm not really satisfied with this approach as it not represented in the modeler as nice as a custom task is and it might lead to errors describing your extension elements (typos and the like).

Cheers

Philipp Ossler

unread,
Jan 4, 2016, 3:52:04 AM1/4/16
to camunda BPM platform contributors
Hi,

the recommended (and easiest) way is to use a service task ("moveRobotArm") and inject the parameters ("speed") [1]. 

However, let's talk about the representation. What modeler do you use? Do you want to view the process definition / instance in cockpit or your own application?

In case you use the new camunda Modeler, you may interested in the feature request [2] which is about custom tasks. The idea is to provide a SPI to add custom tasks with custom properties and shapes. So you may add a JSON configuration or Java Script to use your custom tasks. Please look at the feature request and comment your requirements.

Greetings,
Philipp

Reply all
Reply to author
Forward
0 new messages