Add service operation initialtion in request db

Add service operation initialtion in request db

Change-Id: I2aed78e5cda753b5424b8a8c39e9997a7a7dd61c
Issue-ID: SO-422
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/DeleteCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy
index ebf9ae7..8c85433 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy
@@ -341,4 +341,54 @@
 	public void processJavaException(DelegateExecution execution) {

 		//TODO:

 	}

+

+	/**

+	 * Init the service Operation Status

+	 */

+	public void prepareInitServiceOperationStatus(DelegateExecution execution){

+		def isDebugEnabled = execution.getVariable("isDebugLogEnabled")

+		utils.log("DEBUG", " ======== STARTED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled)

+		try{

+			String serviceId = execution.getVariable("serviceInstanceId")

+			String operationId = execution.getVariable("operationId")

+			String userId = ""

+			String result = "processing"

+			String progress = "0"

+			String reason = ""

+			String operationContent = "Prepare service creation"

+			utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled)

+			serviceId = UriUtils.encode(serviceId,"UTF-8")

+

+			def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")

+			execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)

+			utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)

+

+			String payload =

+					"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

+                        xmlns:ns="http://org.openecomp.mso/requestsdb">

+                        <soapenv:Header/>

+                        <soapenv:Body>

+                            <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">

+                            <serviceId>${serviceId}</serviceId>

+                            <operationId>${operationId}</operationId>

+                            <operationType>DELETE</operationType>

+                            <userId>${userId}</userId>

+                            <result>${result}</result>

+                            <operationContent>${operationContent}</operationContent>

+                            <progress>${progress}</progress>

+                            <reason>${reason}</reason>

+                        </ns:updateServiceOperationStatus>

+                    </soapenv:Body>

+                </soapenv:Envelope>"""

+

+			payload = utils.formatXml(payload)

+			execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)

+			utils.log("DEBUG", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled)

+

+		}catch(Exception e){

+			utils.log("ERROR", "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)

+			execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage())

+		}

+		utils.log("DEBUG", "======== COMPLETED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled)

+	}

 }

diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn
index 013b5b2..e0747eb 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn
@@ -111,7 +111,7 @@
       <bpmn:sequenceFlow id="SequenceFlow_1py6yqz" sourceRef="ScriptTask_0so3xj0" targetRef="CallActivity_1qhekgt" />
     </bpmn:subProcess>
     <bpmn:scriptTask id="ScriptTask_1mao77y" name="Send Sync Ack Response" scriptFormat="groovy">
-      <bpmn:incoming>SequenceFlow_0yowshs</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_1dkcu9o</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0zf2qyk</bpmn:outgoing>
       <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
 def csi = new  DeleteCustomE2EServiceInstance()
@@ -130,20 +130,51 @@
     <bpmn:sequenceFlow id="SequenceFlow_0zf2qyk" sourceRef="ScriptTask_1mao77y" targetRef="CallActivity_1vyx9hu" />
     <bpmn:sequenceFlow id="SequenceFlow_07hrbs0" sourceRef="CallActivity_1vyx9hu" targetRef="ExclusiveGateway_0vu8gx6" />
     <bpmn:sequenceFlow id="SequenceFlow_1ab5l2q" sourceRef="CallActivity_1wx4ihe" targetRef="EndEvent_0db8bs6" />
-    <bpmn:sequenceFlow id="SequenceFlow_0yowshs" sourceRef="ScriptTask_0a63hms" targetRef="ScriptTask_1mao77y" />
+    <bpmn:sequenceFlow id="SequenceFlow_0yowshs" sourceRef="ScriptTask_0a63hms" targetRef="Task_1jksf62" />
     <bpmn:sequenceFlow id="SequenceFlow_04urx2e" name="yes" sourceRef="ExclusiveGateway_0vu8gx6" targetRef="ScriptTask_1fzpbop">
       <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("WorkflowException") == null}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:sequenceFlow id="SequenceFlow_1ii935p" sourceRef="ScriptTask_1fzpbop" targetRef="CallActivity_1wx4ihe" />
     <bpmn:sequenceFlow id="SequenceFlow_1t6ekab" name="no" sourceRef="ExclusiveGateway_0vu8gx6" targetRef="EndEvent_1i1g9s6" />
+    <bpmn:sequenceFlow id="SequenceFlow_0c4t26p" sourceRef="Task_1jksf62" targetRef="ServiceTask_0j9q5xe" />
+    <bpmn:scriptTask id="Task_1jksf62" name="prepare init operation status" scriptFormat="groovy">
+      <bpmn:incoming>SequenceFlow_0yowshs</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_0c4t26p</bpmn:outgoing>
+      <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
+def csi= new DeleteCustomE2EServiceInstance()
+csi.prepareInitServiceOperationStatus(execution)]]></bpmn:script>
+    </bpmn:scriptTask>
+    <bpmn:serviceTask id="ServiceTask_0j9q5xe" name="Update Service Operation Status">
+      <bpmn:extensionElements>
+        <camunda:connector>
+          <camunda:inputOutput>
+            <camunda:inputParameter name="url">${CVFMI_dbAdapterEndpoint}</camunda:inputParameter>
+            <camunda:inputParameter name="headers">
+              <camunda:map>
+                <camunda:entry key="content-type">application/soap+xml</camunda:entry>
+                <camunda:entry key="Authorization">Basic QlBFTENsaWVudDpwYXNzd29yZDEk</camunda:entry>
+              </camunda:map>
+            </camunda:inputParameter>
+            <camunda:inputParameter name="payload">${CVFMI_updateServiceOperStatusRequest}</camunda:inputParameter>
+            <camunda:inputParameter name="method">POST</camunda:inputParameter>
+            <camunda:outputParameter name="CVFMI_dbResponseCode">${statusCode}</camunda:outputParameter>
+            <camunda:outputParameter name="CVFMI_dbResponse">${response}</camunda:outputParameter>
+          </camunda:inputOutput>
+          <camunda:connectorId>http-connector</camunda:connectorId>
+        </camunda:connector>
+      </bpmn:extensionElements>
+      <bpmn:incoming>SequenceFlow_0c4t26p</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1dkcu9o</bpmn:outgoing>
+    </bpmn:serviceTask>
+    <bpmn:sequenceFlow id="SequenceFlow_1dkcu9o" sourceRef="ServiceTask_0j9q5xe" targetRef="ScriptTask_1mao77y" />
   </bpmn:process>
   <bpmn:error id="Error_1erlsmy" name="MSO Workflow Exception" errorCode="MSOWorkflowException" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteCustomE2EServiceInstance">
       <bpmndi:BPMNShape id="StartEvent_00m8zen_di" bpmnElement="StartEvent_00m8zen">
-        <dc:Bounds x="577" y="209" width="36" height="36" />
+        <dc:Bounds x="490" y="209" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="560" y="250" width="70" height="24" />
+          <dc:Bounds x="471" y="250" width="74" height="24" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="SubProcess_0amn8vu_di" bpmnElement="SubProcess_0amn8vu" isExpanded="true">
@@ -159,7 +190,7 @@
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_0a63hms_di" bpmnElement="ScriptTask_0a63hms">
-        <dc:Bounds x="741" y="187" width="100" height="80" />
+        <dc:Bounds x="562" y="187" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1fzpbop_di" bpmnElement="ScriptTask_1fzpbop">
         <dc:Bounds x="1453" y="187" width="100" height="80" />
@@ -171,7 +202,7 @@
         <dc:Bounds x="736" y="374" width="679" height="194" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1mao77y_di" bpmnElement="ScriptTask_1mao77y">
-        <dc:Bounds x="920" y="187" width="100" height="80" />
+        <dc:Bounds x="970" y="187" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ExclusiveGateway_0vu8gx6_di" bpmnElement="ExclusiveGateway_0vu8gx6" isMarkerVisible="true">
         <dc:Bounds x="1318" y="202" width="50" height="50" />
@@ -186,19 +217,17 @@
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1wxumid_di" bpmnElement="SequenceFlow_1wxumid">
-        <di:waypoint xsi:type="dc:Point" x="613" y="227" />
-        <di:waypoint xsi:type="dc:Point" x="741" y="227" />
+        <di:waypoint xsi:type="dc:Point" x="526" y="227" />
+        <di:waypoint xsi:type="dc:Point" x="562" y="227" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="587" y="212" width="90" height="12" />
+          <dc:Bounds x="499" y="206" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0zf2qyk_di" bpmnElement="SequenceFlow_0zf2qyk">
-        <di:waypoint xsi:type="dc:Point" x="1020" y="227" />
-        <di:waypoint xsi:type="dc:Point" x="1073" y="227" />
-        <di:waypoint xsi:type="dc:Point" x="1073" y="227" />
+        <di:waypoint xsi:type="dc:Point" x="1070" y="227" />
         <di:waypoint xsi:type="dc:Point" x="1121" y="227" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="1043" y="227" width="0" height="12" />
+          <dc:Bounds x="1050.5" y="206" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_07hrbs0_di" bpmnElement="SequenceFlow_07hrbs0">
@@ -216,10 +245,10 @@
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0yowshs_di" bpmnElement="SequenceFlow_0yowshs">
-        <di:waypoint xsi:type="dc:Point" x="841" y="227" />
-        <di:waypoint xsi:type="dc:Point" x="920" y="227" />
+        <di:waypoint xsi:type="dc:Point" x="662" y="227" />
+        <di:waypoint xsi:type="dc:Point" x="707" y="227" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="835.5" y="206" width="90" height="12" />
+          <dc:Bounds x="639.5" y="206" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_04urx2e_di" bpmnElement="SequenceFlow_04urx2e">
@@ -327,6 +356,26 @@
           <dc:Bounds x="1060" y="463" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_0c4t26p_di" bpmnElement="SequenceFlow_0c4t26p">
+        <di:waypoint xsi:type="dc:Point" x="807" y="227" />
+        <di:waypoint xsi:type="dc:Point" x="833" y="227" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="820" y="206" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ScriptTask_1joo7s7_di" bpmnElement="Task_1jksf62">
+        <dc:Bounds x="707" y="187" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ServiceTask_0j9q5xe_di" bpmnElement="ServiceTask_0j9q5xe">
+        <dc:Bounds x="833" y="187" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1dkcu9o_di" bpmnElement="SequenceFlow_1dkcu9o">
+        <di:waypoint xsi:type="dc:Point" x="933" y="227" />
+        <di:waypoint xsi:type="dc:Point" x="970" y="227" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="951.5" y="206" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn:definitions>