getImplementation() returns null

Hi there,

I’m currently working on a project, where I need to distinguish the different tasks and their respective implementations.It works if I try to retrieve the id or name with getId() / getName(), but this doesn’t work for the implementation.

Is there anything I need to consider in order to access this piece of information? And why does it work for the name/id? It doesn’t matter wether this is a service task, business rule task or any other task. Doesn’t work on any for me.

This is a JUnit test, where I try to validate the correctness of tasks, which unfortunatly does not work as intended.

Thanks and have a nice day
Sascha

Hi Sascha,

It is not clear to me what you want to achieve. Please try to be more precise in what you want to do.

  • What do you mean with distinguishing implementations?
  • You write about methods getId() and getName() - which classes do they belong to?
  • You say you tried some things already. What did you try? If you have some code already, it may be a good idea to post it.

Cheers,
Thorben

Hi Thorben,

thanks for responding. I already thought that my questions were too vague to answer precisely.
So I try my best to clear things up now.

First, I create a small model with just a startevent, a businessruletask and an endevent. I now wrote some code in order to validate the model, so e.g. if the implementation is “DelegateExpresseion” then I want the field “DelegateExpression” to reference a java class. Same applies for “DMN”, which needs to reference a “Decision Ref”. So these small rules should be able to validate a small model, but in order to decide which rules apply I need to know what kind of implementation a task has.

Now in my code I try to evaluate what kind of implementation a task (in this case a businessruletask) uses and tried it with the following lines:

  final BaseElement baseElement = element.getBaseElement();
  final BusinessRuleTask task = (BusinessRuleTask) baseElement;    
  if(task instanceof BusinessRuleTask && task.getImplementation().compareTo("##unspecified") == 0){

Whats happens is that task.getImplementation() always returns the string ##unspecified or null.

I hope this clears things up. Cheers for any help
Sascha

Thanks for the clarification. Camunda modeler and engine don’t use the implementation attribute. I think you’ll have to check the camunda extension attributes directly, i.e. task.getCamundaClass() != null etc.

Cheers,
Thorben

I will try that and report back. I hope your hint will clear things up.

Thanks
Sascha

EDIT: getCamundaClass returns null unfortunatly. So what can I do in order to check the implementation field value?

Hi again,

unfortunatly nothing really seems to work within java. getCamundaClass() returns null, which makes the problem even harder. Any further hints how to check a given businessRuleTask?

Cheers,
Sascha

Hi Sascha,

Could you please upload a minimal executable test case to github? That makes it easier to give hints on your code.

Cheers,
Thorben

Hi Thorben,

I created a workaround, which makes use of DOM Elements for a given XML. If you´re interested I´ll give you the link to GitHub and maybe you´ll see what the use of this is.

Cheers,
Sascha