AnsweredAssumed Answered

Creating activiti process dynamically. The task delegate which is set to the service task is not getting instantiated through spring because of  which the auto wiring attributes are coming as null. Can any one give some suggestion.

Question asked by chiranjeeviveerni on Oct 31, 2017
BpmnModel model = new BpmnModel();
Process process = new Process();
process.setId("my-process");
process.setName("my-process");
process.addFlowElement(createStartEvent());
process.addFlowElement(createServiceTask("PatchingTask"));
process.addFlowElement(createEndEvent());

process.addFlowElement(createSequenceFlow("start", "PatchingTask"));
process.addFlowElement(createSequenceFlow("PatchingTask", "end"));

model.addProcess(process);

Deployment deployment = processEngine.getRepositoryService().createDeployment().addBpmnModel("DynamicApiFlow.bpmn", model).name("Dynamic process deployment").deploy();

InputStream processBpmn = repositoryService.getResourceAsStream(deployment.getId(), "DynamicApiFlow.bpmn");

System.out.println(processBpmn);

Map<String, Object> variables = new HashedMap();

variables.put(AvaasConstants.CONST_API_EXECUTION_REQUEST,apiExecutionRequest);
variables.put(AvaasConstants.CONST_RUN_REQUEST_ID,delegateExecution.getVariable(AvaasConstants.CONST_RUN_REQUEST_ID,ObjectId.class));

ExecutionEntity processInstance = (ExecutionEntity) runtimeService.startProcessInstanceByKey("my-process", variables);

}

 

 

protected FlowElement createServiceTask(String name){
    ServiceTask stask = new ServiceTask();
    stask.setId(name);
    String implementationType = ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION;
    stask.setImplementationType(implementationType);
    stask.setName(name);
    stask.setImplementation("OsPatchExecutionDelegate");
    return stask;
}

Outcomes