Fix service topology deletion

Fix request body for service topology deletion.

Issue-ID: SO-422
Change-Id: Ic2e7cc74dd45dbc4b4a190a159f3ebb852e02b84
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy
index 3591243..b2a7bb6 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy
@@ -272,6 +272,7 @@
     }
     
     public void prepareFinishedProgressForResource(execution) {
+
         String serviceInstanceId = execution.getVariable("serviceInstanceId")
         String serviceType = execution.getVariable("serviceType")
         String resourceInstanceId = execution.getVariable("resourceInstanceId")
@@ -305,4 +306,22 @@
         execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
         execution.setVariable("CVFMI_updateResOperStatusRequest", body)
     }
+
+    public void prepareServiceTopologyDeletion(DelegateExecution execution) {
+        def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+        utils.log("INFO"," ***** prepareServiceTopologyDeletion "  + " *****", isDebugEnabled)
+
+        ModelInfo serviceModelInfo = execution.getVariable("serviceModelInfo")
+
+        execution.setVariable("modelInvariantUuid", serviceModelInfo.getModelInvariantUuid())
+        execution.setVariable("modelVersion", serviceModelInfo.getModelVersion())
+        execution.setVariable("modelUuid", serviceModelInfo.getModelUuid())
+        execution.setVariable("serviceModelName", serviceModelInfo.getModelName())
+
+        // set operation type and resource type is required to form request body
+        execution.setVariable("operationType", "DELETE")
+        execution.setVariable("resourceType", "SDNC-SERVICE-TOPOLOGY")
+
+        utils.log("INFO"," ***** prepareServiceTopologyDeletion "  + " *****", isDebugEnabled)
+    }
 }
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn
index 8da0ae0..b74c169 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteResourcesV1.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: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="1.10.0">
+<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="1.11.3">
   <bpmn:process id="DoDeleteResourcesV1" name="DoDeleteResourcesV1" isExecutable="true">
     <bpmn:startEvent id="StartEvent_1" name="Start Resource Delete">
       <bpmn:outgoing>SequenceFlow_0stqur4</bpmn:outgoing>
@@ -58,7 +58,7 @@
       <bpmn:sequenceFlow id="SequenceFlow_117fiux" name="" sourceRef="ScriptTask_0plexin" targetRef="EndEvent_0gh3mcj" />
     </bpmn:subProcess>
     <bpmn:serviceTask id="ServiceTask_176j3rl" name="Call Delete SDNC Service Topology" camunda:class="org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncServiceTopologyOperationTask">
-      <bpmn:incoming>SequenceFlow_1s1nnmj</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_11h5pba</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_174yrgl</bpmn:outgoing>
     </bpmn:serviceTask>
     <bpmn:exclusiveGateway id="ExclusiveGateway_1x63i6w" name="Is SDNC Service Contained">
@@ -70,7 +70,7 @@
     <bpmn:endEvent id="EndEvent_17bzayo" name="End Resource Deletion">
       <bpmn:incoming>SequenceFlow_0o21fg8</bpmn:incoming>
     </bpmn:endEvent>
-    <bpmn:sequenceFlow id="SequenceFlow_1s1nnmj" name="yes" sourceRef="ExclusiveGateway_1x63i6w" targetRef="ServiceTask_176j3rl">
+    <bpmn:sequenceFlow id="SequenceFlow_1s1nnmj" name="yes" sourceRef="ExclusiveGateway_1x63i6w" targetRef="prepareSDNCServiceTopologyDelete">
       <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("isContainsWanResource" )  == "true" )}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:sequenceFlow id="SequenceFlow_174yrgl" sourceRef="ServiceTask_176j3rl" targetRef="ExclusiveGateway_1jybr0n" />
@@ -148,6 +148,14 @@
     <bpmn:sequenceFlow id="SequenceFlow_11bgbsh" sourceRef="ScriptTask_0shhhxr" targetRef="ServiceTask_1bw1mjh" />
     <bpmn:sequenceFlow id="SequenceFlow_19ccmqv" name="no" sourceRef="ExclusiveGateway_0khn1my" targetRef="ScriptTask_0shhhxr" />
     <bpmn:sequenceFlow id="SequenceFlow_0djplpd" sourceRef="ServiceTask_1bw1mjh" targetRef="ScriptTask_1gf78zz" />
+    <bpmn:sequenceFlow id="SequenceFlow_11h5pba" sourceRef="prepareSDNCServiceTopologyDelete" targetRef="ServiceTask_176j3rl" />
+    <bpmn:scriptTask id="prepareSDNCServiceTopologyDelete" name="Prepare SDNC service Topology Delete" scriptFormat="groovy">
+      <bpmn:incoming>SequenceFlow_1s1nnmj</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_11h5pba</bpmn:outgoing>
+      <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
+def ddr = new DoDeleteResourcesV1()
+ddr.prepareServiceTopologyDeletion(execution)]]></bpmn:script>
+    </bpmn:scriptTask>
   </bpmn:process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeleteResourcesV1">
@@ -242,7 +250,7 @@
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ServiceTask_176j3rl_di" bpmnElement="ServiceTask_176j3rl">
-        <dc:Bounds x="604" y="566" width="100" height="80" />
+        <dc:Bounds x="689" y="566" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ExclusiveGateway_1x63i6w_di" bpmnElement="ExclusiveGateway_1x63i6w" isMarkerVisible="true">
         <dc:Bounds x="396" y="581" width="50" height="50" />
@@ -265,16 +273,16 @@
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1s1nnmj_di" bpmnElement="SequenceFlow_1s1nnmj">
         <di:waypoint xsi:type="dc:Point" x="446" y="606" />
-        <di:waypoint xsi:type="dc:Point" x="604" y="606" />
+        <di:waypoint xsi:type="dc:Point" x="525" y="606" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="516" y="585" width="20" height="12" />
+          <dc:Bounds x="476" y="585" width="20" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_174yrgl_di" bpmnElement="SequenceFlow_174yrgl">
-        <di:waypoint xsi:type="dc:Point" x="704" y="606" />
+        <di:waypoint xsi:type="dc:Point" x="789" y="606" />
         <di:waypoint xsi:type="dc:Point" x="827" y="606" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="765.5" y="585" width="0" height="12" />
+          <dc:Bounds x="763" y="585" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0lk19rm_di" bpmnElement="SequenceFlow_0lk19rm">
@@ -381,6 +389,16 @@
           <dc:Bounds x="930" y="206" width="0" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_11h5pba_di" bpmnElement="SequenceFlow_11h5pba">
+        <di:waypoint xsi:type="dc:Point" x="625" y="606" />
+        <di:waypoint xsi:type="dc:Point" x="689" y="606" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="657" y="585" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ScriptTask_0va5zgp_di" bpmnElement="prepareSDNCServiceTopologyDelete">
+        <dc:Bounds x="525" y="566" width="100" height="80" />
+      </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn:definitions>