Create user task with custom attributes in Camunda Modeler

1,565 views
Skip to first unread message

bibi....@googlemail.com

unread,
Apr 25, 2014, 3:02:36 AM4/25/14
to camunda-...@googlegroups.com, bianca...@pumacy.de
Hi!

I want to create a custom user task for the Camunda Modeler, that acts like a normal user task but has a couple of additional attributes, that I want to set using the Modeler. I found the custom task example here http://docs.camunda.org/latest/real-life/how-to/#modeler-creating-custom-tasks-for-camunda-modeler but it seems to be a service task, not a user task. Is it possible to do something similar for a user task?

I'm coming from the Activiti world and wanted to use Activiti for my current project as well, but I coulnd't find a way to implement that for a user task. If that is supported by camunda BPM I would consider using camunda BPM instead. This would be very important for the project to be successful.

Thank for any help!

Best regards,
Bianca

Roman Smirnov

unread,
Apr 25, 2014, 3:44:13 AM4/25/14
to camunda-...@googlegroups.com, bianca...@pumacy.de, bibi....@googlemail.com
Hi Bianca,

You can create a custom user task like it is described in the example you found. So, you have to do similar steps for a custom user task! Instead of using the service task you have to use the user task.

Does it help you? Do not hesitate to ask if you need some help.

Cheers,
Roman

Bianca

unread,
Apr 25, 2014, 4:05:16 AM4/25/14
to camunda-...@googlegroups.com, bianca...@pumacy.de, bibi....@googlemail.com
Hi Roman,

thanks for the answer!

Is there an example describing the steps you have do take to achieve that? Do I still have to extend the AbstractCustomTaskProvider or another class? And if it's the same, where do I define whether I want to create a service task or a user task?

Thanks for your help!
Bianca

Michael Schöttes

unread,
Apr 25, 2014, 4:16:34 AM4/25/14
to camunda-...@googlegroups.com, bianca...@pumacy.de, bibi....@googlemail.com
Hi Bianca,

basically there are two positions in the tutorial where you have to implement the user task instead of a service task. Generally you can use any kind of task.

  public static boolean isMyCustomTask(EObject eObject) {
    return eObject instanceof UserTask && CLASS_VALUE.equals(eObject.eGet(CLASS_STRUCTURAL_FEATURE));
  }

  @Override
  public ICreateFeature getCreateFeature(IFeatureProvider fp) {
    String taskName = PluginConstants.getMyCustomTaskName();
    String createDescription = "A task that talks to an endpoint";

    return new AbstractCreateTaskFeature<ServiceTask>(fp, taskName, createDescription) {

      @Override
      protected String getStencilImageId() {
        return Images.IMG_16_SERVICE_TASK;
      }

      @Override
      public ServiceTask createBusinessObject(ICreateContext context) {
        ServiceTask serviceTask = super.createBusinessObject(context);

        serviceTask.eSet(PluginConstants.CLASS_STRUCTURAL_FEATURE, PluginConstants.CLASS_VALUE);

        return serviceTask;
      }

      @Override
      public EClass getBusinessObjectClass() {
        return Bpmn2Package.eINSTANCE.getServiceTask();
      }
    };
  }
Cheers,
Michael

Bianca

unread,
Apr 28, 2014, 4:29:13 AM4/28/14
to camunda-...@googlegroups.com, bianca...@pumacy.de
Hi Michael,

thanks for your help!

I installed camunda BPM to my machine and looked into the tutorial. I used the example code from github to have a working configuration before I started to customize it and change everything to UserTask.

I can run the plugin and a custom user task is shown, but when I add to the process I don't have a cutom tab added to the properties. Looking into the tutorial again I figured, that the modeler might identify the custom (service) task by the class that was assigned to it. But because I have a user task there is no class to assign. Is there another way I can add custom properties with or without custom tabs?

I have to say that I'm really glad, that this forum is so active and everyone is so supportive here!

Cheers
Bianca

Bianca

unread,
Apr 28, 2014, 5:26:57 AM4/28/14
to camunda-...@googlegroups.com, bianca...@pumacy.de
Hi!

Ok, I just found the solution myself. It was much easier than expected. In case anyone else might have the same problem:
In the example files is a class PluginConstants that contains a method isMyCustomTask(EObject eObject). I changed the return value to "eObject instanceof UserTask" because for me it works to change all user tasks to custom tasks. Otherwise there would have to be some kind an identifier.

But I still have some questions left. Maybe someone can help. The tutorial describes how to add a custom tab. Is there a way to add custom fields to the existing tabs as well?

And is there a way to remove task types etc. from the modeler view (e.g. remove the standard user task as it is not needed anymore).

Thanks for the help!
Bianca

Michael Schöttes

unread,
Apr 28, 2014, 8:22:17 AM4/28/14
to camunda-...@googlegroups.com, bianca...@pumacy.de, bibi....@googlemail.com
Hi Bianca,

thank you for the feedback. It's nice to hear that your custom Task is running. 

Regarding your questions:
1. The palette can be customized. In org.camunda.bpm.modeler.ui.diagram.palette you have to add a filter to remove the not required elements:

public IPaletteCompartmentEntry[] build() {

PaletteCompartments compartments = new PaletteCompartments();
// add compartments from super class
create(Category.CONNECTORS, compartments);
create(Category.TASKS, compartments);
create(Category.GATEWAYS, compartments);
create(Category.EVENTS, compartments);
create(Category.EVENT_DEFINITIONS, compartments);
create(Category.DATA, compartments);
create(Category.OTHER, compartments);
Filter(.....); // add your filter here
addCustomTasks(compartments);
return compartments.getCompartments();
}

Maybe you find the solution here. 

Cheers
Michael

Reply all
Reply to author
Forward
0 new messages