Fix serviceType,serviceRole,serviceName saving in AAI also Adapter issues

Issue-ID: SO-3411

Signed-off-by: zm330 <zhangminyj@chinamobile.com>
Change-Id: I07eeb4e512a1a2cc67ac5bff7ee3227d90117fe7
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
index 8b452d3..aa34453 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
@@ -126,7 +126,7 @@
 
 
         String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName")
-        String serviceType = execution.getVariable("serviceType")
+        String serviceType = sliceParams.serviceProfile.get("sST")
         String serviceStatus = "deactivated"
         String modelInvariantUuid = sliceParams.getNSTInfo().invariantUUID
         String modelUuid = sliceParams.getNSTInfo().UUID
@@ -379,7 +379,7 @@
         allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2AnProfile()
         allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
         allocateAnNssi.nssiId = sliceTaskInfo.suggestNssiId
-        allocateAnNssi.nssiName = sliceTaskInfo.NSSTInfo.name
+        allocateAnNssi.nssiName = "nssi_An" + execution.getVariable("sliceServiceInstanceName")
         NsiInfo nsiInfo = new NsiInfo()
         nsiInfo.nsiId = sliceParams.suggestNsiId
         nsiInfo.nsiName = sliceParams.suggestNsiName
@@ -406,6 +406,8 @@
         serviceInfo.nsiId = sliceParams.suggestNsiId
         serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
         serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
+        serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST")
+        serviceInfo.nssiName = allocateAnNssi.nssiName
 
         nbiRequest.setServiceInfo(serviceInfo)
         nbiRequest.setEsrInfo(esrInfo)
@@ -499,7 +501,7 @@
         AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
         allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
         allocateCnNssi.nssiId = sliceTaskInfo.suggestNssiId
-        allocateCnNssi.nssiName = sliceTaskInfo.NSSTInfo.name
+        allocateCnNssi.nssiName = "nssi_Cn" + execution.getVariable("sliceServiceInstanceName")
         allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2CnProfile()
         NsiInfo nsiInfo = new NsiInfo()
         nsiInfo.nsiId = sliceParams.suggestNsiId
@@ -528,6 +530,8 @@
         serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
         serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
         serviceInfo.nssiId = sliceTaskInfo.suggestNssiId //if shared
+        serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST")
+        serviceInfo.nssiName = allocateCnNssi.nssiName
 
         nbiRequest.setServiceInfo(serviceInfo)
         nbiRequest.setEsrInfo(esrInfo)
@@ -656,6 +660,7 @@
         serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
         serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
         serviceInfo.nssiId = sliceTaskInfo.suggestNssiId
+        serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST")
 
         nbiRequest.setServiceInfo(serviceInfo)
         nbiRequest.setEsrInfo(esrInfo)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
index 35079d2..e88b1c7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
@@ -62,8 +62,10 @@
      */
     void sendCreateRequestNSSMF(DelegateExecution execution) {
         NssmfAdapterNBIRequest nbiRequest = execution.getVariable("nbiRequest") as NssmfAdapterNBIRequest
-        String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, NSSMF_ALLOCATE_URL,
-                objectMapper.writeValueAsString(nbiRequest))
+        String nssmfRequest = objectMapper.writeValueAsString(nbiRequest)
+        logger.debug("sendCreateRequestNSSMF: " + nssmfRequest)
+
+        String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, NSSMF_ALLOCATE_URL, nssmfRequest)
 
         if (response != null) {
             NssiResponse nssiResponse = objectMapper.readValue(response, NssiResponse.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
index ec70bd3..ccb04d9 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
@@ -100,7 +100,6 @@
          * todo: role
          */
         String serviceRole = "service-profile"
-        String serviceType = execution.getVariable("serviceType")
         String globalSubscriberId = execution.getVariable("globalSubscriberId")
         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
 
@@ -111,7 +110,7 @@
             ss.setServiceInstanceId(ssInstanceId)
             String sliceInstanceName = execution.getVariable("serviceInstanceName")
             ss.setServiceInstanceName(sliceInstanceName)
-            ss.setServiceType(serviceType)
+            ss.setServiceType(serviceProfile.get("sST"))
             String serviceStatus = "deactivated"
             ss.setOrchestrationStatus(serviceStatus)
             String modelInvariantUuid = modelInfo.getModelInvariantUuid()
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
index 9450227..25a7159 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
@@ -416,10 +416,10 @@
             sliceProfile.remove("domainType")
             SliceProfileAdapter adapter = objectMapper.readValue(objectMapper.writeValueAsString(sliceProfile), SliceProfileAdapter.class)
             switch (domainType.toLowerCase()) {
-                case "tn-bh":
+                case "tn_bh":
                     sliceParams.tnBHSliceTaskInfo.sliceProfile = adapter
                     break
-                case "an-nf":
+                case "an_nf":
                 case "an":
                     sliceParams.anSliceTaskInfo.sliceProfile = adapter
                     break
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy
index cf9a95e..4eb70a5 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy
@@ -101,7 +101,7 @@
 
     void createServiceInstance(DelegateExecution execution) {
 
-        String serviceRole = "TN"
+        String serviceRole = "nssi"
         String serviceType = execution.getVariable("subscriptionServiceType")
         String ssInstanceId = execution.getVariable("sliceServiceInstanceId")
         String sliceProfileStr = execution.getVariable("sliceProfile")
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCommunicationService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCommunicationService.bpmn
index a632266..04bab09 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCommunicationService.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCommunicationService.bpmn
@@ -145,7 +145,7 @@
         <camunda:in source="serviceInstanceId" target="serviceInstanceId" />
         <camunda:in source="csInputMap" target="csInputMap" />
         <camunda:in source="serviceInstanceName" target="serviceInstanceName" />
-        <camunda:in source="serviceType" target="serviceType" />
+        <camunda:in source="csServiceType" target="csServiceType" />
         <camunda:in source="uuiRequest" target="uuiRequest" />
         <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" />
         <camunda:in source="modelUuid" target="modelUuid" />
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn
index 1a9281f..290e13d 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn
@@ -34,7 +34,6 @@
         <camunda:in source="serviceInstanceName" target="serviceInstanceName" />
         <camunda:in source="globalSubscriberId" target="globalSubscriberId" />
         <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" />
-        <camunda:in source="serviceType" target="serviceType" />
         <camunda:in source="uuiRequest" target="uuiRequest" />
         <camunda:in source="operationId" target="operationId" />
         <camunda:out source="WorkflowException" target="WorkflowException" />