在 processBody of (/processes POST) in alfresco rest-api 中设置的自定义变量无法被我部署的 .bpmn2 文件识别
Custom variables set in processBody of (/processes POST) in alfresco rest-api not recognizable by my deployed .bpmn2 file
我通过我的露天工作流控制台部署了以下 .bpmn2 文件,其中包含将根据传递的变量分配给用户的用户任务 "Y"
<process isExecutable="true" id="step4reconfigure41" name="Reconfigure step 4">
<startEvent id="start"
activiti:formKey="wf:submitAdhocTask" />
<sequenceFlow id='flow1'
sourceRef='start'
targetRef='adhocTask' />
<userTask id="adhocTask" name="First user Task"
activiti:formKey="wf:adhocTask">
<documentation> First task </documentation>
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
if(execution.getVariable("Y") == 22){
task.assignee = 'userA';
}
else if(execution.getVariable("Y") != 22){
task.assignee = 'userB';
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
我成功地从 alfresco 工作流控制台启动了流程,例如:
- start Y=22
这是成功的,因为已成功读取变量并相应地应用了 .bpmn2 文件中描述的赋值逻辑。
我想使用 alfresco rest-api 执行相同的场景。
根据 api-explorer 文档,我必须使用 /processes (POST) 端点和如下所示的 processBody
{
"processDefinitionKey": "string",
"variables": {
"bpm_assignee": "string",
"bpm_sendEMailNotifications": true,
"bpm_workflowPriority": 0
}
}
我正在尝试将变量 "Y" 传递给 processBody,如下所示:
{
"processDefinitionKey": "test",
"variables": {
"Y": "5",
"bpm_sendEMailNotifications": true,
"bpm_workflowPriority": 0
}
}
不幸的是,即使进程正常启动,也没有设置变量"Y",我通过/processes/{processId}/variables端点进行了测试。
What should i do to perform the same action i did on my workflow
console (passing the variable on start) through the rest api? And how
this variable will be visible in my .bpmn2 file?
任何帮助将不胜感激:)
如果您无法使用开箱即用的 REST API 来执行您想要的操作,您可以编写自己的 Java 支持的 Web 脚本。 controller可以使用Alfresco WorkflowAPIWorkflowService.startWorkflow method启动workflow并传入parmaeter.
REST API 可能使用相同的 API。如果是这样,这可能也无法正常工作。如果发生这种情况,请启动调试器并单步执行 Alfresco 源代码以查看发生了什么。
最后我设法通过 "expanding" 将 bpmnModel.xml 放在
WEB-INF/lib/alfresco-repository-{version}.jar/alfresco/model/ 并在 "bpm:startTask"
中添加了一个额外的 属性
<property name="bpm:Y">
<type>d:text</type>
</property>
重新启动服务器,新进程已成功创建,我的新自定义参数通过添加到请求设置
{
"processDefinitionKey": "test",
"variables": {
"bpm_Y": "5",
"bpm_sendEMailNotifications": true,
"bpm_workflowPriority": 0
}
}
我通过我的露天工作流控制台部署了以下 .bpmn2 文件,其中包含将根据传递的变量分配给用户的用户任务 "Y"
<process isExecutable="true" id="step4reconfigure41" name="Reconfigure step 4">
<startEvent id="start"
activiti:formKey="wf:submitAdhocTask" />
<sequenceFlow id='flow1'
sourceRef='start'
targetRef='adhocTask' />
<userTask id="adhocTask" name="First user Task"
activiti:formKey="wf:adhocTask">
<documentation> First task </documentation>
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
if(execution.getVariable("Y") == 22){
task.assignee = 'userA';
}
else if(execution.getVariable("Y") != 22){
task.assignee = 'userB';
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
我成功地从 alfresco 工作流控制台启动了流程,例如:
- start Y=22
这是成功的,因为已成功读取变量并相应地应用了 .bpmn2 文件中描述的赋值逻辑。
我想使用 alfresco rest-api 执行相同的场景。
根据 api-explorer 文档,我必须使用 /processes (POST) 端点和如下所示的 processBody
{ "processDefinitionKey": "string", "variables": { "bpm_assignee": "string", "bpm_sendEMailNotifications": true, "bpm_workflowPriority": 0 } }
我正在尝试将变量 "Y" 传递给 processBody,如下所示:
{ "processDefinitionKey": "test", "variables": { "Y": "5", "bpm_sendEMailNotifications": true, "bpm_workflowPriority": 0 } }
不幸的是,即使进程正常启动,也没有设置变量"Y",我通过/processes/{processId}/variables端点进行了测试。
What should i do to perform the same action i did on my workflow console (passing the variable on start) through the rest api? And how this variable will be visible in my .bpmn2 file?
任何帮助将不胜感激:)
如果您无法使用开箱即用的 REST API 来执行您想要的操作,您可以编写自己的 Java 支持的 Web 脚本。 controller可以使用Alfresco WorkflowAPIWorkflowService.startWorkflow method启动workflow并传入parmaeter.
REST API 可能使用相同的 API。如果是这样,这可能也无法正常工作。如果发生这种情况,请启动调试器并单步执行 Alfresco 源代码以查看发生了什么。
最后我设法通过 "expanding" 将 bpmnModel.xml 放在 WEB-INF/lib/alfresco-repository-{version}.jar/alfresco/model/ 并在 "bpm:startTask"
中添加了一个额外的 属性<property name="bpm:Y">
<type>d:text</type>
</property>
重新启动服务器,新进程已成功创建,我的新自定义参数通过添加到请求设置
{
"processDefinitionKey": "test",
"variables": {
"bpm_Y": "5",
"bpm_sendEMailNotifications": true,
"bpm_workflowPriority": 0
}
}