<?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" id="Definitions_Capstone" targetNamespace="https://uisi.ac.id/bpmn-tutorial">
  <bpmn:collaboration id="Collaboration_Order" name="Pemenuhan Pesanan E-Commerce">
    <bpmn:participant id="Participant_Customer" name="Customer" />
    <bpmn:participant id="Participant_Merchant" name="Merchant" processRef="Process_Merchant" />
    <bpmn:participant id="Participant_Payment" name="Payment Provider" />
    <bpmn:participant id="Participant_Warehouse" name="Warehouse" />
    <bpmn:participant id="Participant_Shipping" name="Shipping Provider" />
    <bpmn:messageFlow id="Message_Order" name="Order" sourceRef="Participant_Customer" targetRef="Start_Order" />
    <bpmn:messageFlow id="Message_PaymentRequest" name="Payment request" sourceRef="Task_RequestPayment" targetRef="Participant_Payment" />
    <bpmn:messageFlow id="Message_PaymentResult" name="Payment result" sourceRef="Participant_Payment" targetRef="Catch_Payment" />
    <bpmn:messageFlow id="Message_WarehouseRequest" name="Fulfillment request" sourceRef="Task_ReserveStock" targetRef="Participant_Warehouse" />
    <bpmn:messageFlow id="Message_Shipment" name="Shipment request" sourceRef="Task_CreateShipment" targetRef="Participant_Shipping" />
  </bpmn:collaboration>
  <bpmn:process id="Process_Merchant" name="Orkestrasi Pesanan" isExecutable="false">
    <bpmn:startEvent id="Start_Order" name="Order diterima">
      <bpmn:outgoing>Flow_Start_Check</bpmn:outgoing>
      <bpmn:messageEventDefinition id="Definition_OrderMessage" />
    </bpmn:startEvent>
    <bpmn:userTask id="Task_CheckOrder" name="Verifikasi Pesanan">
      <bpmn:incoming>Flow_Start_Check</bpmn:incoming>
      <bpmn:outgoing>Flow_Check_Payment</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sendTask id="Task_RequestPayment" name="Minta Pembayaran">
      <bpmn:incoming>Flow_Check_Payment</bpmn:incoming>
      <bpmn:outgoing>Flow_Payment_Race</bpmn:outgoing>
    </bpmn:sendTask>
    <bpmn:eventBasedGateway id="Gateway_PaymentRace" name="Pembayaran atau batas waktu" eventGatewayType="Exclusive" instantiate="false">
      <bpmn:incoming>Flow_Payment_Race</bpmn:incoming>
      <bpmn:outgoing>Flow_Race_Paid</bpmn:outgoing>
      <bpmn:outgoing>Flow_Race_Timeout</bpmn:outgoing>
    </bpmn:eventBasedGateway>
    <bpmn:intermediateCatchEvent id="Catch_Payment" name="Pembayaran diterima">
      <bpmn:incoming>Flow_Race_Paid</bpmn:incoming>
      <bpmn:outgoing>Flow_Paid_Stock</bpmn:outgoing>
      <bpmn:messageEventDefinition id="Definition_PaymentMessage" />
    </bpmn:intermediateCatchEvent>
    <bpmn:intermediateCatchEvent id="Catch_Timeout" name="Batas pembayaran habis">
      <bpmn:incoming>Flow_Race_Timeout</bpmn:incoming>
      <bpmn:outgoing>Flow_Timeout_Cancel</bpmn:outgoing>
      <bpmn:timerEventDefinition id="Definition_PaymentTimer"><bpmn:timeDuration xsi:type="bpmn:tFormalExpression" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">PT24H</bpmn:timeDuration></bpmn:timerEventDefinition>
    </bpmn:intermediateCatchEvent>
    <bpmn:serviceTask id="Task_ReserveStock" name="Reservasi Persediaan">
      <bpmn:incoming>Flow_Split_Reserve</bpmn:incoming>
      <bpmn:outgoing>Flow_Reserve_Join</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:task id="Task_PackItems" name="Siapkan Item Pesanan">
      <bpmn:incoming>Flow_Split_Pack</bpmn:incoming>
      <bpmn:outgoing>Flow_Pack_Join</bpmn:outgoing>
    </bpmn:task>
    <bpmn:boundaryEvent id="Boundary_StockError" name="Persediaan gagal" attachedToRef="Task_ReserveStock" cancelActivity="true">
      <bpmn:outgoing>Flow_Error_Escalate</bpmn:outgoing>
      <bpmn:errorEventDefinition id="Definition_StockError" />
    </bpmn:boundaryEvent>
    <bpmn:parallelGateway id="Gateway_FulfillmentSplit" name="Mulai fulfillment paralel">
      <bpmn:incoming>Flow_Paid_Stock</bpmn:incoming>
      <bpmn:outgoing>Flow_Split_Reserve</bpmn:outgoing>
      <bpmn:outgoing>Flow_Split_Pack</bpmn:outgoing>
    </bpmn:parallelGateway>
    <bpmn:parallelGateway id="Gateway_FulfillmentJoin" name="Fulfillment lengkap">
      <bpmn:incoming>Flow_Reserve_Join</bpmn:incoming>
      <bpmn:incoming>Flow_Pack_Join</bpmn:incoming>
      <bpmn:outgoing>Flow_Join_Ship</bpmn:outgoing>
    </bpmn:parallelGateway>
    <bpmn:sendTask id="Task_CreateShipment" name="Kirim Instruksi Pengiriman">
      <bpmn:incoming>Flow_Join_Ship</bpmn:incoming>
      <bpmn:outgoing>Flow_Ship_End</bpmn:outgoing>
    </bpmn:sendTask>
    <bpmn:task id="Task_CancelOrder" name="Batalkan Pesanan">
      <bpmn:incoming>Flow_Timeout_Cancel</bpmn:incoming>
      <bpmn:outgoing>Flow_Cancel_End</bpmn:outgoing>
    </bpmn:task>
    <bpmn:task id="Task_Escalate" name="Eskalasi Kegagalan">
      <bpmn:incoming>Flow_Error_Escalate</bpmn:incoming>
      <bpmn:outgoing>Flow_Escalate_End</bpmn:outgoing>
    </bpmn:task>
    <bpmn:endEvent id="End_Delivered" name="Pengiriman diminta"><bpmn:incoming>Flow_Ship_End</bpmn:incoming></bpmn:endEvent>
    <bpmn:endEvent id="End_Cancelled" name="Pesanan dibatalkan"><bpmn:incoming>Flow_Cancel_End</bpmn:incoming></bpmn:endEvent>
    <bpmn:endEvent id="End_Escalated" name="Ditinjau manual"><bpmn:incoming>Flow_Escalate_End</bpmn:incoming></bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_Start_Check" sourceRef="Start_Order" targetRef="Task_CheckOrder" />
    <bpmn:sequenceFlow id="Flow_Check_Payment" sourceRef="Task_CheckOrder" targetRef="Task_RequestPayment" />
    <bpmn:sequenceFlow id="Flow_Payment_Race" sourceRef="Task_RequestPayment" targetRef="Gateway_PaymentRace" />
    <bpmn:sequenceFlow id="Flow_Race_Paid" sourceRef="Gateway_PaymentRace" targetRef="Catch_Payment" />
    <bpmn:sequenceFlow id="Flow_Race_Timeout" sourceRef="Gateway_PaymentRace" targetRef="Catch_Timeout" />
    <bpmn:sequenceFlow id="Flow_Paid_Stock" sourceRef="Catch_Payment" targetRef="Task_ReserveStock" />
    <bpmn:sequenceFlow id="Flow_Split_Reserve" sourceRef="Gateway_FulfillmentSplit" targetRef="Task_ReserveStock" />
    <bpmn:sequenceFlow id="Flow_Split_Pack" sourceRef="Gateway_FulfillmentSplit" targetRef="Task_PackItems" />
    <bpmn:sequenceFlow id="Flow_Reserve_Join" sourceRef="Task_ReserveStock" targetRef="Gateway_FulfillmentJoin" />
    <bpmn:sequenceFlow id="Flow_Pack_Join" sourceRef="Task_PackItems" targetRef="Gateway_FulfillmentJoin" />
    <bpmn:sequenceFlow id="Flow_Join_Ship" sourceRef="Gateway_FulfillmentJoin" targetRef="Task_CreateShipment" />
    <bpmn:sequenceFlow id="Flow_Ship_End" sourceRef="Task_CreateShipment" targetRef="End_Delivered" />
    <bpmn:sequenceFlow id="Flow_Timeout_Cancel" sourceRef="Catch_Timeout" targetRef="Task_CancelOrder" />
    <bpmn:sequenceFlow id="Flow_Cancel_End" sourceRef="Task_CancelOrder" targetRef="End_Cancelled" />
    <bpmn:sequenceFlow id="Flow_Error_Escalate" sourceRef="Boundary_StockError" targetRef="Task_Escalate" />
    <bpmn:sequenceFlow id="Flow_Escalate_End" sourceRef="Task_Escalate" targetRef="End_Escalated" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="Diagram_Capstone">
    <bpmndi:BPMNPlane id="Plane_Capstone" bpmnElement="Collaboration_Order">
      <bpmndi:BPMNShape id="Shape_Customer" bpmnElement="Participant_Customer" isHorizontal="true"><dc:Bounds x="40" y="20" width="1210" height="70" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Merchant" bpmnElement="Participant_Merchant" isHorizontal="true"><dc:Bounds x="40" y="110" width="1210" height="250" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Payment" bpmnElement="Participant_Payment" isHorizontal="true"><dc:Bounds x="40" y="380" width="1210" height="70" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Warehouse" bpmnElement="Participant_Warehouse" isHorizontal="true"><dc:Bounds x="40" y="470" width="1210" height="70" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Shipping" bpmnElement="Participant_Shipping" isHorizontal="true"><dc:Bounds x="40" y="560" width="1210" height="70" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Start_Order" bpmnElement="Start_Order"><dc:Bounds x="135" y="205" width="36" height="36" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Task_CheckOrder" bpmnElement="Task_CheckOrder"><dc:Bounds x="210" y="195" width="120" height="56" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Task_RequestPayment" bpmnElement="Task_RequestPayment"><dc:Bounds x="365" y="195" width="125" height="56" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Gateway_PaymentRace" bpmnElement="Gateway_PaymentRace"><dc:Bounds x="530" y="200" width="50" height="50" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Catch_Payment" bpmnElement="Catch_Payment"><dc:Bounds x="625" y="165" width="36" height="36" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Catch_Timeout" bpmnElement="Catch_Timeout"><dc:Bounds x="625" y="265" width="36" height="36" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Gateway_FulfillmentSplit" bpmnElement="Gateway_FulfillmentSplit"><dc:Bounds x="690" y="165" width="50" height="50" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Task_ReserveStock" bpmnElement="Task_ReserveStock"><dc:Bounds x="785" y="135" width="130" height="56" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Task_PackItems" bpmnElement="Task_PackItems"><dc:Bounds x="785" y="250" width="130" height="56" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Boundary_StockError" bpmnElement="Boundary_StockError"><dc:Bounds x="865" y="118" width="36" height="36" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Gateway_FulfillmentJoin" bpmnElement="Gateway_FulfillmentJoin"><dc:Bounds x="950" y="165" width="50" height="50" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Task_CreateShipment" bpmnElement="Task_CreateShipment"><dc:Bounds x="1030" y="165" width="110" height="56" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Task_CancelOrder" bpmnElement="Task_CancelOrder"><dc:Bounds x="710" y="265" width="130" height="56" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_Task_Escalate" bpmnElement="Task_Escalate"><dc:Bounds x="870" y="265" width="130" height="56" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_End_Delivered" bpmnElement="End_Delivered"><dc:Bounds x="1170" y="175" width="36" height="36" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_End_Cancelled" bpmnElement="End_Cancelled"><dc:Bounds x="945" y="270" width="36" height="36" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Shape_End_Escalated" bpmnElement="End_Escalated"><dc:Bounds x="1110" y="285" width="36" height="36" /></bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Edge_Flow_Start_Check" bpmnElement="Flow_Start_Check"><di:waypoint x="171" y="223" /><di:waypoint x="210" y="223" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Check_Payment" bpmnElement="Flow_Check_Payment"><di:waypoint x="330" y="223" /><di:waypoint x="365" y="223" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Payment_Race" bpmnElement="Flow_Payment_Race"><di:waypoint x="490" y="223" /><di:waypoint x="530" y="225" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Race_Paid" bpmnElement="Flow_Race_Paid"><di:waypoint x="555" y="200" /><di:waypoint x="555" y="183" /><di:waypoint x="625" y="183" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Race_Timeout" bpmnElement="Flow_Race_Timeout"><di:waypoint x="555" y="250" /><di:waypoint x="555" y="283" /><di:waypoint x="625" y="283" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Paid_Stock" bpmnElement="Flow_Paid_Stock"><di:waypoint x="661" y="183" /><di:waypoint x="690" y="190" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Split_Reserve" bpmnElement="Flow_Split_Reserve"><di:waypoint x="740" y="190" /><di:waypoint x="785" y="163" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Split_Pack" bpmnElement="Flow_Split_Pack"><di:waypoint x="715" y="215" /><di:waypoint x="715" y="278" /><di:waypoint x="785" y="278" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Reserve_Join" bpmnElement="Flow_Reserve_Join"><di:waypoint x="915" y="163" /><di:waypoint x="975" y="163" /><di:waypoint x="975" y="165" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Pack_Join" bpmnElement="Flow_Pack_Join"><di:waypoint x="915" y="278" /><di:waypoint x="975" y="278" /><di:waypoint x="975" y="215" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Join_Ship" bpmnElement="Flow_Join_Ship"><di:waypoint x="1000" y="190" /><di:waypoint x="1030" y="193" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Ship_End" bpmnElement="Flow_Ship_End"><di:waypoint x="1140" y="193" /><di:waypoint x="1170" y="193" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Timeout_Cancel" bpmnElement="Flow_Timeout_Cancel"><di:waypoint x="661" y="283" /><di:waypoint x="710" y="293" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Cancel_End" bpmnElement="Flow_Cancel_End"><di:waypoint x="840" y="293" /><di:waypoint x="945" y="288" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Error_Escalate" bpmnElement="Flow_Error_Escalate"><di:waypoint x="901" y="136" /><di:waypoint x="930" y="136" /><di:waypoint x="930" y="293" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Flow_Escalate_End" bpmnElement="Flow_Escalate_End"><di:waypoint x="1000" y="293" /><di:waypoint x="1110" y="303" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Message_Order" bpmnElement="Message_Order"><di:waypoint x="170" y="90" /><di:waypoint x="153" y="205" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Message_PaymentRequest" bpmnElement="Message_PaymentRequest"><di:waypoint x="430" y="251" /><di:waypoint x="430" y="380" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Message_PaymentResult" bpmnElement="Message_PaymentResult"><di:waypoint x="500" y="380" /><di:waypoint x="643" y="201" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Message_WarehouseRequest" bpmnElement="Message_WarehouseRequest"><di:waypoint x="775" y="221" /><di:waypoint x="775" y="470" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Edge_Message_Shipment" bpmnElement="Message_Shipment"><di:waypoint x="1010" y="221" /><di:waypoint x="1010" y="560" /></bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
