Camunda GET opportunities of XOR Gateway using REST

早过忘川 提交于 2020-07-22 11:12:11

问题


I have the following situation:

What i want to do is to get a dropdown menu in my Angular application where all opportunities of books are listed. So i can choose between 'Harry Potter', 'Moby Dick' and 'Robinson Crusoe'. When i selected one book and press submit i send a POST /complete via REST.

It should look like this, whereby the options should always be the same like in the Camunda Model:

My questions here are: how can i get the information which books i can choose via REST? Is that even possible and is that how it should be done?


回答1:


What I understood from your question that you want to access gateway route values and convert it into a drop-down menu before even reaching there. As far as I know it is not possible. Gateways are just the if-else condition to find the execution route. you can create this drop-down list by passing it to the process execution, keeping it in some script or by taking the data through rest apis.




回答2:


There is one option that might help you. The idea is to get the BPMN 2.0 XML of a process definition. And you can parse the xml and get the gateways or any element.

The standard result is a an escaped XML string containing the XML that this definition was deployed with.

Version 7.0 and 7.13

Camunda's API has the following endpoint /process-definition/{id}/xml. It returns the BPMN 2.0 XML of the process defition.

Version 7.13

Added additional endpoints,

Returns the XML for the latest version of the process definition which belongs to no tenant

GET /process-definition/key/{key}/xml

Return the XML for the latest version of the process definition for tenant

GET /process-definition/key/{key}/tenant-id/{tenant-id}/xml

Result

Request

http://localhost:5115/engine-rest/process-definition/Process_16yhb92:1:1605d9ef-be29-11ea-a3af-0242ac160003/xml

Diagram

Your XML should look like the following:

"bpmn20Xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bpmn:definitions xmlns:bpmn=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\" xmlns:dc=\"http://www.omg.org/spec/DD/20100524/DC\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:di=\"http://www.omg.org/spec/DD/20100524/DI\" id=\"Definitions_0tnus7x\" targetNamespace=\"http://bpmn.io/schema/bpmn\" exporter=\"Camunda Modeler\" exporterVersion=\"3.5.0\">\n  <bpmn:process id=\"Process_16yhb92\" isExecutable=\"true\">\n    <bpmn:startEvent id=\"StartEvent_1\">\n      <bpmn:outgoing>SequenceFlow_05h0ut0</bpmn:outgoing>\n    </bpmn:startEvent>\n    **<bpmn:exclusiveGateway id=\"ExclusiveGateway_1\">\n**      
...
...
sourceRef=\"Task_1mivaws\" targetRef=\"ExclusiveGateway_1\" />\n 


来源:https://stackoverflow.com/questions/62634391/camunda-get-opportunities-of-xor-gateway-using-rest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!