Scripting everywhere in camunda BPM example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://activiti.org/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_1KLIwBCfEeS575qdd8CgmQ" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://activiti.org/bpmn"> | |
<bpmn2:process id="scriptingEverywhere" name="Scripting Everywhere Example" isExecutable="true"> | |
<bpmn2:startEvent id="startEvent"> | |
<bpmn2:outgoing>flow1</bpmn2:outgoing> | |
</bpmn2:startEvent> | |
<bpmn2:sequenceFlow id="flow1" sourceRef="startEvent" targetRef="scriptTask"/> | |
<bpmn2:scriptTask id="scriptTask" name="Welcome Message" scriptFormat="groovy"> | |
<bpmn2:extensionElements> | |
<camunda:inputOutput> | |
<camunda:inputParameter name="player"> | |
<!-- script as input parameter --> | |
<camunda:script scriptFormat="groovy"> | |
players = ["Fritz", "Heinz", "Horst", "Klaus"] | |
players[new Random().nextInt(players.size())] | |
</camunda:script> | |
</camunda:inputParameter> | |
</camunda:inputOutput> | |
</bpmn2:extensionElements> | |
<bpmn2:incoming>flow1</bpmn2:incoming> | |
<bpmn2:outgoing>flow2</bpmn2:outgoing> | |
<!-- script as script task --> | |
<bpmn2:script> | |
println "Hello $player! Welcome to our casino" | |
</bpmn2:script> | |
</bpmn2:scriptTask> | |
<bpmn2:sequenceFlow id="flow2" sourceRef="scriptTask" targetRef="gateway"/> | |
<bpmn2:exclusiveGateway id="gateway" name="Dice"> | |
<bpmn2:extensionElements> | |
<camunda:executionListener event="start"> | |
<!-- script as execution listener --> | |
<camunda:script scriptFormat="groovy"> | |
aNumber = new Random().nextInt(6) + 1 | |
println "$aNumber was diced" | |
execution.setVariable('aNumber', aNumber) | |
</camunda:script> | |
</camunda:executionListener> | |
</bpmn2:extensionElements> | |
<bpmn2:incoming>flow2</bpmn2:incoming> | |
<bpmn2:outgoing>flow3</bpmn2:outgoing> | |
<bpmn2:outgoing>flow4</bpmn2:outgoing> | |
</bpmn2:exclusiveGateway> | |
<bpmn2:sequenceFlow id="flow3" name="Greater than 3" sourceRef="gateway" targetRef="userTaskPlayerWins"> | |
<!-- script as sequence flow condition --> | |
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression" language="groovy"> | |
aNumber > 3 | |
</bpmn2:conditionExpression> | |
</bpmn2:sequenceFlow> | |
<bpmn2:userTask id="userTaskPlayerWins" name="Player Wins"> | |
<bpmn2:extensionElements> | |
<camunda:taskListener event="create"> | |
<!-- script as task listener --> | |
<camunda:script scriptFormat="groovy"> | |
println "User task '$task.name' was $task.eventName" | |
</camunda:script> | |
</camunda:taskListener> | |
</bpmn2:extensionElements> | |
<bpmn2:incoming>flow3</bpmn2:incoming> | |
<bpmn2:outgoing>flow5</bpmn2:outgoing> | |
</bpmn2:userTask> | |
<bpmn2:sequenceFlow id="flow4" name="Less then 4" sourceRef="gateway" targetRef="userTaskBankWins"> | |
<!-- script as sequence flow condition --> | |
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression" language="groovy"> | |
<![CDATA[ | |
aNumber < 4 | |
]]> | |
</bpmn2:conditionExpression> | |
</bpmn2:sequenceFlow> | |
<bpmn2:userTask id="userTaskBankWins" name="Bank Wins"> | |
<bpmn2:extensionElements> | |
<camunda:taskListener event="create"> | |
<!-- script as task listener --> | |
<camunda:script scriptFormat="groovy"> | |
println "User task '$task.name' was $task.eventName" | |
</camunda:script> | |
</camunda:taskListener> | |
</bpmn2:extensionElements> | |
<bpmn2:incoming>flow4</bpmn2:incoming> | |
<bpmn2:outgoing>flow6</bpmn2:outgoing> | |
</bpmn2:userTask> | |
<bpmn2:endEvent id="endEventPlayerWins"> | |
<bpmn2:incoming>flow5</bpmn2:incoming> | |
</bpmn2:endEvent> | |
<bpmn2:sequenceFlow id="flow5" name="" sourceRef="userTaskPlayerWins" targetRef="endEventPlayerWins"/> | |
<bpmn2:endEvent id="endEventBankWins"> | |
<bpmn2:incoming>flow6</bpmn2:incoming> | |
</bpmn2:endEvent> | |
<bpmn2:sequenceFlow id="flow6" name="" sourceRef="userTaskBankWins" targetRef="endEventBankWins"/> | |
</bpmn2:process> | |
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | |
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="scriptingEverywhere"> | |
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_17" bpmnElement="startEvent"> | |
<dc:Bounds height="36.0" width="36.0" x="313.0" y="238.0"/> | |
</bpmndi:BPMNShape> | |
<bpmndi:BPMNShape id="_BPMNShape_ScriptTask_2" bpmnElement="scriptTask"> | |
<dc:Bounds height="80.0" width="100.0" x="399.0" y="216.0"/> | |
</bpmndi:BPMNShape> | |
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="flow1" sourceElement="_BPMNShape_StartEvent_17" targetElement="_BPMNShape_ScriptTask_2"> | |
<di:waypoint xsi:type="dc:Point" x="349.0" y="256.0"/> | |
<di:waypoint xsi:type="dc:Point" x="399.0" y="256.0"/> | |
</bpmndi:BPMNEdge> | |
<bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_26" bpmnElement="gateway" isMarkerVisible="true"> | |
<dc:Bounds height="50.0" width="50.0" x="549.0" y="231.0"/> | |
<bpmndi:BPMNLabel> | |
<dc:Bounds height="22.0" width="33.0" x="600.0" y="246.0"/> | |
</bpmndi:BPMNLabel> | |
</bpmndi:BPMNShape> | |
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="flow2" sourceElement="_BPMNShape_ScriptTask_2" targetElement="_BPMNShape_ExclusiveGateway_26"> | |
<di:waypoint xsi:type="dc:Point" x="499.0" y="256.0"/> | |
<di:waypoint xsi:type="dc:Point" x="549.0" y="256.0"/> | |
</bpmndi:BPMNEdge> | |
<bpmndi:BPMNShape id="_BPMNShape_UserTask_8" bpmnElement="userTaskPlayerWins"> | |
<dc:Bounds height="80.0" width="100.0" x="648.0" y="111.0"/> | |
</bpmndi:BPMNShape> | |
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="flow3" sourceElement="_BPMNShape_ExclusiveGateway_26" targetElement="_BPMNShape_UserTask_8"> | |
<di:waypoint xsi:type="dc:Point" x="574.0" y="231.0"/> | |
<di:waypoint xsi:type="dc:Point" x="574.0" y="151.0"/> | |
<di:waypoint xsi:type="dc:Point" x="648.0" y="151.0"/> | |
<bpmndi:BPMNLabel> | |
<dc:Bounds height="22.0" width="89.0" x="531.0" y="120.0"/> | |
</bpmndi:BPMNLabel> | |
</bpmndi:BPMNEdge> | |
<bpmndi:BPMNShape id="_BPMNShape_UserTask_9" bpmnElement="userTaskBankWins"> | |
<dc:Bounds height="80.0" width="100.0" x="648.0" y="336.0"/> | |
</bpmndi:BPMNShape> | |
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="flow4" sourceElement="_BPMNShape_ExclusiveGateway_26" targetElement="_BPMNShape_UserTask_9"> | |
<di:waypoint xsi:type="dc:Point" x="574.0" y="281.0"/> | |
<di:waypoint xsi:type="dc:Point" x="574.0" y="376.0"/> | |
<di:waypoint xsi:type="dc:Point" x="648.0" y="376.0"/> | |
<bpmndi:BPMNLabel> | |
<dc:Bounds height="22.0" width="74.0" x="538.0" y="389.0"/> | |
</bpmndi:BPMNLabel> | |
</bpmndi:BPMNEdge> | |
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_39" bpmnElement="endEventPlayerWins"> | |
<dc:Bounds height="36.0" width="36.0" x="798.0" y="133.0"/> | |
</bpmndi:BPMNShape> | |
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="flow5" sourceElement="_BPMNShape_UserTask_8" targetElement="_BPMNShape_EndEvent_39"> | |
<di:waypoint xsi:type="dc:Point" x="748.0" y="151.0"/> | |
<di:waypoint xsi:type="dc:Point" x="798.0" y="151.0"/> | |
</bpmndi:BPMNEdge> | |
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_40" bpmnElement="endEventBankWins"> | |
<dc:Bounds height="36.0" width="36.0" x="798.0" y="358.0"/> | |
</bpmndi:BPMNShape> | |
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="flow6" sourceElement="_BPMNShape_UserTask_9" targetElement="_BPMNShape_EndEvent_40"> | |
<di:waypoint xsi:type="dc:Point" x="748.0" y="376.0"/> | |
<di:waypoint xsi:type="dc:Point" x="798.0" y="376.0"/> | |
</bpmndi:BPMNEdge> | |
</bpmndi:BPMNPlane> | |
</bpmndi:BPMNDiagram> | |
</bpmn2:definitions> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment