Skip to content

Instantly share code, notes, and snippets.

@pingkunga
Created June 24, 2018 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingkunga/02a641a3c54d6276bd8fffd218fba02e to your computer and use it in GitHub Desktop.
Save pingkunga/02a641a3c54d6276bd8fffd218fba02e to your computer and use it in GitHub Desktop.
BPMN-HttpConnectorRequestGet
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3">
<bpmn:process id="HttpConnectorRequestGet" name="HttpConnectorRequestGet" isExecutable="true" camunda:versionTag="1">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1435fpg</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1435fpg" sourceRef="StartEvent_1" targetRef="Task_0zq32cv" />
<bpmn:endEvent id="EndEvent_186wp1n">
<bpmn:incoming>SequenceFlow_17nx2nk</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_03p4qxe" sourceRef="Task_1dkkumo" targetRef="Task_1sfjjen" />
<bpmn:serviceTask id="Task_1dkkumo" name="Test &#10;REST-API (GET)&#10;">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="url">
<camunda:script scriptFormat="groovy"><![CDATA["https://jsonplaceholder.typicode.com/posts/${PostId}".toString()
]]></camunda:script>
</camunda:inputParameter>
<camunda:inputParameter name="method">GET</camunda:inputParameter>
<camunda:inputParameter name="header">
<camunda:map>
<camunda:entry key="Accept">application/json</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:outputParameter name="postResult">
<camunda:script scriptFormat="groovy"><![CDATA[import groovy.json.JsonSlurper;
jsonResponse= connector.getVariable("response");
out:println "jsonResponse :" + jsonResponse.getClass();
JsonSlurper jsonSlurper = new JsonSlurper();
Object result = jsonSlurper.parseText(jsonResponse);
//Convert to MAP
Map jsonResponseMap = (Map)result ;
//Step Value to Process Engine
connector.setVariable('userId', jsonResponseMap.get("userId"));
connector.setVariable('id', jsonResponseMap.get("id"));
connector.setVariable('title', jsonResponseMap.get("title"));
connector.setVariable('body', jsonResponseMap.get("body"));
//Return JSON to outpur variable
postResult = result;]]></camunda:script>
</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>http-connector</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_13f8xbw</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_03p4qxe</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:userTask id="Task_1sfjjen" name="View Result" camunda:assignee="mary">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="userId" label="userId" type="string" />
<camunda:formField id="id" label="id" type="string" />
<camunda:formField id="title" label="title" type="string" />
<camunda:formField id="body" label="body" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_03p4qxe</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_17nx2nk</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="SequenceFlow_17nx2nk" sourceRef="Task_1sfjjen" targetRef="EndEvent_186wp1n" />
<bpmn:sequenceFlow id="SequenceFlow_13f8xbw" sourceRef="Task_0zq32cv" targetRef="Task_1dkkumo" />
<bpmn:userTask id="Task_0zq32cv" name="Enter Post Id" camunda:assignee="mary">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="PostId" label="PostId" type="long" defaultValue="2" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1435fpg</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_13f8xbw</bpmn:outgoing>
</bpmn:userTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="HttpConnectorRequestGet">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="20" y="94" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="-7" y="130" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1435fpg_di" bpmnElement="SequenceFlow_1435fpg">
<di:waypoint xsi:type="dc:Point" x="56" y="112" />
<di:waypoint xsi:type="dc:Point" x="109" y="112" />
<bpmndi:BPMNLabel>
<dc:Bounds x="82.5" y="91" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_186wp1n_di" bpmnElement="EndEvent_186wp1n">
<dc:Bounds x="523.859" y="94" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="541.859" y="134" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_03p4qxe_di" bpmnElement="SequenceFlow_03p4qxe">
<di:waypoint xsi:type="dc:Point" x="342" y="111" />
<di:waypoint xsi:type="dc:Point" x="384" y="111" />
<bpmndi:BPMNLabel>
<dc:Bounds x="363" y="90" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_01g1tty_di" bpmnElement="Task_1dkkumo">
<dc:Bounds x="242" y="72" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTask_0dz9bh6_di" bpmnElement="Task_1sfjjen">
<dc:Bounds x="384" y="72" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_17nx2nk_di" bpmnElement="SequenceFlow_17nx2nk">
<di:waypoint xsi:type="dc:Point" x="484" y="112" />
<di:waypoint xsi:type="dc:Point" x="524" y="112" />
<bpmndi:BPMNLabel>
<dc:Bounds x="504" y="91" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_13f8xbw_di" bpmnElement="SequenceFlow_13f8xbw">
<di:waypoint xsi:type="dc:Point" x="209" y="112" />
<di:waypoint xsi:type="dc:Point" x="242" y="112" />
<bpmndi:BPMNLabel>
<dc:Bounds x="225.5" y="91" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_03xo9g6_di" bpmnElement="Task_0zq32cv">
<dc:Bounds x="109" y="72" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment