Merge "Implemented OOF call in TN NSSMF for deallocate flow"
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
index b09161d..ea4c29b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
@@ -34,6 +34,13 @@
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.common.scripts.RequestDBUtil
 import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.common.scripts.OofUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.oof.adapter.beans.payload.OofRequest
+import javax.ws.rs.core.Response
+import org.onap.logging.filter.base.ONAPComponents
 import org.onap.so.db.request.beans.ResourceOperationStatus
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
@@ -48,6 +55,7 @@
     JsonUtils jsonUtil = new JsonUtils()
     RequestDBUtil requestDBUtil = new RequestDBUtil()
     TnNssmfUtils tnNssmfUtils = new TnNssmfUtils()
+    OofUtils oofUtils = new OofUtils()
     JsonSlurper jsonSlurper = new JsonSlurper()
     ObjectMapper objectMapper = new ObjectMapper()
     private static final Logger logger = LoggerFactory.getLogger(DoDeallocateTnNssi.class)
@@ -92,10 +100,69 @@
                         "enableSdnc", "enableSdnc"))) {
             tnNssmfUtils.setEnableSdncConfig(execution)
         }
+        if (isBlank(additionalPropJsonStr) ||
+                isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution,
+                        additionalPropJsonStr,
+                        "enableOof", "enableOof"))) {
+            tnNssmfUtils.setEnableOofConfig(execution)
+        }
 
+		String nsiId = jsonUtil.getJsonValue(additionalPropJsonStr, "nsiId")
+        execution.setVariable("nsiId", nsiId)
         logger.debug("Finish preProcessRequest")
     }
 
+    void prepareOOFNssiTerminationRequest(DelegateExecution execution) {
+        logger.debug("Start prepareOOFTnNssiTerminationRequest")
+		String requestId = execution.getVariable("msoRequestId")
+		String messageType = "TN_NSSITermination"
+		String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
+		String serviceInstanceId = execution.getVariable("sliceServiceInstanceId")
+
+        String relatedNsiId = execution.getVariable("nsiId")
+
+		String oofRequest = oofUtils.buildTerminateNxiRequest(requestId,serviceInstanceId, "NSSI",messageType,relatedNsiId)
+		execution.setVariable("oofTnNssiPayload", oofRequest)
+		logger.debug("Finish prepareOOFTnNssiTerminationRequest")
+    }
+
+    void performOofNSSITerminationCall(DelegateExecution execution) {
+        boolean terminateTnNSSI = callOofAdapter(execution,execution.getVariable("oofTnNssiPayload"))
+		execution.setVariable("terminateTnNSSI", terminateTnNSSI)
+    }
+
+    /**
+	 * @param execution
+	 * @param oofRequest - Request payload to be sent to adapter
+	 * @return
+	 */
+	boolean callOofAdapter(DelegateExecution execution, Object oofRequest) {
+		logger.debug("Start callOofAdapter")
+		String requestId = execution.getVariable("msoRequestId")
+		String oofAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.oof.endpoint", execution)
+		URL requestUrl = new URL(oofAdapterEndpoint)
+		OofRequest oofPayload = new OofRequest()
+		oofPayload.setApiPath("/api/oof/terminate/nxi/v1")
+		oofPayload.setRequestDetails(oofRequest)
+		String requestJson = objectMapper.writeValueAsString(oofPayload)
+		logger.debug("Calling OOF adapter  : ${requestUrl} with payload : ${requestJson}")
+		HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.EXTERNAL)
+		Response httpResponse = httpClient.post(requestJson)
+		int responseCode = httpResponse.getStatus()
+		logger.debug("OOF sync response code is: " + responseCode)
+		if(responseCode < 200 || responseCode >= 300){
+			logger.debug("OOF request failed with reason : " + httpResponse)
+			exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
+		}else {
+			Map<String,Object> response = objectMapper.readValue(httpResponse.getEntity(),Map.class)
+			boolean terminateResponse =  response.get("terminateResponse")
+			if(!terminateResponse) {
+				logger.debug("Terminate response is false because " + response.get("reason"))
+			}
+			return terminateResponse
+		}
+	}
+
     void preprocessSdncDeallocateTnNssiRequest(DelegateExecution execution) {
         def method = getClass().getSimpleName() + '.preprocessSdncDeallocateTnNssiRequest(' +
                 'execution=' + execution.getId() + ')'
@@ -174,4 +241,3 @@
         requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
     }
 }
-
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
index d6e94ef..d1e2b11 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
@@ -382,6 +382,18 @@
         execution.setVariable("enableSdnc", enableSdnc)
     }
 
+    void setEnableOofConfig(DelegateExecution execution) {
+        String enableOof = UrnPropertiesReader.getVariable(
+                "mso.workflow.TnNssmf.enableOOFNetworkConfig")
+        if (isBlank(enableOof)) {
+            logger.debug("mso.workflow.TnNssmf.enableOOFNetworkConfig is undefined, so use default value (true)")
+            enableOof = "true"
+        }
+        logger.debug("setEnableOofConfig: enableOof=" + enableOof)
+
+        execution.setVariable("enableOof", enableOof)
+    }
+
     String setExecVarFromJsonIfExists(DelegateExecution execution,
                                       String jsonStr, String jsonKey, String varName) {
         return setExecVarFromJsonStr(execution, jsonStr, jsonKey, varName, false)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy
index 31bd3b5..2bb2270 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy
@@ -32,8 +32,10 @@
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
 import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.common.scripts.OofUtils
 
 import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertTrue
 import static org.mockito.ArgumentMatchers.eq
 import static org.mockito.Mockito.*
 
@@ -135,4 +137,41 @@
         obj.deleteServiceInstance(mockExecution)
         Mockito.verify(client, times(1)).delete(serviceInstanceUri)
     }
+
+    @Test
+    void testPrepareOOFNssiTerminationRequest() {
+        when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82")
+        when(mockExecution.getVariable("sliceServiceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+        when(mockExecution.getVariable("nsiId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56")
+        when(mockExecution.getVariable("mso.adapters.oof.timeout")).thenReturn("")
+        DoDeallocateTnNssi obj = spy(DoDeallocateTnNssi.class)
+        OofUtils oofUtils = spy(OofUtils.class)
+        when(oofUtils.buildTerminateNxiRequest()).thenReturn("""
+        {
+	"apiPath": "/api/oof/terminate/nxi/v1",
+	"requestDetails": "{\"type\":\"NSSI\",\"NxIId\":\"f78c1531-55a7-4dfa-8a12-1e2544c9b248\",\"requestInfo\":{\"transactionId\":\"863fb189-33d8-455f-9d3f-bf3f6a2e4509\",\"requestId\":\"863fb189-33d8-455f-9d3f-bf3f6a2e4509\",\"callbackUrl\":\"http://so-oof-adapter.onap:8090/so/adapters/oof/callback/v1/TN_NSSITermination/863fb189-33d8-455f-9d3f-bf3f6a2e4509\",\"sourceId\":\"SO\",\"timeout\":600,\"addtnlArgs\":{\"serviceInstanceId\":\"fe6f0901-292d-4493-bcad-485793605781\"}}}"
+       }""".replaceAll("\\\\s+", ""))
+        obj.prepareOOFNssiTerminationRequest(mockExecution)
+        Mockito.verify(mockExecution, times(1)).setVariable(eq("oofTnNssiPayload"), captor.capture())
+        String oofTnNssiPayload = captor.getValue()
+        assertNotNull(oofTnNssiPayload)
+    }
+
+    @Test
+    void testPerformOofNSSITerminationCall() {
+        when(mockExecution.getVariable("oofTnNssiPayload")).thenReturn("""
+        {
+	"reason": "",
+	"requestId": "e0a026a9-dd6d-4800-ab27-0fdd8f5f64f5",
+	"requestStatus": "success",
+	"terminateResponse": true,
+	"transactionId": "e0a026a9-dd6d-4800-ab27-0fdd8f5f64f5"
+        }""".replaceAll("\\\\s+", ""))
+        DoDeallocateTnNssi obj = spy(DoDeallocateTnNssi.class)
+        when(obj.callOofAdapter()).thenReturn(true)
+        obj.performOofNSSITerminationCall(mockExecution)
+        Mockito.verify(mockExecution, times(1)).setVariable(eq("terminateTnNSSI"), captor.capture())
+        String terminateTnNSSI = captor.getValue()
+        assertTrue(terminateTnNSSI)
+    }
 }
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn
index 1dd362b..4897850 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn
@@ -1,5 +1,5 @@
 <?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1">
+<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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.9.0">
   <bpmn:process id="DoDeallocateTransportNSSI" name="DoDeallocateTransportNSSI" isExecutable="true">
     <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Deallocate TN NSSMF Work Flow">
       <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing>
@@ -26,7 +26,7 @@
       <bpmn:incoming>Flow_0ca4l8d</bpmn:incoming>
     </bpmn:endEvent>
     <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy">
-      <bpmn:incoming>SequenceFlow_1jygjln</bpmn:incoming>
+      <bpmn:incoming>Flow_14tkuoh</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def runScript = new DoDeallocateTnNssi()
@@ -69,7 +69,7 @@
     <bpmn:scriptTask id="Activity_013rjwc" name="Delete Service Instance (TN NSSI) in AAI" scriptFormat="groovy">
       <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming>
       <bpmn:incoming>Flow_0dirb5b</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_1jygjln</bpmn:outgoing>
+      <bpmn:outgoing>Flow_14pzrs9</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def runScript = new DoDeallocateTnNssi()
 runScript.deleteServiceInstance(execution)</bpmn:script>
@@ -77,13 +77,11 @@
     <bpmn:sequenceFlow id="SequenceFlow_1jdb2oq" sourceRef="Activity_0phv8e5" targetRef="Activity_013rjwc" />
     <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy">
       <bpmn:incoming>SequenceFlow_03s744c</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_07e12rt</bpmn:outgoing>
+      <bpmn:outgoing>Flow_1xxj5g6</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def runScript = new DoDeallocateTnNssi()
 runScript.preProcessRequest(execution)</bpmn:script>
     </bpmn:scriptTask>
-    <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Gateway_1spi9lo" />
-    <bpmn:sequenceFlow id="SequenceFlow_1jygjln" sourceRef="Activity_013rjwc" targetRef="ScriptTask_1ssh2l9" />
     <bpmn:serviceTask id="Activity_0rgeefb" name="Update Resource Operation Status">
       <bpmn:extensionElements>
         <camunda:connector>
@@ -108,7 +106,7 @@
     </bpmn:serviceTask>
     <bpmn:sequenceFlow id="Flow_0ca4l8d" sourceRef="Activity_0rgeefb" targetRef="EndEvent_05h01gx" />
     <bpmn:exclusiveGateway id="Gateway_1spi9lo" name="Enable SDNC?">
-      <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming>
+      <bpmn:incoming>Flow_08so17j</bpmn:incoming>
       <bpmn:outgoing>Flow_0sj0mtu</bpmn:outgoing>
       <bpmn:outgoing>Flow_0dirb5b</bpmn:outgoing>
     </bpmn:exclusiveGateway>
@@ -116,119 +114,281 @@
       <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("enableSdnc" )  == true)}</bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:sequenceFlow id="Flow_0dirb5b" name="No" sourceRef="Gateway_1spi9lo" targetRef="Activity_013rjwc" />
+    <bpmn:exclusiveGateway id="Gateway_0evcwr8" name="Enable OOF?" default="Flow_0buil9w">
+      <bpmn:incoming>Flow_1xxj5g6</bpmn:incoming>
+      <bpmn:outgoing>Flow_0elnhnt</bpmn:outgoing>
+      <bpmn:outgoing>Flow_0buil9w</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
+    <bpmn:exclusiveGateway id="Gateway_0m3yrzp" name="Terminate Tn NSSI?" default="Flow_1oxjcb2">
+      <bpmn:incoming>Flow_18xmkvl</bpmn:incoming>
+      <bpmn:outgoing>Flow_1oxjcb2</bpmn:outgoing>
+      <bpmn:outgoing>Flow_083usqs</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
+    <bpmn:sequenceFlow id="Flow_1xxj5g6" sourceRef="ScriptTask_1tc44ge" targetRef="Gateway_0evcwr8" />
+    <bpmn:scriptTask id="Activity_0tw406b" name="Prepare OOF Terminate TN NSSI" scriptFormat="groovy">
+      <bpmn:incoming>Flow_0elnhnt</bpmn:incoming>
+      <bpmn:outgoing>Flow_1yadxwl</bpmn:outgoing>
+      <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def deallocator = new DoDeallocateTnNssi()
+deallocator.prepareOOFNssiTerminationRequest(execution)</bpmn:script>
+    </bpmn:scriptTask>
+    <bpmn:scriptTask id="Activity_0ztykbe" name="Call OOF flow for TN termination" scriptFormat="groovy">
+      <bpmn:incoming>Flow_1yadxwl</bpmn:incoming>
+      <bpmn:outgoing>Flow_18xmkvl</bpmn:outgoing>
+      <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def deallocator = new DoDeallocateTnNssi()
+deallocator.performOofNSSITerminationCall(execution)</bpmn:script>
+    </bpmn:scriptTask>
+    <bpmn:sequenceFlow id="Flow_0elnhnt" name="Yes" sourceRef="Gateway_0evcwr8" targetRef="Activity_0tw406b">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("enableOof") == true}</bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
+    <bpmn:sequenceFlow id="Flow_1yadxwl" sourceRef="Activity_0tw406b" targetRef="Activity_0ztykbe" />
+    <bpmn:intermediateCatchEvent id="Event_0ypmuow" name="Start operation status update">
+      <bpmn:outgoing>Flow_14tkuoh</bpmn:outgoing>
+      <bpmn:linkEventDefinition id="LinkEventDefinition_0sxzf9o" name="OperationStatusUpdate" />
+    </bpmn:intermediateCatchEvent>
+    <bpmn:sequenceFlow id="Flow_14tkuoh" sourceRef="Event_0ypmuow" targetRef="ScriptTask_1ssh2l9" />
+    <bpmn:intermediateThrowEvent id="Event_0c3sko9" name="Go to start   operation status update">
+      <bpmn:incoming>Flow_14pzrs9</bpmn:incoming>
+      <bpmn:linkEventDefinition id="LinkEventDefinition_1qixrye" name="OperationStatusUpdate" />
+    </bpmn:intermediateThrowEvent>
+    <bpmn:sequenceFlow id="Flow_14pzrs9" sourceRef="Activity_013rjwc" targetRef="Event_0c3sko9" />
+    <bpmn:intermediateThrowEvent id="Event_0l28lqi" name="Go to start   operation status update">
+      <bpmn:incoming>Flow_1oxjcb2</bpmn:incoming>
+      <bpmn:linkEventDefinition id="LinkEventDefinition_0rexbo3" name="OperationStatusUpdate" />
+    </bpmn:intermediateThrowEvent>
+    <bpmn:sequenceFlow id="Flow_18xmkvl" sourceRef="Activity_0ztykbe" targetRef="Gateway_0m3yrzp" />
+    <bpmn:sequenceFlow id="Flow_1oxjcb2" name="No" sourceRef="Gateway_0m3yrzp" targetRef="Event_0l28lqi" />
+    <bpmn:intermediateThrowEvent id="Event_01bin3l" name="Go to deallocate TN nssi">
+      <bpmn:incoming>Flow_083usqs</bpmn:incoming>
+      <bpmn:linkEventDefinition id="LinkEventDefinition_1tnxmki" name="DeAllocateTnNSSI" />
+    </bpmn:intermediateThrowEvent>
+    <bpmn:sequenceFlow id="Flow_083usqs" name="Yes" sourceRef="Gateway_0m3yrzp" targetRef="Event_01bin3l">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("terminateTnNSSI") == true}</bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
+    <bpmn:intermediateCatchEvent id="Event_0a5fzwt" name="Start deallocate TN nssi">
+      <bpmn:outgoing>Flow_08so17j</bpmn:outgoing>
+      <bpmn:linkEventDefinition id="LinkEventDefinition_11dpw4b" name="DeAllocateTnNSSI" />
+    </bpmn:intermediateCatchEvent>
+    <bpmn:sequenceFlow id="Flow_08so17j" sourceRef="Event_0a5fzwt" targetRef="Gateway_1spi9lo" />
+    <bpmn:intermediateThrowEvent id="Event_06m6kud" name="Go to deallocate TN nssi">
+      <bpmn:incoming>Flow_0buil9w</bpmn:incoming>
+      <bpmn:linkEventDefinition id="LinkEventDefinition_02jveqm" name="DeAllocateTnNSSI" />
+    </bpmn:intermediateThrowEvent>
+    <bpmn:sequenceFlow id="Flow_0buil9w" name="No" sourceRef="Gateway_0evcwr8" targetRef="Event_06m6kud" />
   </bpmn:process>
   <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" />
   <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
   <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeallocateTransportNSSI">
-      <bpmndi:BPMNEdge id="Flow_0ca4l8d_di" bpmnElement="Flow_0ca4l8d">
-        <di:waypoint x="1030" y="410" />
-        <di:waypoint x="1152" y="410" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_1jygjln_di" bpmnElement="SequenceFlow_1jygjln">
-        <di:waypoint x="530" y="410" />
-        <di:waypoint x="660" y="410" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt">
-        <di:waypoint x="385" y="121" />
-        <di:waypoint x="455" y="121" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq">
-        <di:waypoint x="1130" y="121" />
-        <di:waypoint x="1220" y="121" />
-        <di:waypoint x="1220" y="260" />
-        <di:waypoint x="480" y="260" />
-        <di:waypoint x="480" y="370" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_0fuabjs_di" bpmnElement="Flow_0fuabjs">
-        <di:waypoint x="910" y="121" />
-        <di:waypoint x="1009" y="121" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_0cpctye_di" bpmnElement="Flow_0cpctye">
-        <di:waypoint x="690" y="121" />
-        <di:waypoint x="789" y="121" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1">
-        <di:waypoint x="760" y="410" />
-        <di:waypoint x="930" y="410" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c">
-        <di:waypoint x="214" y="121" />
-        <di:waypoint x="285" y="121" />
+      <bpmndi:BPMNEdge id="Flow_0dirb5b_di" bpmnElement="Flow_0dirb5b">
+        <di:waypoint x="350" y="496" />
+        <di:waypoint x="350" y="680" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="353" y="511" width="15" height="14" />
+        </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_0sj0mtu_di" bpmnElement="Flow_0sj0mtu">
-        <di:waypoint x="505" y="121" />
-        <di:waypoint x="569" y="121" />
+        <di:waypoint x="375" y="471" />
+        <di:waypoint x="439" y="471" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="529" y="103" width="19" height="14" />
+          <dc:Bounds x="400" y="453" width="18" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_0dirb5b_di" bpmnElement="Flow_0dirb5b">
-        <di:waypoint x="480" y="146" />
-        <di:waypoint x="480" y="370" />
+      <bpmndi:BPMNEdge id="Flow_0ca4l8d_di" bpmnElement="Flow_0ca4l8d">
+        <di:waypoint x="570" y="910" />
+        <di:waypoint x="662" y="910" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq">
+        <di:waypoint x="1000" y="471" />
+        <di:waypoint x="1090" y="471" />
+        <di:waypoint x="1090" y="610" />
+        <di:waypoint x="350" y="610" />
+        <di:waypoint x="350" y="680" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0fuabjs_di" bpmnElement="Flow_0fuabjs">
+        <di:waypoint x="780" y="471" />
+        <di:waypoint x="879" y="471" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0cpctye_di" bpmnElement="Flow_0cpctye">
+        <di:waypoint x="560" y="471" />
+        <di:waypoint x="659" y="471" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1">
+        <di:waypoint x="400" y="910" />
+        <di:waypoint x="470" y="910" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c">
+        <di:waypoint x="208" y="140" />
+        <di:waypoint x="280" y="140" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_1xxj5g6_di" bpmnElement="Flow_1xxj5g6">
+        <di:waypoint x="380" y="140" />
+        <di:waypoint x="445" y="140" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0elnhnt_di" bpmnElement="Flow_0elnhnt">
+        <di:waypoint x="495" y="140" />
+        <di:waypoint x="570" y="140" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="483" y="166" width="14" height="14" />
+          <dc:Bounds x="524" y="122" width="18" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd">
-        <dc:Bounds x="178" y="103" width="36" height="36" />
+      <bpmndi:BPMNEdge id="Flow_1yadxwl_di" bpmnElement="Flow_1yadxwl">
+        <di:waypoint x="670" y="140" />
+        <di:waypoint x="750" y="140" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_14tkuoh_di" bpmnElement="Flow_14tkuoh">
+        <di:waypoint x="208" y="910" />
+        <di:waypoint x="300" y="910" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_14pzrs9_di" bpmnElement="Flow_14pzrs9">
+        <di:waypoint x="400" y="720" />
+        <di:waypoint x="502" y="720" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_18xmkvl_di" bpmnElement="Flow_18xmkvl">
+        <di:waypoint x="850" y="140" />
+        <di:waypoint x="921" y="140" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_1oxjcb2_di" bpmnElement="Flow_1oxjcb2">
+        <di:waypoint x="946" y="165" />
+        <di:waypoint x="946" y="260" />
+        <di:waypoint x="1062" y="260" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="166" y="146" width="70" height="53" />
+          <dc:Bounds x="954" y="210" width="15" height="14" />
         </bpmndi:BPMNLabel>
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9">
-        <dc:Bounds x="660" y="370" width="100" height="80" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_083usqs_di" bpmnElement="Flow_083usqs">
+        <di:waypoint x="971" y="140" />
+        <di:waypoint x="1062" y="140" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1008" y="122" width="18" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_08so17j_di" bpmnElement="Flow_08so17j">
+        <di:waypoint x="208" y="471" />
+        <di:waypoint x="325" y="471" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0buil9w_di" bpmnElement="Flow_0buil9w">
+        <di:waypoint x="470" y="165" />
+        <di:waypoint x="470" y="250" />
+        <di:waypoint x="532" y="250" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="478" y="205" width="15" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="Event_0ypmuow_di" bpmnElement="Event_0ypmuow">
+        <dc:Bounds x="172" y="892" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="154" y="935" width="73" height="27" />
+        </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_013rjwc_di" bpmnElement="Activity_013rjwc">
-        <dc:Bounds x="430" y="370" width="100" height="80" />
+        <dc:Bounds x="300" y="680" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9">
+        <dc:Bounds x="300" y="870" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_0rgeefb_di" bpmnElement="Activity_0rgeefb">
-        <dc:Bounds x="930" y="370" width="100" height="80" />
+        <dc:Bounds x="470" y="870" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx">
-        <dc:Bounds x="1152" y="392" width="36" height="36" />
+        <dc:Bounds x="662" y="892" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="1160" y="435" width="20" height="14" />
+          <dc:Bounds x="670" y="935" width="20" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Event_0c3sko9_di" bpmnElement="Event_0c3sko9">
+        <dc:Bounds x="502" y="702" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="480" y="750" width="79" height="40" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Event_0a5fzwt_di" bpmnElement="Event_0a5fzwt">
+        <dc:Bounds x="172" y="453" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="152" y="496" width="77" height="27" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Gateway_0evcwr8_di" bpmnElement="Gateway_0evcwr8" isMarkerVisible="true">
+        <dc:Bounds x="445" y="115" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="437" y="92" width="68" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Event_06m6kud_di" bpmnElement="Event_06m6kud">
+        <dc:Bounds x="532" y="232" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="509" y="280" width="81" height="27" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge">
+        <dc:Bounds x="280" y="100" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd">
+        <dc:Bounds x="172" y="122" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="160" y="165" width="70" height="53" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_1tw8eyy_di" bpmnElement="Activity_1tw8eyy">
-        <dc:Bounds x="569" y="74" width="121" height="94" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Gateway_1spi9lo_di" bpmnElement="Gateway_1spi9lo" isMarkerVisible="true">
-        <dc:Bounds x="455" y="96" width="50" height="50" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="443" y="73" width="75" height="14" />
-        </bpmndi:BPMNLabel>
+        <dc:Bounds x="439" y="424" width="121" height="94" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_0p20esb_di" bpmnElement="Activity_0p20esb">
-        <dc:Bounds x="789" y="74" width="121" height="94" />
+        <dc:Bounds x="659" y="424" width="121" height="94" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5">
-        <dc:Bounds x="1009" y="74" width="121" height="94" />
+        <dc:Bounds x="879" y="424" width="121" height="94" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Gateway_1spi9lo_di" bpmnElement="Gateway_1spi9lo" isMarkerVisible="true">
+        <dc:Bounds x="325" y="446" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="313" y="423" width="75" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Event_01bin3l_di" bpmnElement="Event_01bin3l">
+        <dc:Bounds x="1062" y="122" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1039" y="170" width="81" height="27" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Event_0l28lqi_di" bpmnElement="Event_0l28lqi">
+        <dc:Bounds x="1062" y="242" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1040" y="290" width="79" height="40" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Gateway_0m3yrzp_di" bpmnElement="Gateway_0m3yrzp" isMarkerVisible="true">
+        <dc:Bounds x="921" y="115" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="915" y="85" width="64" height="27" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_0ztykbe_di" bpmnElement="Activity_0ztykbe">
+        <dc:Bounds x="750" y="100" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_0tw406b_di" bpmnElement="Activity_0tw406b">
+        <dc:Bounds x="570" y="100" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true">
-        <dc:Bounds x="685" y="1080" width="781" height="196" />
+        <dc:Bounds x="555" y="1430" width="781" height="196" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz">
-        <di:waypoint x="1079" y="1184" />
-        <di:waypoint x="1353" y="1184" />
+        <di:waypoint x="949" y="1534" />
+        <di:waypoint x="1223" y="1534" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s">
-        <di:waypoint x="751" y="1184" />
-        <di:waypoint x="979" y="1184" />
+        <di:waypoint x="621" y="1534" />
+        <di:waypoint x="849" y="1534" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56">
-        <dc:Bounds x="715" y="1166" width="36" height="36" />
+        <dc:Bounds x="585" y="1516" width="36" height="36" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026">
-        <dc:Bounds x="1353" y="1166" width="36" height="36" />
+        <dc:Bounds x="1223" y="1516" width="36" height="36" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw">
-        <dc:Bounds x="979" y="1144" width="100" height="80" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge">
-        <dc:Bounds x="285" y="81" width="100" height="80" />
+        <dc:Bounds x="849" y="1494" width="100" height="80" />
       </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>