<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_ResultsReport" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:collaboration id="Collaboration_ResultsReport">
    <bpmn:participant id="Participant_Platform" name="結果與報告｜既有完成後處理" processRef="Process_ResultsReport" />
    <bpmn:participant id="Participant_Mail" name="郵件服務（黑箱）" />
    <bpmn:messageFlow id="Flow_SendToMail" name="提交 Email" sourceRef="Activity_Send" targetRef="Participant_Mail" />
  </bpmn:collaboration>
  <bpmn:process id="Process_ResultsReport" name="結果與報告｜既有完成後處理" isExecutable="false">
    <bpmn:laneSet id="LaneSet_ResultsReport">
      <bpmn:lane id="Lane_Run" name="Northstar＋Sentry">
        <bpmn:flowNodeRef>Event_Start</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Activity_Artifacts</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gateway_Coverage</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Activity_Coverage</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gateway_Report</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Activity_Request</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Activity_Log</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Event_End</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Event_ReportError</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gateway_MergeEnd</bpmn:flowNodeRef>
      </bpmn:lane>
      <bpmn:lane id="Lane_Crystal" name="Crystal 報告服務">
        <bpmn:flowNodeRef>Activity_Aggregate</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Activity_Send</bpmn:flowNodeRef>
      </bpmn:lane>
    </bpmn:laneSet>
    <bpmn:startEvent id="Event_Start" name="Run 主流程正常完成">
      <bpmn:outgoing>Flow_StartToArtifacts</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_StartToArtifacts" sourceRef="Event_Start" targetRef="Activity_Artifacts" />
    <bpmn:serviceTask id="Activity_Artifacts" name="嘗試上傳 SQL 比對產物">
      <bpmn:incoming>Flow_StartToArtifacts</bpmn:incoming>
      <bpmn:outgoing>Flow_ArtifactsToCoverage</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_ArtifactsToCoverage" sourceRef="Activity_Artifacts" targetRef="Gateway_Coverage" />
    <bpmn:exclusiveGateway id="Gateway_Coverage" name="符合覆蓋率條件?" default="Flow_CoverageToReport">
      <bpmn:incoming>Flow_ArtifactsToCoverage</bpmn:incoming>
      <bpmn:outgoing>Flow_CoverageToCoverage</bpmn:outgoing>
      <bpmn:outgoing>Flow_CoverageToReport</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_CoverageToCoverage" name="SYSTEM_USER 或 needsCoverage=Y" sourceRef="Gateway_Coverage" targetRef="Activity_Coverage">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">coverageRequested</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_CoverageToReport" name="不需" sourceRef="Gateway_Coverage" targetRef="Gateway_Report" />
    <bpmn:serviceTask id="Activity_Coverage" name="嘗試上傳覆蓋率">
      <bpmn:incoming>Flow_CoverageToCoverage</bpmn:incoming>
      <bpmn:outgoing>Flow_CoverageToReport_2</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_CoverageToReport_2" sourceRef="Activity_Coverage" targetRef="Gateway_Report" />
    <bpmn:exclusiveGateway id="Gateway_Report" name="符合寄信條件?" default="Flow_ReportToMergeEnd">
      <bpmn:incoming>Flow_CoverageToReport</bpmn:incoming>
      <bpmn:incoming>Flow_CoverageToReport_2</bpmn:incoming>
      <bpmn:outgoing>Flow_ReportToRequest</bpmn:outgoing>
      <bpmn:outgoing>Flow_ReportToMergeEnd</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_ReportToRequest" name="SYSTEM_USER 或 needsSendReport=Y" sourceRef="Gateway_Report" targetRef="Activity_Request">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">reportRequested</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_ReportToMergeEnd" name="不需" sourceRef="Gateway_Report" targetRef="Gateway_MergeEnd" />
    <bpmn:serviceTask id="Activity_Request" name="請求單次 Run 報告">
      <bpmn:incoming>Flow_ReportToRequest</bpmn:incoming>
      <bpmn:outgoing>Flow_RequestToAggregate</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_RequestToAggregate" sourceRef="Activity_Request" targetRef="Activity_Aggregate" />
    <bpmn:boundaryEvent id="Event_ReportError" name="報告請求失敗" attachedToRef="Activity_Request">
      <bpmn:outgoing>Flow_ReportErrorToLog</bpmn:outgoing>
      <bpmn:errorEventDefinition errorRef="Error_Error" />
    </bpmn:boundaryEvent>
    <bpmn:sequenceFlow id="Flow_ReportErrorToLog" sourceRef="Event_ReportError" targetRef="Activity_Log" />
    <bpmn:serviceTask id="Activity_Aggregate" name="彙整本次群組與案例">
      <bpmn:incoming>Flow_RequestToAggregate</bpmn:incoming>
      <bpmn:outgoing>Flow_AggregateToSend</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_AggregateToSend" sourceRef="Activity_Aggregate" targetRef="Activity_Send" />
    <bpmn:serviceTask id="Activity_Send" name="提交報告寄送">
      <bpmn:incoming>Flow_AggregateToSend</bpmn:incoming>
      <bpmn:outgoing>Flow_SendToMergeEnd</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_SendToMergeEnd" sourceRef="Activity_Send" targetRef="Gateway_MergeEnd" />
    <bpmn:serviceTask id="Activity_Log" name="記錄報告失敗日誌">
      <bpmn:incoming>Flow_ReportErrorToLog</bpmn:incoming>
      <bpmn:outgoing>Flow_LogToMergeEnd</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_LogToMergeEnd" sourceRef="Activity_Log" targetRef="Gateway_MergeEnd" />
    <bpmn:endEvent id="Event_End" name="後處理結束">
      <bpmn:incoming>Flow_MergeEndToEnd</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:exclusiveGateway id="Gateway_MergeEnd">
      <bpmn:incoming>Flow_ReportToMergeEnd</bpmn:incoming>
      <bpmn:incoming>Flow_SendToMergeEnd</bpmn:incoming>
      <bpmn:incoming>Flow_LogToMergeEnd</bpmn:incoming>
      <bpmn:outgoing>Flow_MergeEndToEnd</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_MergeEndToEnd" sourceRef="Gateway_MergeEnd" targetRef="Event_End" />
  </bpmn:process>
  <bpmn:error id="Error_Error" name="報告請求失敗" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_Collaboration_ResultsReport">
    <bpmndi:BPMNPlane id="BPMNPlane_Collaboration_ResultsReport" bpmnElement="Collaboration_ResultsReport">
      <bpmndi:BPMNShape id="BPMNShape_Participant_Platform" bpmnElement="Participant_Platform" isHorizontal="true">
        <dc:Bounds x="80" y="80" width="1555" height="444" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Lane_Run" bpmnElement="Lane_Run" isHorizontal="true">
        <dc:Bounds x="110" y="80" width="1525" height="304" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Lane_Crystal" bpmnElement="Lane_Crystal" isHorizontal="true">
        <dc:Bounds x="110" y="384" width="1525" height="140" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Event_Start" bpmnElement="Event_Start">
        <dc:Bounds x="170" y="137" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="144" y="179" width="89" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Artifacts" bpmnElement="Activity_Artifacts">
        <dc:Bounds x="266" y="115" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Gateway_Coverage" bpmnElement="Gateway_Coverage" isMarkerVisible="true">
        <dc:Bounds x="426" y="130" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="417" y="110" width="68" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Coverage" bpmnElement="Activity_Coverage">
        <dc:Bounds x="614" y="115" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Gateway_Report" bpmnElement="Gateway_Report" isMarkerVisible="true">
        <dc:Bounds x="774" y="130" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="769" y="110" width="61" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Request" bpmnElement="Activity_Request">
        <dc:Bounds x="973" y="115" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Event_ReportError" bpmnElement="Event_ReportError">
        <dc:Bounds x="1030" y="177" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1070" y="197" width="54" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Aggregate" bpmnElement="Activity_Aggregate">
        <dc:Bounds x="1133" y="414" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Send" bpmnElement="Activity_Send">
        <dc:Bounds x="1293" y="414" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Log" bpmnElement="Activity_Log">
        <dc:Bounds x="1133" y="274" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Event_End" bpmnElement="Event_End">
        <dc:Bounds x="1563" y="137" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1558" y="179" width="47" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Gateway_MergeEnd" bpmnElement="Gateway_MergeEnd" isMarkerVisible="true">
        <dc:Bounds x="1453" y="130" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_StartToArtifacts" bpmnElement="Flow_StartToArtifacts">
        <di:waypoint x="206" y="155" />
        <di:waypoint x="266" y="155" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_ArtifactsToCoverage" bpmnElement="Flow_ArtifactsToCoverage">
        <di:waypoint x="366" y="155" />
        <di:waypoint x="426" y="155" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_CoverageToCoverage" bpmnElement="Flow_CoverageToCoverage">
        <di:waypoint x="476" y="155" />
        <di:waypoint x="614" y="155" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="487" y="123" width="117" height="28" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_CoverageToReport" bpmnElement="Flow_CoverageToReport">
        <di:waypoint x="451" y="180" />
        <di:waypoint x="451" y="444" />
        <di:waypoint x="799" y="444" />
        <di:waypoint x="799" y="180" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="459" y="426" width="26" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_CoverageToReport_2" bpmnElement="Flow_CoverageToReport_2">
        <di:waypoint x="714" y="155" />
        <di:waypoint x="774" y="155" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_ReportToRequest" bpmnElement="Flow_ReportToRequest">
        <di:waypoint x="824" y="155" />
        <di:waypoint x="973" y="155" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="832" y="123" width="131" height="28" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_ReportToMergeEnd" bpmnElement="Flow_ReportToMergeEnd">
        <di:waypoint x="799" y="180" />
        <di:waypoint x="799" y="384" />
        <di:waypoint x="1478" y="384" />
        <di:waypoint x="1478" y="180" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="807" y="366" width="26" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_RequestToAggregate" bpmnElement="Flow_RequestToAggregate">
        <di:waypoint x="993" y="195" />
        <di:waypoint x="993" y="454" />
        <di:waypoint x="1133" y="454" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_ReportErrorToLog" bpmnElement="Flow_ReportErrorToLog">
        <di:waypoint x="1048" y="213" />
        <di:waypoint x="1048" y="314" />
        <di:waypoint x="1133" y="314" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_AggregateToSend" bpmnElement="Flow_AggregateToSend">
        <di:waypoint x="1233" y="454" />
        <di:waypoint x="1293" y="454" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_SendToMergeEnd" bpmnElement="Flow_SendToMergeEnd">
        <di:waypoint x="1393" y="454" />
        <di:waypoint x="1478" y="454" />
        <di:waypoint x="1478" y="180" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_LogToMergeEnd" bpmnElement="Flow_LogToMergeEnd">
        <di:waypoint x="1233" y="314" />
        <di:waypoint x="1478" y="314" />
        <di:waypoint x="1478" y="180" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_MergeEndToEnd" bpmnElement="Flow_MergeEndToEnd">
        <di:waypoint x="1503" y="155" />
        <di:waypoint x="1563" y="155" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="BPMNShape_Participant_Mail" bpmnElement="Participant_Mail" isHorizontal="true">
        <dc:Bounds x="80" y="604" width="1555" height="60" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_SendToMail" bpmnElement="Flow_SendToMail">
        <di:waypoint x="1343" y="494" />
        <di:waypoint x="1343" y="604" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1349" y="557" width="60" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
