<?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://camunda.org/schema/1.0/bpmn" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
  <bpmn2:collaboration id="Collaboration_12geczp">
    <bpmn2:participant id="Participant_08rb9rc" name="Smardigo Management Action" processRef="smardigo-management-action" />
  </bpmn2:collaboration>
  <bpmn2:process id="smardigo-management-action" name="smardigo-management-action" isExecutable="true">
    <bpmn2:startEvent id="Event_02kqmmg" camunda:asyncAfter="true">
      <bpmn2:outgoing>Flow_1ow8whd</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:scriptTask id="Activity_1olpao9" name="ansible-start.groovy" scriptFormat="groovy" camunda:resource="ansible-start.groovy">
      <bpmn2:incoming>Flow_1ow8whd</bpmn2:incoming>
      <bpmn2:outgoing>Flow_0qfq760</bpmn2:outgoing>
    </bpmn2:scriptTask>
    <bpmn2:task id="Activity_1igdww7" name="AWX Job-Template-ID auslesen">
      <bpmn2:extensionElements>
        <camunda:inputOutput>
          <camunda:outputParameter name="job_template_id">
            <camunda:script scriptFormat="groovy">def templates = datasources.query('awx-job-templates').processScope(contextScopeId, contextProcessId).parameters([name:smardigoManagementAction]).list();

templates.size()==0 ? -1 : templates[0]['id'];</camunda:script>
          </camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn2:extensionElements>
      <bpmn2:incoming>Flow_1xdj53u</bpmn2:incoming>
      <bpmn2:outgoing>Flow_1cnt5hf</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:sequenceFlow id="Flow_1ow8whd" sourceRef="Event_02kqmmg" targetRef="Activity_1olpao9" />
    <bpmn2:sequenceFlow id="Flow_0qfq760" sourceRef="Activity_1olpao9" targetRef="Gateway_0n3j4hy" />
    <bpmn2:sequenceFlow id="Flow_1nqz9ya" sourceRef="Activity_1hwc1va" targetRef="Activity_0wn3csk" />
    <bpmn2:sequenceFlow id="Flow_1kxc9t0" sourceRef="Activity_0wn3csk" targetRef="Activity_12p300g" />
    <bpmn2:sequenceFlow id="Flow_0tmasvl" name="simulation active " sourceRef="Gateway_0n3j4hy" targetRef="Gateway_0p57e80">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${simulation}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="Flow_1cnt5hf" sourceRef="Activity_1igdww7" targetRef="Gateway_11tein2" />
    <bpmn2:sequenceFlow id="Flow_1nuku1o" sourceRef="Activity_12p300g" targetRef="Event_0tax83l" />
    <bpmn2:sequenceFlow id="Flow_0gcsmj7" sourceRef="Event_0tax83l" targetRef="Gateway_0p57e80" />
    <bpmn2:sequenceFlow id="Flow_1rngywr" name="default" sourceRef="Gateway_0n3j4hy" targetRef="Activity_1ewqrs7" />
    <bpmn2:sequenceFlow id="Flow_0npv638" sourceRef="Gateway_0p57e80" targetRef="Activity_136brby" />
    <bpmn2:sequenceFlow id="Flow_1ju13h8" sourceRef="Activity_136brby" targetRef="Event_0hla739" />
    <bpmn2:exclusiveGateway id="Gateway_0n3j4hy" default="Flow_1rngywr">
      <bpmn2:incoming>Flow_0qfq760</bpmn2:incoming>
      <bpmn2:outgoing>Flow_0tmasvl</bpmn2:outgoing>
      <bpmn2:outgoing>Flow_1rngywr</bpmn2:outgoing>
    </bpmn2:exclusiveGateway>
    <bpmn2:callActivity id="Activity_1ewqrs7" name="Management Benachrichtigung senden" calledElement="smardigo-management-message">
      <bpmn2:extensionElements>
        <camunda:in businessKey="#{execution.processBusinessKey}" />
        <camunda:in variables="all" />
        <camunda:in sourceExpression="Neue Aufgabe" target="activityTitle" />
        <camunda:in sourceExpression="${smardigoManagementAction}" target="activitySubtitle" />
        <camunda:in source="simulation" target="simulation" />
      </bpmn2:extensionElements>
      <bpmn2:incoming>Flow_1rngywr</bpmn2:incoming>
      <bpmn2:outgoing>Flow_1xdj53u</bpmn2:outgoing>
    </bpmn2:callActivity>
    <bpmn2:sequenceFlow id="Flow_1xdj53u" sourceRef="Activity_1ewqrs7" targetRef="Activity_1igdww7" />
    <bpmn2:sequenceFlow id="Flow_065a4cq" name="job_template_id found" sourceRef="Gateway_11tein2" targetRef="Activity_1hwc1va">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${job_template_id != -1}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:exclusiveGateway id="Gateway_0p57e80">
      <bpmn2:incoming>Flow_0gcsmj7</bpmn2:incoming>
      <bpmn2:incoming>Flow_0tmasvl</bpmn2:incoming>
      <bpmn2:outgoing>Flow_0npv638</bpmn2:outgoing>
    </bpmn2:exclusiveGateway>
    <bpmn2:endEvent id="Event_0hla739">
      <bpmn2:incoming>Flow_1ju13h8</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:scriptTask id="Activity_136brby" name="ansible-end.groovy" scriptFormat="groovy" camunda:resource="ansible-end.groovy">
      <bpmn2:incoming>Flow_0npv638</bpmn2:incoming>
      <bpmn2:outgoing>Flow_1ju13h8</bpmn2:outgoing>
    </bpmn2:scriptTask>
    <bpmn2:intermediateCatchEvent id="Event_0tax83l" name="Ausführung der Aktion abwarten">
      <bpmn2:incoming>Flow_1nuku1o</bpmn2:incoming>
      <bpmn2:outgoing>Flow_0gcsmj7</bpmn2:outgoing>
      <bpmn2:messageEventDefinition id="MessageEventDefinition_193tmaa" messageRef="Message_13oyyv2" />
    </bpmn2:intermediateCatchEvent>
    <bpmn2:scriptTask id="Activity_12p300g" name="Aktuelle Job Id übernehmen" scriptFormat="groovy">
      <bpmn2:incoming>Flow_1kxc9t0</bpmn2:incoming>
      <bpmn2:outgoing>Flow_1nuku1o</bpmn2:outgoing>
      <bpmn2:script>def jobs = processes.byId(contextScopeId, contextProcessId).getVariable('jobs')
jobs = !!jobs ? jobs : []
jobs.add(0, awxResponse.job)
processes.byId(contextScopeId, contextProcessId).setVariable('jobs', jobs)
processes.byId(contextScopeId, contextProcessId).setVariable('current_job_id', awxResponse.job)
processes.byId(contextScopeId, contextProcessId).createComment('current_job_id := ' + awxResponse.job)</bpmn2:script>
    </bpmn2:scriptTask>
    <bpmn2:task id="Activity_1hwc1va" name="AWX REST-Parameter erzeugen">
      <bpmn2:extensionElements>
        <camunda:inputOutput>
          <camunda:outputParameter name="awxPath">/api/v2/job_templates/${job_template_id}/launch/</camunda:outputParameter>
          <camunda:outputParameter name="extra_vars">
            <camunda:script scriptFormat="groovy" resource="create-awx-parameters.groovy" />
          </camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn2:extensionElements>
      <bpmn2:incoming>Flow_065a4cq</bpmn2:incoming>
      <bpmn2:outgoing>Flow_1nqz9ya</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:serviceTask id="Activity_0wn3csk" name="AWX Provisionierung starten" camunda:delegateExpression="${rest.post(&#39;awx&#39;, awxPath).responseJSONObject(&#39;awxResponse&#39;).bodyJSONMap(awxRequestBody)}">
      <bpmn2:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="awxRequestBody">
            <camunda:map>
              <camunda:entry key="extra_vars">${extra_vars}</camunda:entry>
            </camunda:map>
          </camunda:inputParameter>
        </camunda:inputOutput>
      </bpmn2:extensionElements>
      <bpmn2:incoming>Flow_1nqz9ya</bpmn2:incoming>
      <bpmn2:outgoing>Flow_1kxc9t0</bpmn2:outgoing>
    </bpmn2:serviceTask>
    <bpmn2:exclusiveGateway id="Gateway_11tein2">
      <bpmn2:incoming>Flow_1cnt5hf</bpmn2:incoming>
      <bpmn2:outgoing>Flow_065a4cq</bpmn2:outgoing>
      <bpmn2:outgoing>Flow_0mtnk56</bpmn2:outgoing>
    </bpmn2:exclusiveGateway>
    <bpmn2:sequenceFlow id="Flow_0mtnk56" name="job_template_id not found" sourceRef="Gateway_11tein2" targetRef="Event_1bfppnu">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${job_template_id == -1}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:endEvent id="Event_1bfppnu">
      <bpmn2:incoming>Flow_0mtnk56</bpmn2:incoming>
      <bpmn2:errorEventDefinition id="ErrorEventDefinition_1ww36kh" errorRef="Error_1m76bd5" />
    </bpmn2:endEvent>
    <bpmn2:textAnnotation id="TextAnnotation_0bt6e0d">
      <bpmn2:text>Anmerkung
* teams-Benachrichtigung nur, wenn teams_channel_url exisitiert</bpmn2:text>
    </bpmn2:textAnnotation>
  </bpmn2:process>
  <bpmn2:message id="Message_13oyyv2" name="action-executed-${execution.getVariable(&#39;smardigoManagementAction&#39;)}" />
  <bpmn2:error id="Error_1m76bd5" name="job_template_id not found" errorCode="10" camunda:errorMessage="job_template_id not found" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_12geczp">
      <bpmndi:BPMNShape id="Participant_08rb9rc_di" bpmnElement="Participant_08rb9rc" isHorizontal="true">
        <dc:Bounds x="350" y="150" width="1700" height="460" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_02kqmmg_di" bpmnElement="Event_02kqmmg">
        <dc:Bounds x="402" y="392" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1olpao9_di" bpmnElement="Activity_1olpao9">
        <dc:Bounds x="470" y="370" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1igdww7_di" bpmnElement="Activity_1igdww7">
        <dc:Bounds x="880" y="370" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_0n3j4hy_di" bpmnElement="Gateway_0n3j4hy" isMarkerVisible="true">
        <dc:Bounds x="605" y="385" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1ewqrs7_di" bpmnElement="Activity_1ewqrs7" bioc:stroke="rgb(67, 160, 71)" bioc:fill="rgb(200, 230, 201)">
        <dc:Bounds x="720" y="370" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_0p57e80_di" bpmnElement="Gateway_0p57e80" isMarkerVisible="true">
        <dc:Bounds x="1715" y="385" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0kni7xh_di" bpmnElement="Event_0hla739">
        <dc:Bounds x="1952" y="392" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_136brby_di" bpmnElement="Activity_136brby">
        <dc:Bounds x="1810" y="370" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0tax83l_di" bpmnElement="Event_0tax83l">
        <dc:Bounds x="1622" y="392" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1604" y="436" width="79" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0bu6o2b_di" bpmnElement="Activity_12p300g">
        <dc:Bounds x="1480" y="370" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1hwc1va_di" bpmnElement="Activity_1hwc1va">
        <dc:Bounds x="1200" y="370" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0wn3csk_di" bpmnElement="Activity_0wn3csk">
        <dc:Bounds x="1340" y="370" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_11tein2_di" bpmnElement="Gateway_11tein2" isMarkerVisible="true">
        <dc:Bounds x="1045" y="385" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="TextAnnotation_0bt6e0d_di" bpmnElement="TextAnnotation_0bt6e0d">
        <dc:Bounds x="390" y="240" width="355" height="58" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_10n5few_di" bpmnElement="Event_1bfppnu">
        <dc:Bounds x="1052" y="242" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_1ow8whd_di" bpmnElement="Flow_1ow8whd">
        <di:waypoint x="438" y="410" />
        <di:waypoint x="470" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0qfq760_di" bpmnElement="Flow_0qfq760">
        <di:waypoint x="570" y="410" />
        <di:waypoint x="605" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1nqz9ya_di" bpmnElement="Flow_1nqz9ya">
        <di:waypoint x="1300" y="410" />
        <di:waypoint x="1340" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1kxc9t0_di" bpmnElement="Flow_1kxc9t0">
        <di:waypoint x="1440" y="410" />
        <di:waypoint x="1480" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0tmasvl_di" bpmnElement="Flow_0tmasvl">
        <di:waypoint x="630" y="435" />
        <di:waypoint x="630" y="550" />
        <di:waypoint x="1740" y="550" />
        <di:waypoint x="1740" y="435" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="648" y="533" width="82" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1cnt5hf_di" bpmnElement="Flow_1cnt5hf">
        <di:waypoint x="980" y="410" />
        <di:waypoint x="1045" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1nuku1o_di" bpmnElement="Flow_1nuku1o">
        <di:waypoint x="1580" y="410" />
        <di:waypoint x="1622" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0gcsmj7_di" bpmnElement="Flow_0gcsmj7">
        <di:waypoint x="1658" y="410" />
        <di:waypoint x="1715" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1rngywr_di" bpmnElement="Flow_1rngywr">
        <di:waypoint x="655" y="410" />
        <di:waypoint x="720" y="410" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="666" y="413" width="34" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0npv638_di" bpmnElement="Flow_0npv638">
        <di:waypoint x="1765" y="410" />
        <di:waypoint x="1810" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1ju13h8_di" bpmnElement="Flow_1ju13h8">
        <di:waypoint x="1910" y="410" />
        <di:waypoint x="1952" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1xdj53u_di" bpmnElement="Flow_1xdj53u">
        <di:waypoint x="820" y="410" />
        <di:waypoint x="880" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_065a4cq_di" bpmnElement="Flow_065a4cq">
        <di:waypoint x="1095" y="410" />
        <di:waypoint x="1200" y="410" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1101" y="426" width="78" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0mtnk56_di" bpmnElement="Flow_0mtnk56">
        <di:waypoint x="1070" y="385" />
        <di:waypoint x="1070" y="278" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1081" y="296" width="78" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn2:definitions>
