<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1">
  <bpmn:process id="DoCreateTnNssiInstance" name="DoCreateTnNssiInstance" isExecutable="true">
    <bpmn:startEvent id="allocateTnNssi_StartEvent" name="allocateTnNssi_StartEvent">
      <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="allocateTnNssi_StartEvent" targetRef="PreprocessIncomingRequest_task" />
    <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="instantiate_NSTask" />
    <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="Preprocess Incoming Request" scriptFormat="groovy">
      <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_0khtova</bpmn:outgoing>
      <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
def dcsi = new DoCreateTnNssiInstance()
dcsi.preProcessRequest(execution)</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:scriptTask id="instantiate_NSTask" name="create Service Instance in AAI" scriptFormat="groovy">
      <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_0g5bwvl</bpmn:outgoing>
      <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
def dcsi = new DoCreateTnNssiInstance()
dcsi.createServiceInstance(execution)</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:sequenceFlow id="SequenceFlow_1uiz85h" sourceRef="Activity_16luyg1" targetRef="Event_1rsf7yb" />
    <bpmn:sequenceFlow id="SequenceFlow_0g5bwvl" sourceRef="instantiate_NSTask" targetRef="ScriptTask_18rzwzb" />
    <bpmn:scriptTask id="ScriptTask_18rzwzb" name="Create Allottedsource in AAI" scriptFormat="groovy">
      <bpmn:incoming>SequenceFlow_0g5bwvl</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_17u69c4</bpmn:outgoing>
      <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
def dcsi = new DoCreateTnNssiInstance()
dcsi.createAllottedResource(execution)</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:sequenceFlow id="SequenceFlow_17u69c4" sourceRef="ScriptTask_18rzwzb" targetRef="Gateway_1cehbyc" />
    <bpmn:intermediateCatchEvent id="Event_0l9vk9p" name="Start SDNC Operation">
      <bpmn:outgoing>Flow_1c8zr59</bpmn:outgoing>
      <bpmn:linkEventDefinition id="LinkEventDefinition_0uwmpn2" name="SdncOperation" />
    </bpmn:intermediateCatchEvent>
    <bpmn:scriptTask id="Activity_0eh82ds" name="PreProcess SDNC Allocate TN NSSI Request" scriptFormat="groovy">
      <bpmn:incoming>Flow_1c8zr59</bpmn:incoming>
      <bpmn:outgoing>Flow_0pko5tm</bpmn:outgoing>
      <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
def dcsi = new DoCreateTnNssiInstance()
dcsi.preprocessSdncAllocateTnNssiRequest(execution)</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:callActivity id="Activity_1fs2182" name="Call SDNC Adapter: Allocate TN NSSI" calledElement="sdncAdapter">
      <bpmn:extensionElements>
        <camunda:in source="TNNSSMF_SDNCRequest" target="sdncAdapterWorkflowRequest" />
        <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" />
        <camunda:in source="msoRequestId" target="mso-request-id" />
        <camunda:in source="sliceServiceInstanceId" target="mso-service-instance-id" />
        <camunda:out source="WorkflowException" target="WorkflowException" />
        <camunda:out source="sdncAdapterResponse" target="TNNSSMF_SDNCAdapterResponse" />
        <camunda:out source="SDNCA_SuccessIndicator" target="SDNCA_SuccessIndicator" />
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0pko5tm</bpmn:incoming>
      <bpmn:outgoing>Flow_11kadz7</bpmn:outgoing>
    </bpmn:callActivity>
    <bpmn:scriptTask id="Activity_16luyg1" name="Postprocess SDNC Allocate TN NSSI  Request" scriptFormat="groovy">
      <bpmn:incoming>Flow_11kadz7</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1uiz85h</bpmn:outgoing>
      <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*

String response = execution.getVariable("TNNSSMF_SDNCAdapterResponse")

def dcsi = new DoCreateTnNssiInstance()
dcsi.validateSDNCResponse(execution, response, "allocate")</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:sequenceFlow id="Flow_1c8zr59" name="" sourceRef="Event_0l9vk9p" targetRef="Activity_0eh82ds" />
    <bpmn:sequenceFlow id="Flow_0pko5tm" name="" sourceRef="Activity_0eh82ds" targetRef="Activity_1fs2182" />
    <bpmn:sequenceFlow id="Flow_11kadz7" name="" sourceRef="Activity_1fs2182" targetRef="Activity_16luyg1" />
    <bpmn:endEvent id="Event_1rsf7yb" name="No">
      <bpmn:incoming>SequenceFlow_1uiz85h</bpmn:incoming>
      <bpmn:incoming>Flow_07tmxxo</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:intermediateThrowEvent id="Event_1a9swwa" name="Goto SDNC operation">
      <bpmn:incoming>Flow_0dp5afv</bpmn:incoming>
      <bpmn:linkEventDefinition id="LinkEventDefinition_1skl6p7" name="SdncOperation" />
    </bpmn:intermediateThrowEvent>
    <bpmn:exclusiveGateway id="Gateway_1cehbyc" name="Enable SDNC?">
      <bpmn:incoming>SequenceFlow_17u69c4</bpmn:incoming>
      <bpmn:outgoing>Flow_0dp5afv</bpmn:outgoing>
      <bpmn:outgoing>Flow_07tmxxo</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_0dp5afv" name="Yes" sourceRef="Gateway_1cehbyc" targetRef="Event_1a9swwa">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("enableSdnc" )  == true)}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_07tmxxo" name="No" sourceRef="Gateway_1cehbyc" targetRef="Event_1rsf7yb" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateTnNssiInstance">
      <bpmndi:BPMNEdge id="Flow_11kadz7_di" bpmnElement="Flow_11kadz7">
        <di:waypoint x="610" y="375" />
        <di:waypoint x="719" y="375" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0pko5tm_di" bpmnElement="Flow_0pko5tm">
        <di:waypoint x="420" y="375" />
        <di:waypoint x="489" y="375" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1c8zr59_di" bpmnElement="Flow_1c8zr59">
        <di:waypoint x="211" y="375" />
        <di:waypoint x="299" y="375" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_17u69c4_di" bpmnElement="SequenceFlow_17u69c4">
        <di:waypoint x="830" y="129" />
        <di:waypoint x="895" y="129" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0g5bwvl_di" bpmnElement="SequenceFlow_0g5bwvl">
        <di:waypoint x="600" y="129" />
        <di:waypoint x="730" y="129" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1uiz85h_di" bpmnElement="SequenceFlow_1uiz85h">
        <di:waypoint x="840" y="375" />
        <di:waypoint x="972" y="375" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="631" y="108" width="0" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova">
        <di:waypoint x="410" y="129" />
        <di:waypoint x="500" y="129" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="436" y="108" width="0" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln">
        <di:waypoint x="211" y="129" />
        <di:waypoint x="310" y="129" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="266" y="123" width="0" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0dp5afv_di" bpmnElement="Flow_0dp5afv">
        <di:waypoint x="945" y="129" />
        <di:waypoint x="1072" y="129" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1000" y="113" width="19" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_07tmxxo_di" bpmnElement="Flow_07tmxxo">
        <di:waypoint x="920" y="154" />
        <di:waypoint x="920" y="375" />
        <di:waypoint x="972" y="375" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="929" y="262" width="14" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="allocateTnNssi_StartEvent">
        <dc:Bounds x="175" y="111" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="153" y="147" width="86" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task">
        <dc:Bounds x="310" y="89" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ScriptTask_1qmmew8_di" bpmnElement="instantiate_NSTask">
        <dc:Bounds x="500" y="89" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ScriptTask_18rzwzb_di" bpmnElement="ScriptTask_18rzwzb">
        <dc:Bounds x="730" y="89" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0l9vk9p_di" bpmnElement="Event_0l9vk9p">
        <dc:Bounds x="175" y="357" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="165" y="400" width="58" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0eh82ds_di" bpmnElement="Activity_0eh82ds">
        <dc:Bounds x="299" y="328" width="121" height="94" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1fs2182_di" bpmnElement="Activity_1fs2182">
        <dc:Bounds x="489" y="328" width="121" height="94" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_16luyg1_di" bpmnElement="Activity_16luyg1">
        <dc:Bounds x="719" y="328" width="121" height="94" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1rsf7yb_di" bpmnElement="Event_1rsf7yb">
        <dc:Bounds x="972" y="357" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="983" y="400" width="14" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1a9swwa_di" bpmnElement="Event_1a9swwa">
        <dc:Bounds x="1072" y="111" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1063" y="154" width="59" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_1cehbyc_di" bpmnElement="Gateway_1cehbyc" isMarkerVisible="true">
        <dc:Bounds x="895" y="104" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="884" y="74" width="75" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>