AnsweredAssumed Answered

Programmatically Change Model in BpmnParseHandler

Question asked by smaik84 on Apr 18, 2017

Hello Community.

 

I would like to change BPMN models programmatically during process deployment. I have tried to impl. that requirement in a BpmnParseHandler, configured as a preBpmnParseHandlers in the activiti.cfg.xml. Changes like the called java class of a service task works perfectly. Also adding a execution listener is fine. Then tried to add a complete new task like:

final ServiceTask myTask = new ServiceTask();

myTask.setId("id");

myTask.setName("name");
myTask.setImplementation("MyClass");
myTask.setImplementationType("class");
myTask.setAsynchronous(true);
myTask.setNotExclusive(false);

... (add and correct the sequence flows) ...

bpmnParse.getBpmnModel().getProcesses().get(0).addFlowElement(myTask);

 

(Optional, re-render the model picture)

final BpmnAutoLayout layoutDesigner = new BpmnAutoLayout(bpmnParse.getBpmnModel());

layoutDesigner.execute();

 

Unfortunately that is not working. The picture is updated correctly, but the new task itself will be ignored from engine. I assume this is because the BpmnParseHandler works element based and new once are not re-read in some processors before.

 

However, is there another possibility to implement my requirement of adding new task in an existing model programmatically? Also hacks / workarounds are welcome ;-)

 

Thanks for your response and best regards

Outcomes