Define input/output in Custom Task for the Eclipse modeler?

I am creating an Eclipse plugin for a custom task extension, as is done here:

Everything works fine, but I cannot figure out how to set input / output parameters by default.

E.g. to set the name of the task I simply do:
serviceTask.setName("Do Something");

I would like to provide default input / output parameters too. I can see that there is a method

serviceTask.setIoSpecification(arg0);

But I cannot figure out how to use it.

Thankful for any pointers in the right direction.

Hi @VictorEkdahl,

What do you mean with “input / output parameters”? Do you mean the camunda:inputOutput element (see 1)? Or do you mean the bpmn InputOutputSpecification element?

Cheers,
Roman

Hello @roman.smirnov

I mean the camunda:inputOutput element in the service task Input/Output tab. That is, the input and output parameters of the task.

If InputOutputSpecification is something else entirely, perhaps the Input/Output can be set similarly to the class value? I.e.

EStructuralFeature InputOutput = ModelPackage.eINSTANCE.getDocumentRoot_InputOutput()

I did make an attempt along those lines without success. Because what would the X in
serviceTask.eSet(InputOutput, X)
be?

Perhaps, this isn’t the right approach either?

Hi @VictorEkdahl,

The camunda:InputOutput element is a custom camunda extension elements. That’s why you can’t use serviceTask.eSet(InputOutput, X) to set it. The camunda:InputOutput element must be added as an extension element of the service task.

In order to add a custom element to the extension elements of a service task you can use the ExtensionUtil#addExtension() (see 1).

Does it help you?

Cheers,
Roman

It’s all new to me, so no, not yet, but I’ll keep looking at it. I think I got the general idea.

addExtension(EObject object, EStructuralFeature feature, EObject value)

Speculations:

  • Object is the serviceTask
  • Feature is the ModelPackage.eINSTANCE.getDocumentRoot_InputOutput()

What is the “value” though?

Thanks,
Victor

The value would be an instance of the camunda extension element InputOutput, so it would the X in your example above.

Cheers,
Roman

Yes, but X is unknown to me.

How do I create an extension element InputOutput object that I can pass to the above, is what the question now boils down to.

Anyway, I’ve seen your name in the source code and I appreciate the help so far. I understand that it’s trivial to you.

Hi @VictorEkdahl,

An instance of InputOutput can be created by using the ModelFactory:

ModelFactory.eINSTANCE.createInputOutputType()

Cheers,
Roman

Hm, ok.

So to summarize so far, I do:

final InputOutputType InputOutput = ModelFactory.eINSTANCE.createInputOutputType();
ExtensionUtil.addExtension(serviceTask, PluginConstants.INPUT_OUTPUT_FEATURE, InputOutput);

Where

EStructuralFeature INPUT_OUTPUT_FEATURE = ModelPackage.eINSTANCE.getDocumentRoot_InputOutput();

and the rest is as in the custom task tutorial.

This compiles and does not give an error, but the input-output table is empty. So I create a parameter:

final ParameterType parameter = ModelFactory.eINSTANCE.createParameterType();
field.setName("input name");
field.setText("input value");

And here I get stuck again - what do I do next to associate this parameter with the input or output list of the InputOutput object?

Again, it’s a custom extension element i.e. “camunda:inputParameter”. So I attempt to use the ExtensionUtil again, but this time I don’t know on what object to put it.

  1. The parameter has to be associated with an input/output-list?
  2. The list has to be associated with the InputOutput object?

Any hints appreciated.

To add an input/output parameter you have to do the following:

EStructuralFeature inputFeature = ModelPackage.eINSTANCE.getInputOutputType_InputParameters();
EList<ParameterType> inputs = (EList<ParameterType>) inputOutput.eGet(inputFeature);
ParameterType inputParameter = ModelFactory.eINSTANCE.createParameterType();
inputs.add(inputParameter);

The same for output paremters

EStructuralFeature outputFeature = ModelPackage.eINSTANCE.getInputOutputType_OutputParameters();
EList<ParameterType> outputs = (EList<ParameterType>) inputOutput.eGet(inputFeature);
ParameterType outputParameter = ModelFactory.eINSTANCE.createParameterType();
outputs.add(outputParameter);

Does it help you?

Cheers,
Roman

1 Like

Yes, it does!

It’s working now. Thank you.