Skip to content

Instantly share code, notes, and snippets.

@pingkunga
Created July 7, 2018 15:05
Show Gist options
  • Select an option

  • Save pingkunga/9ad0ce06fdcfa88839ea397c7d60ce34 to your computer and use it in GitHub Desktop.

Select an option

Save pingkunga/9ad0ce06fdcfa88839ea397c7d60ce34 to your computer and use it in GitHub Desktop.
HttpConnectorRequestPatch
<?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="HttpConnectorRequestPatch" name="HttpConnectorRequestPatch" 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_1vry191</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["http://localhost:3000/requests/${RequestId}".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('id', jsonResponseMap.get("id"));
connector.setVariable('projectId', jsonResponseMap.get("projectId"));
connector.setVariable('requestId', jsonResponseMap.get("requestId"));
connector.setVariable('requestby', jsonResponseMap.get("requestby"));
connector.setVariable('requeststatus', jsonResponseMap.get("requeststatus"));
//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="projectId" label="projectId" type="string" />
<camunda:formField id="requestId" label="requestId" type="string" />
<camunda:formField id="requestby" label="requestby" type="string" />
<camunda:formField id="requeststatus" label="requeststatus" type="string" />
<camunda:formField id="id" label="id" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_03p4qxe</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1x13z2l</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="SequenceFlow_13f8xbw" sourceRef="Task_0zq32cv" targetRef="Task_1dkkumo" />
<bpmn:userTask id="Task_0zq32cv" name="Enter Request Id" camunda:assignee="mary">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="RequestId" label="RequestId" type="long" defaultValue="2" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1435fpg</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_13f8xbw</bpmn:outgoing>
</bpmn:userTask>
<bpmn:serviceTask id="Task_1y1oxu5" name="REST-API&#10;(PATCH)&#10;request status">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="url">
<camunda:script scriptFormat="groovy"><![CDATA["http://localhost:3000/requests/${id}".toString()]]></camunda:script>
</camunda:inputParameter>
<camunda:inputParameter name="method">PATCH</camunda:inputParameter>
<camunda:inputParameter name="header">
<camunda:map>
<camunda:entry key="accept">application/json</camunda:entry>
<camunda:entry key="Content-Type">application/json</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="payload">
<camunda:script scriptFormat="groovy"><![CDATA[import groovy.json.JsonOutput;
def payload = [ 'requeststatus': 'completed' ];
//JsonOutput.prettyPrint(JsonOutput.toJson(payload));
JsonOutput.toJson(payload);]]></camunda:script>
</camunda:inputParameter>
<camunda:outputParameter name="statusCode">
<camunda:script scriptFormat="groovy"><![CDATA[out:println "response:" + response;
out:println "statusCode:" + statusCode;]]></camunda:script>
</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>http-connector</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1x13z2l</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1vry191</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="SequenceFlow_1x13z2l" sourceRef="Task_1sfjjen" targetRef="Task_1y1oxu5" />
<bpmn:sequenceFlow id="SequenceFlow_1vry191" sourceRef="Task_1y1oxu5" targetRef="EndEvent_186wp1n" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="HttpConnectorRequestPatch">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="-101" y="94" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="-128" 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="-65" y="112" />
<di:waypoint xsi:type="dc:Point" x="-35" y="112" />
<bpmndi:BPMNLabel>
<dc:Bounds x="-95" y="91" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_186wp1n_di" bpmnElement="EndEvent_186wp1n">
<dc:Bounds x="491" y="94" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="464" y="134" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_03p4qxe_di" bpmnElement="SequenceFlow_03p4qxe">
<di:waypoint xsi:type="dc:Point" x="192" y="112" />
<di:waypoint xsi:type="dc:Point" x="225" y="112" />
<bpmndi:BPMNLabel>
<dc:Bounds x="163.5" y="91" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_01g1tty_di" bpmnElement="Task_1dkkumo">
<dc:Bounds x="92" y="72" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTask_0dz9bh6_di" bpmnElement="Task_1sfjjen">
<dc:Bounds x="225" y="72" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_13f8xbw_di" bpmnElement="SequenceFlow_13f8xbw">
<di:waypoint xsi:type="dc:Point" x="65" y="112" />
<di:waypoint xsi:type="dc:Point" x="92" y="112" />
<bpmndi:BPMNLabel>
<dc:Bounds x="33.5" y="91" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_03xo9g6_di" bpmnElement="Task_0zq32cv">
<dc:Bounds x="-35" y="72" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_07lxnv4_di" bpmnElement="Task_1y1oxu5">
<dc:Bounds x="352" y="72" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1x13z2l_di" bpmnElement="SequenceFlow_1x13z2l">
<di:waypoint xsi:type="dc:Point" x="325" y="112" />
<di:waypoint xsi:type="dc:Point" x="352" y="112" />
<bpmndi:BPMNLabel>
<dc:Bounds x="338.5" y="91" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1vry191_di" bpmnElement="SequenceFlow_1vry191">
<di:waypoint xsi:type="dc:Point" x="452" y="112" />
<di:waypoint xsi:type="dc:Point" x="491" y="112" />
<bpmndi:BPMNLabel>
<dc:Bounds x="426.5" y="91" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment