Transport Slicing Fixes
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / TnAllocateNssi.groovy
index 3367920..019e836 100644 (file)
@@ -27,10 +27,10 @@ import groovy.json.JsonSlurper
 import org.camunda.bpm.engine.delegate.BpmnError
 import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aaiclient.client.aai.AAIObjectType
 import org.onap.aaiclient.client.aai.AAIResourcesClient
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.common.scripts.RequestDBUtil
@@ -72,7 +72,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
 
             String additionalPropJsonStr = execution.getVariable("sliceParams")
 
-            String tnNssiId = execution.getVariable("serviceInstanceID")
+            String tnNssiId = jsonUtil.getJsonValue(additionalPropJsonStr, "serviceInstanceID") //for debug
             if (isBlank(tnNssiId)) {
                 tnNssiId = UUID.randomUUID().toString()
             }
@@ -116,10 +116,10 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
                 execution.setVariable("nsiInfo", nsiInfoStr)
             }
 
-            //nsiId is passed in from caller bpmn
-            //String nsiIdStr = jsonUtil.getJsonValue(nsiInfo, "nsiId")
-            //execution.setVariable("nsiId", nsiIdStr)
-
+            if (isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr,
+                    "enableSdnc", "enableSdnc"))) {
+                tnNssmfUtils.setEnableSdncConfig(execution)
+            }
         } catch (BpmnError e) {
             throw e
         } catch (Exception ex) {
@@ -153,7 +153,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
             "modelUuid":"${modelUuid}",
             "modelVersion":""
              }"""
-        execution.setVariable("ssServiceModelInfo", serviceModelInfo)
+        execution.setVariable("serviceModelInfo", serviceModelInfo)
 
         logger.debug("Finish prepareDecomposeService")
     }
@@ -184,13 +184,14 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
         if (maxIndex < 1) {
             String msg = "Exception in TN NSST processDecomposition. There is no NSST associated with TN NSST "
             logger.info(msg)
-            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+            //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+        } else {
+            execution.setVariable("tnNsstInfoList", nsstInfoList)
+            execution.setVariable("tnModelVersion", tnModelVersion)
+            execution.setVariable("tnModelName", tnModelName)
+            execution.setVariable("currentIndex", currentIndex)
+            execution.setVariable("maxIndex", maxIndex)
         }
-        execution.setVariable("tnNsstInfoList", nsstInfoList)
-        execution.setVariable("tnModelVersion", tnModelVersion)
-        execution.setVariable("tnModelName", tnModelName)
-        execution.setVariable("currentIndex", currentIndex)
-        execution.setVariable("maxIndex", maxIndex)
 
         logger.debug("End processDecomposition")
     }
@@ -302,7 +303,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
             ServiceInstance si = new ServiceInstance()
             si.setOrchestrationStatus(orchStatus)
             AAIResourcesClient client = new AAIResourcesClient()
-            AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceServiceInstanceId)
+            AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceServiceInstanceId))
             client.update(uri, si)
         } catch (BpmnError e) {
             throw e
@@ -320,19 +321,21 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
                                 String status,
                                 String progress,
                                 String statusDescription) {
-        String serviceId = execution.getVariable("sliceServiceInstanceId")
+        String modelUuid = execution.getVariable("modelUuid")
+        String ssInstanceId = execution.getVariable("sliceServiceInstanceId")
         String jobId = execution.getVariable("jobId")
         String nsiId = execution.getVariable("nsiId")
 
         ResourceOperationStatus roStatus = new ResourceOperationStatus()
-        roStatus.setServiceId(serviceId)
+        roStatus.setServiceId(nsiId)
         roStatus.setOperationId(jobId)
-        roStatus.setResourceTemplateUUID(nsiId)
-        roStatus.setOperType("Allocate")
+        roStatus.setResourceTemplateUUID(modelUuid)
+        roStatus.setResourceInstanceID(ssInstanceId)
+        roStatus.setOperType("ALLOCATE")
         roStatus.setProgress(progress)
         roStatus.setStatus(status)
         roStatus.setStatusDescription(statusDescription)
-        requestDBUtil.prepareUpdateResourceOperationStatus(execution, status)
+        requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
     }
 
 }