<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="@bpmnkit/core" exporterVersion="0.0.23" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.9.0">
  <bpmn:process id="four-eyes-review" name="Four-Eyes Change Review" isExecutable="true">
    <bpmn:extensionElements>
      <zeebe:versionTag value="1.0.0"/>
    </bpmn:extensionElements>
    <bpmn:startEvent id="change-requested" name="Change requested">
      <bpmn:outgoing>Flow_change-requested_start-count</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:scriptTask id="start-count" name="Start revision count">
      <bpmn:extensionElements>
        <zeebe:script expression="=0" resultVariable="revisions"/>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_change-requested_start-count</bpmn:incoming>
      <bpmn:outgoing>Flow_start-count_prepare-merge</bpmn:outgoing>
    </bpmn:scriptTask>
    <bpmn:exclusiveGateway id="prepare-merge">
      <bpmn:incoming>Flow_start-count_prepare-merge</bpmn:incoming>
      <bpmn:incoming>Flow_limit-reached_prepare-merge</bpmn:incoming>
      <bpmn:outgoing>Flow_prepare-merge_prepare-change</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:userTask id="prepare-change" name="Prepare change">
      <bpmn:extensionElements>
        <zeebe:userTask/>
        <zeebe:assignmentDefinition candidateGroups="makers"/>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_prepare-merge_prepare-change</bpmn:incoming>
      <bpmn:outgoing>Flow_prepare-change_check-change</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:userTask id="check-change" name="Check change">
      <bpmn:extensionElements>
        <zeebe:userTask/>
        <zeebe:assignmentDefinition candidateGroups="checkers"/>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_prepare-change_check-change</bpmn:incoming>
      <bpmn:outgoing>Flow_check-change_approved</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:exclusiveGateway id="approved" name="Approved?" default="Flow_approved_count-revision">
      <bpmn:incoming>Flow_check-change_approved</bpmn:incoming>
      <bpmn:outgoing>Flow_approved_apply-change</bpmn:outgoing>
      <bpmn:outgoing>Flow_approved_count-revision</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:serviceTask id="apply-change" name="Apply change">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="change-apply"/>
        <zeebe:ioMapping>
          <zeebe:output source="=changeRef" target="changeRef"/>
        </zeebe:ioMapping>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_approved_apply-change</bpmn:incoming>
      <bpmn:outgoing>Flow_apply-change_change-applied</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="change-applied" name="Change applied">
      <bpmn:incoming>Flow_apply-change_change-applied</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:scriptTask id="count-revision" name="Count revision">
      <bpmn:extensionElements>
        <zeebe:script expression="=revisions + 1" resultVariable="revisions"/>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_approved_count-revision</bpmn:incoming>
      <bpmn:outgoing>Flow_count-revision_limit-reached</bpmn:outgoing>
    </bpmn:scriptTask>
    <bpmn:exclusiveGateway id="limit-reached" name="Three rounds?" default="Flow_limit-reached_prepare-merge">
      <bpmn:incoming>Flow_count-revision_limit-reached</bpmn:incoming>
      <bpmn:outgoing>Flow_limit-reached_change-board</bpmn:outgoing>
      <bpmn:outgoing>Flow_limit-reached_prepare-merge</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:userTask id="change-board" name="Decide at change board">
      <bpmn:extensionElements>
        <zeebe:userTask/>
        <zeebe:assignmentDefinition candidateGroups="change-board"/>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_limit-reached_change-board</bpmn:incoming>
      <bpmn:outgoing>Flow_change-board_escalated</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:endEvent id="escalated" name="Escalated">
      <bpmn:incoming>Flow_change-board_escalated</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_change-requested_start-count" sourceRef="change-requested" targetRef="start-count"/>
    <bpmn:sequenceFlow id="Flow_start-count_prepare-merge" sourceRef="start-count" targetRef="prepare-merge"/>
    <bpmn:sequenceFlow id="Flow_prepare-merge_prepare-change" sourceRef="prepare-merge" targetRef="prepare-change"/>
    <bpmn:sequenceFlow id="Flow_prepare-change_check-change" sourceRef="prepare-change" targetRef="check-change"/>
    <bpmn:sequenceFlow id="Flow_check-change_approved" sourceRef="check-change" targetRef="approved"/>
    <bpmn:sequenceFlow id="Flow_approved_apply-change" sourceRef="approved" targetRef="apply-change" name="yes">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=checkApproved</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_apply-change_change-applied" sourceRef="apply-change" targetRef="change-applied"/>
    <bpmn:sequenceFlow id="Flow_approved_count-revision" sourceRef="approved" targetRef="count-revision" name="no"/>
    <bpmn:sequenceFlow id="Flow_count-revision_limit-reached" sourceRef="count-revision" targetRef="limit-reached"/>
    <bpmn:sequenceFlow id="Flow_limit-reached_change-board" sourceRef="limit-reached" targetRef="change-board" name="escalate">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=revisions &gt;= 3</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_change-board_escalated" sourceRef="change-board" targetRef="escalated"/>
    <bpmn:sequenceFlow id="Flow_limit-reached_prepare-merge" sourceRef="limit-reached" targetRef="prepare-merge" name="revise"/>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="four-eyes-review_di">
    <bpmndi:BPMNPlane id="four-eyes-review_di_plane" bpmnElement="four-eyes-review">
      <bpmndi:BPMNShape id="change-requested_di" bpmnElement="change-requested">
        <dc:Bounds x="58" y="42" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="20" y="82" width="112" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="start-count_di" bpmnElement="start-count">
        <dc:Bounds x="194" y="20" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="prepare-merge_di" bpmnElement="prepare-merge">
        <dc:Bounds x="394" y="35" width="50" height="50"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="prepare-change_di" bpmnElement="prepare-change">
        <dc:Bounds x="544" y="20" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="check-change_di" bpmnElement="check-change">
        <dc:Bounds x="744" y="20" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="approved_di" bpmnElement="approved">
        <dc:Bounds x="944" y="35" width="50" height="50"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="938" y="89" width="63" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="apply-change_di" bpmnElement="apply-change">
        <dc:Bounds x="1094" y="180" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="change-applied_di" bpmnElement="change-applied">
        <dc:Bounds x="1301" y="202" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1270" y="242" width="98" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="count-revision_di" bpmnElement="count-revision">
        <dc:Bounds x="1094" y="20" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="limit-reached_di" bpmnElement="limit-reached">
        <dc:Bounds x="1294" y="35" width="50" height="50"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1274" y="89" width="91" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="change-board_di" bpmnElement="change-board">
        <dc:Bounds x="1444" y="20" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="escalated_di" bpmnElement="escalated">
        <dc:Bounds x="1644" y="42" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1631" y="82" width="63" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_change-requested_start-count_di" bpmnElement="Flow_change-requested_start-count">
        <di:waypoint x="94" y="60"/>
        <di:waypoint x="194" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_start-count_prepare-merge_di" bpmnElement="Flow_start-count_prepare-merge">
        <di:waypoint x="294" y="60"/>
        <di:waypoint x="394" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_prepare-merge_prepare-change_di" bpmnElement="Flow_prepare-merge_prepare-change">
        <di:waypoint x="444" y="60"/>
        <di:waypoint x="544" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_prepare-change_check-change_di" bpmnElement="Flow_prepare-change_check-change">
        <di:waypoint x="644" y="60"/>
        <di:waypoint x="744" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_check-change_approved_di" bpmnElement="Flow_check-change_approved">
        <di:waypoint x="844" y="60"/>
        <di:waypoint x="944" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_approved_apply-change_di" bpmnElement="Flow_approved_apply-change">
        <di:waypoint x="969" y="85"/>
        <di:waypoint x="969" y="220"/>
        <di:waypoint x="1094" y="220"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="945" y="146" width="40" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_apply-change_change-applied_di" bpmnElement="Flow_apply-change_change-applied">
        <di:waypoint x="1194" y="220"/>
        <di:waypoint x="1301" y="220"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_approved_count-revision_di" bpmnElement="Flow_approved_count-revision">
        <di:waypoint x="994" y="60"/>
        <di:waypoint x="1094" y="60"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1024" y="36" width="40" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_count-revision_limit-reached_di" bpmnElement="Flow_count-revision_limit-reached">
        <di:waypoint x="1194" y="60"/>
        <di:waypoint x="1294" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_limit-reached_change-board_di" bpmnElement="Flow_limit-reached_change-board">
        <di:waypoint x="1344" y="60"/>
        <di:waypoint x="1444" y="60"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1366" y="36" width="56" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_change-board_escalated_di" bpmnElement="Flow_change-board_escalated">
        <di:waypoint x="1544" y="60"/>
        <di:waypoint x="1644" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_limit-reached_prepare-merge_di" bpmnElement="Flow_limit-reached_prepare-merge">
        <di:waypoint x="1319" y="35"/>
        <di:waypoint x="1319" y="-20"/>
        <di:waypoint x="419" y="-20"/>
        <di:waypoint x="419" y="35"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="848" y="-44" width="42" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

