gpt4 book ai didi

java - Camunda java相当于将所有变量传递给 Activity

转载 作者:行者123 更新时间:2023-12-02 09:43:44 26 4
gpt4 key购买 nike

我有代码可以创建这样的虚拟模型

BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("onelongmodel")
.name("onelongmodel")
.startEvent()
.camundaAsyncBefore()
.callActivity("oneactivity").name("oneactivity").calledElement("oneactivity")
.endEvent()
.done();

我想将所有变量传入和传出 Activity ,我可以通过添加到 bpmn 文件来实现

  <extensionElements>
<camunda:in variables="all" />
<camunda:out variables="all" />
</extensionElements>

我想用java来完成这一步。如何更改上面的 java 代码以添加此选项?

最佳答案

我想这就是你要找的

private void deployProcess(String eventName) {

BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID)
.startEvent()
.userTask(USER_TASK_ID)
.endEvent()
.done();

ExtensionElements extensionElements = modelInstance.newInstance(ExtensionElements.class);

ModelElementInstance taskListener = extensionElements.addExtensionElement(CAMUNDA_NS, "taskListener");

taskListener.setAttributeValueNs(CAMUNDA_NS, "class", ModelExecutionContextTaskListener.class.getName());

taskListener.setAttributeValueNs(CAMUNDA_NS, "event", eventName);

UserTask userTask = modelInstance.getModelElementById(USER_TASK_ID);

userTask.setExtensionElements(extensionElements);

deploymentId = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy().getId();
}

Reference here

关于java - Camunda java相当于将所有变量传递给 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59866000/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com