fixed cs profile trans to ss profile 67/114867/21
authorhetengjiao <hetengjiao@chinamobile.com>
Fri, 13 Nov 2020 07:18:59 +0000 (15:18 +0800)
committerhetengjiao <hetengjiao@chinamobile.com>
Tue, 17 Nov 2020 03:53:27 +0000 (11:53 +0800)
Issue-ID: SO-2963

Signed-off-by: hetengjiao <hetengjiao@chinamobile.com>
Change-Id: Ia5a40ac9126641479047a0a76c7d2fefc1d6f07d

14 files changed:
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java
adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn
common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java
common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java [new file with mode: 0644]
common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java
common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java

index 0b332af..e397201 100644 (file)
@@ -77,6 +77,12 @@ public class NssmfManagerBuilder {
             return;
         }
 
+        if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.TRANSPORT.equals(networkType)) {
+            this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType)
+                    .setInitStatus("activated");
+            return;
+        }
+
         if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) {
             this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType)
                     .setInitStatus("activated");
index acaa394..2de6e01 100644 (file)
@@ -193,7 +193,7 @@ public abstract class BaseNssmfManager implements NssmfManager {
         return doQuerySubnetCapability(nbiRequest.getSubnetCapabilityQuery());
     }
 
-    protected abstract <T> RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException;
+    protected abstract RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException;
 
     /**
      * send request to nssmf
index 9dcd2d4..3c5be7e 100644 (file)
@@ -180,11 +180,11 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager {
     }
 
     @Override
-    protected <T> RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException {
+    protected RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException {
 
         ObjectMapper oMapper = new ObjectMapper();
         InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json");
-        Map<String, Object> subnetCapability = new HashMap<>();
+        Map subnetCapability = new HashMap<>();
         try {
             subnetCapability = oMapper.readValue(inputStream, Map.class);
         } catch (Exception e) {
@@ -201,7 +201,7 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager {
         try {
             response = oMapper.writeValueAsString(responseMap);
         } catch (JsonProcessingException e) {
-            logger.debug("Exception while converting subnet capability object to String {}", e);
+            logger.debug("Exception while converting subnet capability object to String {}", e.getMessage());
         }
 
         RestResponse rsp = new RestResponse();
index 296c30c..e89160c 100644 (file)
@@ -122,7 +122,7 @@ public abstract class InternalNssmfManager extends BaseNssmfManager {
     protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
 
     @Override
-    protected <T> RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException {
+    protected RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException {
         // handler
         return sendRequest(marshal(req));
     }
index f150f47..2d79544 100644 (file)
@@ -77,9 +77,9 @@ public class NssmfAdapterRestTest {
     private final static String ALLOCATE = "{\n" + "  \"esrInfo\" : {\n" + "    \"vendor\" : \"huawei\",\n"
             + "    \"networkType\" : \"cn\"\n" + "  },\n" + "  \"allocateCnNssi\" : {\n"
             + "    \"nssiId\" : \"NSST-C-001-HDBNJ-NSSMF-01-A-ZX\",\n" + "    \"nssiName\" : \"eMBB-001\",\n"
-            + "    \"sliceProfile\" : {\n" + "      \"snssaiList\" : [ \"001-100001\" ],\n"
+            + "    \"sliceProfile\" : {\n" + "      \"sNSSAIList\" : [ \"001-100001\" ],\n"
             + "      \"sliceProfileId\" : \"ab9af40f13f721b5f13539d87484098\",\n"
-            + "      \"plmnIdList\" : [ \"460-00\", \"460-01\" ],\n" + "      \"perfReq\" : {\n"
+            + "      \"pLMNIdList\" : [ \"460-00\", \"460-01\" ],\n" + "      \"perfReq\" : {\n"
             + "        \"perfReqEmbbList\" : [ {\n" + "          \"activityFactor\" : 50\n" + "        } ]\n"
             + "      },\n" + "      \"maxNumberofUEs\" : 200,\n"
             + "      \"coverageAreaTAList\" : [ \"1\", \"2\", \"3\" ],\n" + "      \"latency\" : 6,\n"
index 6784591..bb6fe21 100644 (file)
@@ -43,6 +43,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
 import org.onap.so.db.request.beans.OperationStatus
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
+import org.springframework.util.StringUtils
 import org.springframework.web.util.UriUtils
 
 import static org.apache.commons.lang3.StringUtils.isBlank
@@ -317,14 +318,9 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor {
 
             Map<String, ?> csInputMap = new HashMap<>()
             for (String csInput : csInputs) {
-                def value
-                if (jsonUtil.getJsonValue(csInput, "type") == "integer") {
-                    value = jsonUtil.getJsonValue(csInput, "default")
-                    csInputMap.put(jsonUtil.getJsonValue(csInput, "name"), isBlank(value) ? 0 : (value as Integer))
-                } else if (jsonUtil.getJsonValue(csInput, "type") == "string") {
-                    csInputMap.put(jsonUtil.getJsonValue(csInput, "name"),
-                            jsonUtil.getJsonValue(csInput, "default"))
-                }
+                String key = jsonUtil.getJsonValue(csInput, "name")
+                def value = jsonUtil.getJsonValue(csInput, "default")
+                csInputMap.put(key, getDefaultPropertiesByType(value, key))
             }
             csInputMap.put("expDataRateDL", expDataRateDL)
             csInputMap.put("expDataRateUL", expDataRateUL)
@@ -336,6 +332,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor {
             csInputMap.put("useInterval", useInterval)
 
             execution.setVariable("csInputMap", csInputMap)
+            logger.debug(Prefix + "csInputMap is = " + csInputMap.toString())
         } catch (BpmnError e) {
             throw e
         } catch (Exception ex) {
@@ -365,53 +362,45 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor {
 
             Map<String, ?> csInputMap = execution.getVariable("csInputMap") as Map
             Map<String, ?> e2eInputMap = new HashMap<>()
-            String key
-            def value
-
 
             for (String e2eInput in e2eInputs) {
-                key = jsonUtil.getJsonValue(e2eInput, "name")
+                String key = jsonUtil.getJsonValue(e2eInput, "name")
                 String type = jsonUtil.getJsonValue(e2eInput, "type")
-                if (type == "integer") {
-                    def temp
-                    value = csInputMap.containsKey(key) ? csInputMap.getOrDefault(key, 0) : (isBlank(temp = jsonUtil.getJsonValue(e2eInput, "default")) ? 0 : temp)
-
-                    e2eInputMap.put(key, value as Integer)
-                } else if(type == "string") {
-                    e2eInputMap.put(key, csInputMap.containsKey(key)
-                            ? csInputMap.getOrDefault(key, null) : (jsonUtil.getJsonValue(e2eInput, "default")))
+                def value
+                if (csInputMap.containsKey(key)) {
+                    value = csInputMap.get(key)
+                } else {
+                    value = jsonUtil.getJsonValue(e2eInput, "default")
 
                 }
+                e2eInputMap.put(key, getDefaultPropertiesByType(value, type))
             }
 
             //TODO temp solution
             e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id"))
                e2eInputMap.put("sST", execution.getVariable("csServiceType"))
 
-            Integer activityFactor = 60
+            Integer activityFactor = Integer.parseInt(e2eInputMap.get("activityFactor").toString())
             Integer random = new Random().nextInt(5) + 2
             Integer dLThptPerUE = Integer.parseInt(csInputMap.get("expDataRateDL").toString())
             Integer uLThptPerUE = Integer.parseInt(csInputMap.get("expDataRateUL").toString())
-            Integer maxNumberofUEs = Integer.parseInt(csInputMap.get("maxNumberofUEs").toString())
+            Integer maxNumberofUEs = Integer.parseInt(e2eInputMap.get("maxNumberofUEs").toString())
             Integer dLThptPerSlice = dLThptPerUE * maxNumberofUEs * activityFactor * random
             Integer uLThptPerSlice = uLThptPerUE * maxNumberofUEs * activityFactor * random
             Integer maxNumberofConns = maxNumberofUEs * activityFactor * 3
 
             e2eInputMap.put("jitter", 10)
-            e2eInputMap.put("activityFactor", activityFactor)
-            e2eInputMap.put("maxNumberofUEs", maxNumberofUEs)
             e2eInputMap.put("dLThptPerUE", dLThptPerUE)
             e2eInputMap.put("uLThptPerUE", uLThptPerUE)
             e2eInputMap.put("dLThptPerSlice", dLThptPerSlice)
             e2eInputMap.put("uLThptPerSlice", uLThptPerSlice)
             e2eInputMap.put("maxNumberofConns", maxNumberofConns)
-            e2eInputMap.put("coverageAreaTAList", csInputMap.get("coverageAreaList"))
 
             execution.setVariable("e2eInputMap", e2eInputMap)
             execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType())
             execution.setVariable("e2eModelInvariantUuid", e2eServiceDecomposition.getModelInfo().getModelInvariantUuid())
             execution.setVariable("e2eModelUuid", e2eServiceDecomposition.getModelInfo().getModelUuid())
-
+            logger.debug(Prefix + "e2eInputMap is = " + e2eInputMap.toString())
         } catch (BpmnError e) {
             throw e
         } catch (Exception ex) {
@@ -423,6 +412,25 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor {
         logger.debug(Prefix + "generateE2EServiceProfile Exit")
     }
 
+    static def getDefaultPropertiesByType(def value, String type) {
+
+        def defaultValue
+        switch (type) {
+            case "string":
+                defaultValue = ""
+                break
+            case "integer":
+                defaultValue = 0
+                break
+            case "float":
+                defaultValue = 0.0
+                break
+            default:
+                defaultValue = null
+                break
+        }
+        return StringUtils.isEmpty(value) ? defaultValue : value
+    }
 
     /**
      * call createE2EService get operation id,
@@ -453,7 +461,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor {
                 }
             """
             execution.setVariable("CSMF_NSMFRequest", payload.replaceAll("\\s+", ""))
-
+            logger.debug(Prefix + "Sent to NSMF Request = " + payload)
         } catch (BpmnError e) {
             throw e
         } catch (Exception ex) {
index c136d52..d59c0cf 100644 (file)
@@ -354,6 +354,8 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
             nstInfo.setName(nstSolution.get("NSTName") as String)
 
             sliceTaskParams.setNSTInfo(nstInfo)
+            sliceTaskParams.setNstId(nstSolution.get("UUID") as String)
+            sliceTaskParams.setNstName(nstSolution.get("NSTName") as String)
 
             execution.setVariable("sliceTaskParams", sliceTaskParams)
 
index 1d7acd3..4b020c7 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.onap.so.bpmn.infrastructure.scripts
 
+import org.onap.so.beans.nsmf.SliceProfileAdapter
 import org.onap.so.beans.nsmf.oof.SubnetType
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 import javax.ws.rs.NotFoundException
@@ -36,15 +37,12 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
 import org.onap.so.beans.nsmf.AllocateAnNssi
 import org.onap.so.beans.nsmf.AllocateCnNssi
 import org.onap.so.beans.nsmf.AllocateTnNssi
-import org.onap.so.beans.nsmf.AnSliceProfile
-import org.onap.so.beans.nsmf.CnSliceProfile
 import org.onap.so.beans.nsmf.EsrInfo
 import org.onap.so.beans.nsmf.NssiResponse
 import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
 import org.onap.so.beans.nsmf.ServiceInfo
 import org.onap.so.beans.nsmf.SliceTaskInfo
 import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
-import org.onap.so.beans.nsmf.TnSliceProfile
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.core.json.JsonUtils
 import org.slf4j.Logger
@@ -239,7 +237,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
 
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
-        SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo
+        SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo
         sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
 
         // create slice profile
@@ -275,15 +273,15 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
 
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
-        SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo
-        AnSliceProfile anSliceProfile = sliceTaskInfo.sliceProfile
+        SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo
+        SliceProfileAdapter anSliceProfile = sliceTaskInfo.sliceProfile
 
         String profileId = UUID.randomUUID().toString()
         anSliceProfile.setSliceProfileId(profileId)
 
         SliceProfile sliceProfile = new SliceProfile()
         sliceProfile.setProfileId(profileId)
-        sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList as String)
+        sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList)
         //todo:...
         AAIResourceUri uri = AAIUriFactory.createResourceUri(
             AAIFluentTypeBuilder.business().customer(globalSubscriberId)
@@ -304,12 +302,16 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         //todo:
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
-        SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo
+        SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo
 
         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
 
         AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
-        allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile
+        allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2AnProfile()
+        allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
+        allocateAnNssi.nssiId = sliceTaskInfo.suggestNssiId
+        allocateAnNssi.nssiName = sliceTaskInfo.NSSTInfo.name
+        allocateAnNssi.nsiInfo.nsiId = sliceParams.suggestNsiId
 
         EsrInfo esrInfo = new EsrInfo()
         //todo: vendor and network
@@ -354,7 +356,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
 
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
-        SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo
+        SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo
         sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
 
         // create slice profile
@@ -392,8 +394,8 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
-        SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo
-        CnSliceProfile cnSliceProfile = sliceTaskInfo.sliceProfile
+        SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo
+        SliceProfileAdapter cnSliceProfile = sliceTaskInfo.sliceProfile
 
         String profileId = UUID.randomUUID().toString()
         cnSliceProfile.setSliceProfileId(profileId)
@@ -416,7 +418,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         //todo:
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
-        SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo
+        SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo
 
         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
 
@@ -424,7 +426,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
         allocateCnNssi.nssiId = sliceTaskInfo.suggestNssiId
         allocateCnNssi.nssiName = sliceTaskInfo.NSSTInfo.name
-        allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile
+        allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2CnProfile()
         allocateCnNssi.nsiInfo.nsiId = sliceParams.suggestNsiId
 
         EsrInfo esrInfo = new EsrInfo()
@@ -469,7 +471,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
-        SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
+        SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
         String serviceInstanceId = UUID.randomUUID().toString()
 
         sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
@@ -510,9 +512,9 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
-        SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
+        SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
 
-        TnSliceProfile tnSliceProfile = sliceTaskInfo.sliceProfile
+        SliceProfileAdapter tnSliceProfile = sliceTaskInfo.sliceProfile
         String profileId = UUID.randomUUID().toString()
         tnSliceProfile.setSliceProfileId(profileId)
 
@@ -534,7 +536,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         //todo:
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
-        SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
+        SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
 
         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
 
@@ -545,6 +547,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         allocateTnNssi.setNetworkSliceInfos()
 
 
+
         //allocateTnNssi.networkSliceInfos
 
         EsrInfo esrInfo = new EsrInfo()
index 2cce68a..9450227 100644 (file)
@@ -22,13 +22,12 @@ package org.onap.so.bpmn.infrastructure.scripts
 
 import com.fasterxml.jackson.databind.ObjectMapper
 import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.so.beans.nsmf.AnSliceProfile
-import org.onap.so.beans.nsmf.CnSliceProfile
 import org.onap.so.beans.nsmf.EsrInfo
 import org.onap.so.beans.nsmf.NetworkType
 import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
+import org.onap.so.beans.nsmf.QuerySubnetCapability
+import org.onap.so.beans.nsmf.SliceProfileAdapter
 import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
-import org.onap.so.beans.nsmf.TnSliceProfile
 import org.onap.so.beans.nsmf.oof.SubnetCapability
 import org.onap.so.beans.nsmf.oof.SubnetType
 import org.onap.so.beans.nsmf.oof.TemplateInfo
@@ -45,6 +44,7 @@ import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 import org.springframework.util.StringUtils
 
+
 class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
 
     private static final Logger logger = LoggerFactory.getLogger(DoCreateSliceServiceOption.class)
@@ -185,6 +185,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
 
         execution.setVariable("sliceTaskParams", sliceParams)
         execution.setVariable("subnetCapabilities", subnetCapabilities)
+        execution.setVariable("queryNsiFirst", true)
         logger.debug("sliceTaskParams= " + sliceParams.toString())
     }
 
@@ -290,13 +291,12 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
         NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
 
         List<String> subnetTypes =  new ArrayList<>()
-
         subnetTypes.add(subnetType.subnetType)
 
-        Map<String, Object> paramMap = new  HashMap<>()
-        paramMap.put("subnetTypes", subnetTypes)
+        QuerySubnetCapability req = new QuerySubnetCapability()
+        req.setSubnetTypes(subnetTypes)
 
-        request.setSubnetCapabilityQuery(paramMap)
+        request.setSubnetCapabilityQuery(req)
 
         EsrInfo esrInfo = new EsrInfo()
         esrInfo.setVendor(vendor)
@@ -362,66 +362,73 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
 
         Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class)
         String requestStatus = resMap.get("requestStatus")
-        if (StringUtils.isEmpty(requestStatus)) {
+        if (!StringUtils.isEmpty(requestStatus) && requestStatus == "error") {
             exceptionUtil.buildWorkflowException(execution, 7000, "get nsi from oof error: " + oofResponse)
+            return
         }
 
         List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
 
         Map<String, Object> solution = nsiSolutions.get(0)
 
-        String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
-        Boolean isSharable = resourceSharingLevel == "shared"
+        //String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
+        //Boolean isSharable = resourceSharingLevel == "shared"
 
         if (solution != null) {
-            if (isSharable && solution.get("existingNSI")) {
-                //sharedNSISolution
-                processSharedNSI(solution, sliceTaskParams)
-                execution.setVariable("needQuerySliceProfile", true)
-            }
-            else {
-                if(execution.getVariable("needQuerySliceProfile")){
+            if (execution.getVariable("queryNsiFirst")) {
+                if (solution.get("existingNSI")) {
+                    execution.setVariable("needQuerySliceProfile", true)
+                } else {
+                    processNewNSI(solution, sliceTaskParams)
                     execution.setVariable("needQuerySliceProfile", false)
                 }
-                processNewNSI(solution, sliceTaskParams)
+                execution.setVariable("queryNsiFirst", false)
+            } else {
+                processSharedNSI(solution, sliceTaskParams)
+                execution.setVariable("needQuerySliceProfile", false)
             }
         }
         execution.setVariable("sliceTaskParams", sliceTaskParams)
+        logger.debug("after req to oof for nis select, sliceTaskParams = " + sliceTaskParams)
         logger.debug("*** Completed options Call to OOF ***")
     }
 
-    private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
+    private static void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
         Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map
-
         String nsiId = sharedNSISolution.get("NSIId")
         String nsiName = sharedNSISolution.get("NSIName")
         sliceParams.setSuggestNsiId(nsiId)
         sliceParams.setSuggestNsiName(nsiName)
 
+        List<Map> sliceProfiles = sharedNSISolution.get("sliceProfiles") as List<Map>
+        handleSliceProfiles(sliceProfiles, sliceParams)
     }
 
-    private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
+    private static void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
         Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map
         List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map>
+        handleSliceProfiles(sliceProfiles, sliceParams)
+    }
+
+    static def handleSliceProfiles(List<Map> sliceProfiles, SliceTaskParamsAdapter sliceParams) {
         for (Map sliceProfile : sliceProfiles) {
             String domainType = sliceProfile.get("domainType")
+            sliceProfile.remove("domainType")
+            SliceProfileAdapter adapter = objectMapper.readValue(objectMapper.writeValueAsString(sliceProfile), SliceProfileAdapter.class)
             switch (domainType.toLowerCase()) {
                 case "tn-bh":
-                    sliceParams.tnBHSliceTaskInfo.sliceProfile = sliceProfile as TnSliceProfile
+                    sliceParams.tnBHSliceTaskInfo.sliceProfile = adapter
                     break
                 case "an-nf":
                 case "an":
-                    sliceParams.anSliceTaskInfo.sliceProfile = sliceProfile as AnSliceProfile
+                    sliceParams.anSliceTaskInfo.sliceProfile = adapter
                     break
                 case "cn":
-                    sliceParams.cnSliceTaskInfo.sliceProfile = sliceProfile as CnSliceProfile
+                    sliceParams.cnSliceTaskInfo.sliceProfile = adapter
                     break
                 default:
                     break
             }
-
-            //todo
-
         }
     }
 
@@ -485,7 +492,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
         String selection = resMap.get("selection")
 
         if ("NSMF".equalsIgnoreCase(selection)) {
-            execution.setVariable("NEED_CN_NSSI_SELECTION", true)
+            //execution.setVariable("NEED_CN_NSSI_SELECTION", true)
         }
     }
 
@@ -597,7 +604,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
 
         TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo
         Map<String, Object> profileInfo = nssiNeedHandlerInfo.get("sliceProfile") as Map
-        profileInfo.remove("profileId")
+        //profileInfo.remove("profileId")
 
         String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
         logger.debug( "get NSI option OOF Url: " + urlString)
index 9656c86..a1f9a83 100644 (file)
@@ -5,7 +5,7 @@
       <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing>
     </bpmn:startEvent>
     <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_0vilb24" name="Waiting for confirmation">
-      <bpmn:outgoing>SequenceFlow_060j650</bpmn:outgoing>
+      <bpmn:outgoing>SequenceFlow_0sub2c2</bpmn:outgoing>
       <bpmn:linkEventDefinition id="LinkEventDefinition_197u5pe" name="WaitingForConfirmation" />
     </bpmn:intermediateCatchEvent>
     <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy">
@@ -355,7 +355,6 @@ css.prepareCreateOrchestrationTask(execution)</bpmn:script>
     </bpmn:intermediateCatchEvent>
     <bpmn:sequenceFlow id="SequenceFlow_14c2tav" sourceRef="IntermediateCatchEvent_0gceuxu" targetRef="ScriptTask_1ayg9y8" />
     <bpmn:sequenceFlow id="SequenceFlow_00kcej9" sourceRef="CallActivity_0n47zoh" targetRef="IntermediateThrowEvent_1v96asi" />
-    <bpmn:sequenceFlow id="SequenceFlow_060j650" sourceRef="IntermediateCatchEvent_0vilb24" targetRef="ScriptTask_04qudo2" />
     <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0lpvnze" name="Goto Create Slice Service">
       <bpmn:incoming>SequenceFlow_12wo878</bpmn:incoming>
       <bpmn:linkEventDefinition id="LinkEventDefinition_1oxsvp3" name="CreateSliceService" />
@@ -369,20 +368,12 @@ def css = new CreateSliceService()
 css.processNSTSolutions(execution)</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:sequenceFlow id="SequenceFlow_1f6dyxo" sourceRef="ScriptTask_13roglo" targetRef="CallActivity_0v4mw2x" />
-    <bpmn:receiveTask id="ReceiveTask_02qzb6i" name="Waiting for confirmation" />
     <bpmn:endEvent id="EndEvent_0bz8a65">
-      <bpmn:incoming>SequenceFlow_1vesvto</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_1fk2cn3</bpmn:incoming>
       <bpmn:errorEventDefinition id="ErrorEventDefinition_1hni1r1" errorRef="Error_0p2naox" />
     </bpmn:endEvent>
-    <bpmn:boundaryEvent id="BoundaryEvent_0p4swyp" attachedToRef="ReceiveTask_02qzb6i">
-      <bpmn:outgoing>SequenceFlow_1vesvto</bpmn:outgoing>
-      <bpmn:timerEventDefinition id="TimerEventDefinition_112p48l">
-        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT2H</bpmn:timeDuration>
-      </bpmn:timerEventDefinition>
-    </bpmn:boundaryEvent>
-    <bpmn:sequenceFlow id="SequenceFlow_1vesvto" sourceRef="BoundaryEvent_0p4swyp" targetRef="EndEvent_0bz8a65" />
     <bpmn:scriptTask id="ScriptTask_04qudo2" name="Prepare Get User Options" scriptFormat="groovy">
-      <bpmn:incoming>SequenceFlow_060j650</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_031cwkd</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0ti386y</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def css = new CreateSliceService()
@@ -427,10 +418,36 @@ def css = new CreateSliceService()
 css.prepareSelectNSTRequest(execution)</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:sequenceFlow id="SequenceFlow_02sve8o" sourceRef="ScriptTask_1ayg9y8" targetRef="CallActivity_0xf2g6c" />
+    <bpmn:subProcess id="SubProcess_1sxkpqq" name="Wait for Confim Message">
+      <bpmn:incoming>SequenceFlow_0sub2c2</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_031cwkd</bpmn:outgoing>
+      <bpmn:startEvent id="StartEvent_1hd68zf">
+        <bpmn:outgoing>SequenceFlow_0recnor</bpmn:outgoing>
+      </bpmn:startEvent>
+      <bpmn:endEvent id="EndEvent_05npq16">
+        <bpmn:incoming>SequenceFlow_1htsa6t</bpmn:incoming>
+      </bpmn:endEvent>
+      <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_1iti8re" name="Catch Confim Message">
+        <bpmn:incoming>SequenceFlow_0recnor</bpmn:incoming>
+        <bpmn:outgoing>SequenceFlow_1htsa6t</bpmn:outgoing>
+        <bpmn:messageEventDefinition id="MessageEventDefinition_1rxlviw" messageRef="Message_0c4b2r5" />
+      </bpmn:intermediateCatchEvent>
+      <bpmn:sequenceFlow id="SequenceFlow_1htsa6t" name="" sourceRef="IntermediateCatchEvent_1iti8re" targetRef="EndEvent_05npq16" />
+      <bpmn:sequenceFlow id="SequenceFlow_0recnor" name="" sourceRef="StartEvent_1hd68zf" targetRef="IntermediateCatchEvent_1iti8re" />
+    </bpmn:subProcess>
+    <bpmn:boundaryEvent id="BoundaryEvent_0xqq1ch" name="Timeout" attachedToRef="SubProcess_1sxkpqq">
+      <bpmn:outgoing>SequenceFlow_1fk2cn3</bpmn:outgoing>
+      <bpmn:timerEventDefinition id="TimerEventDefinition_0jxhpup">
+        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT2H</bpmn:timeDuration>
+      </bpmn:timerEventDefinition>
+    </bpmn:boundaryEvent>
+    <bpmn:sequenceFlow id="SequenceFlow_1fk2cn3" sourceRef="BoundaryEvent_0xqq1ch" targetRef="EndEvent_0bz8a65" />
+    <bpmn:sequenceFlow id="SequenceFlow_0sub2c2" sourceRef="IntermediateCatchEvent_0vilb24" targetRef="SubProcess_1sxkpqq" />
+    <bpmn:sequenceFlow id="SequenceFlow_031cwkd" sourceRef="SubProcess_1sxkpqq" targetRef="ScriptTask_04qudo2" />
   </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" />
+  <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateSliceService">
       <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj">
@@ -446,20 +463,20 @@ css.prepareSelectNSTRequest(execution)</bpmn:script>
         <di:waypoint x="274" y="965" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_10ng1vx_di" bpmnElement="SequenceFlow_10ng1vx">
-        <di:waypoint x="1294" y="805" />
+        <di:waypoint x="1320" y="805" />
         <di:waypoint x="1396" y="805" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_19lsayh_di" bpmnElement="SequenceFlow_19lsayh">
-        <di:waypoint x="1124" y="805" />
-        <di:waypoint x="1194" y="805" />
+        <di:waypoint x="1174" y="805" />
+        <di:waypoint x="1220" y="805" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0477975_di" bpmnElement="SequenceFlow_0477975">
-        <di:waypoint x="1294" y="620" />
+        <di:waypoint x="1320" y="620" />
         <di:waypoint x="1396" y="620" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0thd6ny_di" bpmnElement="SequenceFlow_0thd6ny">
-        <di:waypoint x="1124" y="620" />
-        <di:waypoint x="1194" y="620" />
+        <di:waypoint x="1160" y="620" />
+        <di:waypoint x="1220" y="620" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1">
         <di:waypoint x="1174" y="965" />
@@ -504,23 +521,23 @@ css.prepareSelectNSTRequest(execution)</bpmn:script>
         <di:waypoint x="1220" y="350" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_038lb9m_di" bpmnElement="SequenceFlow_038lb9m">
-        <di:waypoint x="884" y="645" />
-        <di:waypoint x="884" y="805" />
-        <di:waypoint x="1024" y="805" />
+        <di:waypoint x="984" y="645" />
+        <di:waypoint x="984" y="805" />
+        <di:waypoint x="1074" y="805" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="886" y="722" width="27" height="14" />
+          <dc:Bounds x="986" y="722" width="27" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_12t5exy_di" bpmnElement="SequenceFlow_12t5exy">
-        <di:waypoint x="909" y="620" />
-        <di:waypoint x="1024" y="620" />
+        <di:waypoint x="1009" y="620" />
+        <di:waypoint x="1060" y="620" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="911" y="602" width="42" height="14" />
+          <dc:Bounds x="998" y="602" width="42" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_197cm2e_di" bpmnElement="SequenceFlow_197cm2e">
-        <di:waypoint x="804" y="620" />
-        <di:waypoint x="859" y="620" />
+        <di:waypoint x="930" y="620" />
+        <di:waypoint x="959" y="620" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt">
         <di:waypoint x="350" y="122" />
@@ -543,12 +560,12 @@ css.prepareSelectNSTRequest(execution)</bpmn:script>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1jgtb0y_di" bpmnElement="ScriptTask_1jgtb0y">
-        <dc:Bounds x="704" y="580" width="100" height="80" />
+        <dc:Bounds x="830" y="580" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ExclusiveGateway_0elbczl_di" bpmnElement="ExclusiveGateway_0elbczl" isMarkerVisible="true">
-        <dc:Bounds x="859" y="595" width="50" height="50" />
+        <dc:Bounds x="959" y="595" width="50" height="50" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="846" y="577" width="78" height="14" />
+          <dc:Bounds x="946" y="577" width="78" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="CallActivity_139l55g_di" bpmnElement="CallActivity_139l55g">
@@ -620,16 +637,16 @@ css.prepareSelectNSTRequest(execution)</bpmn:script>
         <dc:Bounds x="1220" y="310" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_12h8542_di" bpmnElement="ScriptTask_12h8542">
-        <dc:Bounds x="1024" y="580" width="100" height="80" />
+        <dc:Bounds x="1060" y="580" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="CallActivity_0o89wmf_di" bpmnElement="CallActivity_0o89wmf">
-        <dc:Bounds x="1194" y="580" width="100" height="80" />
+        <dc:Bounds x="1220" y="580" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="CallActivity_0jdzpem_di" bpmnElement="CallActivity_0jdzpem">
-        <dc:Bounds x="1194" y="765" width="100" height="80" />
+        <dc:Bounds x="1220" y="765" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1mscu5w_di" bpmnElement="ScriptTask_1mscu5w">
-        <dc:Bounds x="1024" y="765" width="100" height="80" />
+        <dc:Bounds x="1074" y="765" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="IntermediateCatchEvent_0pkvfun_di" bpmnElement="IntermediateCatchEvent_0pkvfun">
         <dc:Bounds x="177" y="947" width="36" height="36" />
@@ -700,10 +717,6 @@ css.prepareSelectNSTRequest(execution)</bpmn:script>
         <di:waypoint x="1320" y="350" />
         <di:waypoint x="1402" y="350" />
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="SequenceFlow_060j650_di" bpmnElement="SequenceFlow_060j650">
-        <di:waypoint x="213" y="620" />
-        <di:waypoint x="394" y="620" />
-      </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="IntermediateThrowEvent_0lpvnze_di" bpmnElement="IntermediateThrowEvent_0lpvnze">
         <dc:Bounds x="1402" y="106" width="36" height="36" />
         <bpmndi:BPMNLabel>
@@ -721,32 +734,22 @@ css.prepareSelectNSTRequest(execution)</bpmn:script>
         <di:waypoint x="810" y="350" />
         <di:waypoint x="880" y="350" />
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNShape id="ReceiveTask_02qzb6i_di" bpmnElement="ReceiveTask_02qzb6i">
-        <dc:Bounds x="254" y="580" width="100" height="80" />
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="EndEvent_0bz8a65_di" bpmnElement="EndEvent_0bz8a65">
-        <dc:Bounds x="286" y="757" width="36" height="36" />
+        <dc:Bounds x="354" y="772" width="36" height="36" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="BoundaryEvent_0p4swyp_di" bpmnElement="BoundaryEvent_0p4swyp">
-        <dc:Bounds x="286" y="642" width="36" height="36" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNEdge id="SequenceFlow_1vesvto_di" bpmnElement="SequenceFlow_1vesvto">
-        <di:waypoint x="304" y="678" />
-        <di:waypoint x="304" y="757" />
-      </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ScriptTask_04qudo2_di" bpmnElement="ScriptTask_04qudo2">
-        <dc:Bounds x="394" y="580" width="100" height="80" />
+        <dc:Bounds x="550" y="580" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0ti386y_di" bpmnElement="SequenceFlow_0ti386y">
-        <di:waypoint x="494" y="620" />
-        <di:waypoint x="534" y="620" />
+        <di:waypoint x="650" y="620" />
+        <di:waypoint x="688" y="620" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="CallActivity_1vu3zcv_di" bpmnElement="CallActivity_1vu3zcv">
-        <dc:Bounds x="534" y="580" width="100" height="80" />
+        <dc:Bounds x="688" y="580" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1whq7vc_di" bpmnElement="SequenceFlow_1whq7vc">
-        <di:waypoint x="634" y="620" />
-        <di:waypoint x="704" y="620" />
+        <di:waypoint x="788" y="620" />
+        <di:waypoint x="830" y="620" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="CallActivity_0xf2g6c_di" bpmnElement="CallActivity_0xf2g6c">
         <dc:Bounds x="520" y="310" width="100" height="80" />
@@ -762,6 +765,47 @@ css.prepareSelectNSTRequest(execution)</bpmn:script>
         <di:waypoint x="410" y="350" />
         <di:waypoint x="520" y="350" />
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="SubProcess_1sxkpqq_di" bpmnElement="SubProcess_1sxkpqq" isExpanded="true">
+        <dc:Bounds x="240" y="540" width="280" height="160" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="BoundaryEvent_0xqq1ch_di" bpmnElement="BoundaryEvent_0xqq1ch">
+        <dc:Bounds x="354" y="682" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="395" y="712" width="40" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="StartEvent_1hd68zf_di" bpmnElement="StartEvent_1hd68zf">
+        <dc:Bounds x="272" y="602" width="36" height="36" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="EndEvent_05npq16_di" bpmnElement="EndEvent_05npq16">
+        <dc:Bounds x="460" y="602" width="36" height="36" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="IntermediateCatchEvent_1iti8re_di" bpmnElement="IntermediateCatchEvent_1iti8re">
+        <dc:Bounds x="367" y="602" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="353" y="644" width="67" height="27" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1htsa6t_di" bpmnElement="SequenceFlow_1htsa6t">
+        <di:waypoint x="403" y="620" />
+        <di:waypoint x="460" y="620" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_0recnor_di" bpmnElement="SequenceFlow_0recnor">
+        <di:waypoint x="308" y="620" />
+        <di:waypoint x="367" y="620" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1fk2cn3_di" bpmnElement="SequenceFlow_1fk2cn3">
+        <di:waypoint x="372" y="718" />
+        <di:waypoint x="372" y="772" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_0sub2c2_di" bpmnElement="SequenceFlow_0sub2c2">
+        <di:waypoint x="213" y="620" />
+        <di:waypoint x="240" y="620" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_031cwkd_di" bpmnElement="SequenceFlow_031cwkd">
+        <di:waypoint x="520" y="620" />
+        <di:waypoint x="550" y="620" />
+      </bpmndi:BPMNEdge>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn:definitions>
index 3bd155d..d68a374 100644 (file)
 package org.onap.so.beans.nsmf;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
 import java.util.List;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
 public class CnSliceProfile {
 
+    @JsonProperty(value = "sNSSAIList", required = true)
     private List<String> snssaiList;
 
     private String sliceProfileId;
 
+    @JsonProperty(value = "pLMNIdList", required = true)
     private List<String> plmnIdList;
 
+    @JsonProperty(value = "perfReq", required = true)
     private PerfReq perfReq;
 
-    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
+    @JsonProperty(value = "maxNumberofUEs")
     private int maxNumberofUEs;
 
+    @JsonProperty(value = "coverageAreaTAList")
     private List<String> coverageAreaTAList;
 
-    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
+    @JsonProperty(value = "latency")
     private int latency;
 
+    @JsonProperty(value = "uEMobilityLevel")
     private UeMobilityLevel ueMobilityLevel;
 
+    @JsonProperty(value = "resourceSharingLevel")
     private ResourceSharingLevel resourceSharingLevel;
-
-    public String getSliceProfileId() {
-        return sliceProfileId;
-    }
-
-    public void setSliceProfileId(String sliceProfileId) {
-        this.sliceProfileId = sliceProfileId;
-    }
-
-    public List<String> getPlmnIdList() {
-        return plmnIdList;
-    }
-
-    public void setPlmnIdList(List<String> plmnIdList) {
-        this.plmnIdList = plmnIdList;
-    }
-
-    public PerfReq getPerfReq() {
-        return perfReq;
-    }
-
-    public void setPerfReq(PerfReq perfReq) {
-        this.perfReq = perfReq;
-    }
-
-    public int getMaxNumberofUEs() {
-        return maxNumberofUEs;
-    }
-
-    public void setMaxNumberofUEs(int maxNumberofUEs) {
-        this.maxNumberofUEs = maxNumberofUEs;
-    }
-
-    public List<String> getCoverageAreaTAList() {
-        return coverageAreaTAList;
-    }
-
-    public void setCoverageAreaTAList(List<String> coverageAreaTAList) {
-        this.coverageAreaTAList = coverageAreaTAList;
-    }
-
-    public int getLatency() {
-        return latency;
-    }
-
-    public void setLatency(int latency) {
-        this.latency = latency;
-    }
-
-    public UeMobilityLevel getUeMobilityLevel() {
-        return ueMobilityLevel;
-    }
-
-    public void setUeMobilityLevel(UeMobilityLevel ueMobilityLevel) {
-        this.ueMobilityLevel = ueMobilityLevel;
-    }
-
-    public ResourceSharingLevel getResourceSharingLevel() {
-        return resourceSharingLevel;
-    }
-
-    public void setResourceSharingLevel(ResourceSharingLevel resourceSharingLevel) {
-        this.resourceSharingLevel = resourceSharingLevel;
-    }
-
-    public List<String> getSnssaiList() {
-        return snssaiList;
-    }
-
-    public void setSnssaiList(List<String> snssaiList) {
-        this.snssaiList = snssaiList;
-    }
 }
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java
new file mode 100644 (file)
index 0000000..c64af1d
--- /dev/null
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.beans.nsmf;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.ToString;
+import org.springframework.beans.BeanUtils;
+import java.io.Serializable;
+import java.util.Arrays;
+
+@Data
+@ToString
+public class SliceProfileAdapter implements Serializable {
+
+    private static final long serialVersionUID = -6412175980642584804L;
+
+    @JsonProperty(value = "sliceProfileId")
+    private String sliceProfileId;
+
+    @JsonProperty(value = "sNSSAI")
+    private String sNSSAIList = "";
+
+    @JsonProperty(value = "pLMNIdList")
+    private String pLMNIdList = "";
+
+    @JsonProperty(value = "maxNumberofUEs")
+    private long maxNumberofUEs;
+
+    @JsonProperty(value = "coverageAreaTAList")
+    private String coverageAreaTAList = "";
+
+    @JsonProperty(value = "latency")
+    private int latency;
+
+    @JsonProperty(value = "uEMobilityLevel")
+    private String uEMobilityLevel;
+
+    @JsonProperty(value = "resourceSharingLevel")
+    private String resourceSharingLevel;
+
+    @JsonProperty(value = "maxBandwidth")
+    private String bandwidth;
+
+    @JsonProperty(value = "sST")
+    private String sST;
+
+    @JsonProperty(value = "activityFactor")
+    private String activityFactor;
+
+    @JsonProperty(value = "survivalTime")
+    private String survivalTime;
+
+    public AnSliceProfile trans2AnProfile() {
+        AnSliceProfile anSliceProfile = new AnSliceProfile();
+        BeanUtils.copyProperties(this, anSliceProfile);
+        anSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
+        anSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
+
+        String[] areas = this.coverageAreaTAList.split("\\|");
+        Integer[] areasRes = new Integer[areas.length];
+        for (int i = 0; i < areas.length; i++) {
+            areasRes[i] = str2Code(areas[i]);
+        }
+        anSliceProfile.setCoverageAreaTAList(Arrays.asList(areasRes));
+        anSliceProfile.setUEMobilityLevel(UeMobilityLevel.fromString(this.uEMobilityLevel));
+        anSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
+        AnPerfReq anPerfReq = new AnPerfReq();
+        // todo
+        anSliceProfile.setPerfReq(anPerfReq);
+        return anSliceProfile;
+    }
+
+    private Integer str2Code(String area) {
+        return area.hashCode() >> 16;
+    }
+
+    public CnSliceProfile trans2CnProfile() {
+        CnSliceProfile cnSliceProfile = new CnSliceProfile();
+        BeanUtils.copyProperties(this, cnSliceProfile);
+        cnSliceProfile.setSnssaiList(Arrays.asList(this.sNSSAIList.split("\\|")));
+        cnSliceProfile.setCoverageAreaTAList(Arrays.asList(this.coverageAreaTAList.split("\\|")));
+        cnSliceProfile.setPlmnIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
+        cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
+        PerfReq perfReq = new PerfReq();
+        // todo
+        cnSliceProfile.setPerfReq(perfReq);
+        return cnSliceProfile;
+    }
+
+    public TnSliceProfile trans2TnProfile() {
+        TnSliceProfile tnSliceProfile = new TnSliceProfile();
+        BeanUtils.copyProperties(this, tnSliceProfile);
+        tnSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
+        tnSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
+        return tnSliceProfile;
+    }
+}
index e97aa70..bfd4627 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.onap.so.beans.nsmf;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.JsonObject;
 import lombok.*;
@@ -56,15 +57,15 @@ public class SliceTaskParamsAdapter implements Serializable {
 
     private TemplateInfo NSTInfo = new TemplateInfo();
 
-    private SliceTaskInfo<TnSliceProfile> tnBHSliceTaskInfo = new SliceTaskInfo<>();
+    private SliceTaskInfo<SliceProfileAdapter> tnBHSliceTaskInfo = new SliceTaskInfo<>();
 
-    private SliceTaskInfo<TnSliceProfile> tnMHSliceTaskInfo = new SliceTaskInfo<>();
+    private SliceTaskInfo<SliceProfileAdapter> tnMHSliceTaskInfo = new SliceTaskInfo<>();
 
-    private SliceTaskInfo<TnSliceProfile> tnFHSliceTaskInfo = new SliceTaskInfo<>();
+    private SliceTaskInfo<SliceProfileAdapter> tnFHSliceTaskInfo = new SliceTaskInfo<>();
 
-    private SliceTaskInfo<CnSliceProfile> cnSliceTaskInfo = new SliceTaskInfo<>();
+    private SliceTaskInfo<SliceProfileAdapter> cnSliceTaskInfo = new SliceTaskInfo<>();
 
-    private SliceTaskInfo<AnSliceProfile> anSliceTaskInfo = new SliceTaskInfo<>();
+    private SliceTaskInfo<SliceProfileAdapter> anSliceTaskInfo = new SliceTaskInfo<>();
 
     @SuppressWarnings("unchecked")
     public void convertFromJson(String jsonString) throws IOException {
@@ -80,24 +81,24 @@ public class SliceTaskParamsAdapter implements Serializable {
 
         this.setServiceProfile(replaceHeader(paramMap, "ServiceProfile."));
 
-        TnSliceProfile tnBHSliceProfile = mapper.readValue(
-                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.BH.")), TnSliceProfile.class);
+        SliceProfileAdapter tnBHSliceProfile = mapper.readValue(
+                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.BH.")), SliceProfileAdapter.class);
         this.tnBHSliceTaskInfo.setSliceProfile(tnBHSliceProfile);
 
-        TnSliceProfile tnMHSliceProfile = mapper.readValue(
-                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.MH.")), TnSliceProfile.class);
+        SliceProfileAdapter tnMHSliceProfile = mapper.readValue(
+                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.MH.")), SliceProfileAdapter.class);
         this.tnMHSliceTaskInfo.setSliceProfile(tnMHSliceProfile);
 
-        TnSliceProfile tnFHSliceProfile = mapper.readValue(
-                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.FH.")), TnSliceProfile.class);
+        SliceProfileAdapter tnFHSliceProfile = mapper.readValue(
+                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.FH.")), SliceProfileAdapter.class);
         this.tnFHSliceTaskInfo.setSliceProfile(tnFHSliceProfile);
 
-        CnSliceProfile cnSliceProfile = mapper.readValue(
-                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.CN.")), CnSliceProfile.class);
+        SliceProfileAdapter cnSliceProfile = mapper.readValue(
+                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.CN.")), SliceProfileAdapter.class);
         this.cnSliceTaskInfo.setSliceProfile(cnSliceProfile);
 
-        AnSliceProfile anSliceProfile = mapper.readValue(
-                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.AN.")), AnSliceProfile.class);
+        SliceProfileAdapter anSliceProfile = mapper.readValue(
+                mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.AN.")), SliceProfileAdapter.class);
         this.anSliceTaskInfo.setSliceProfile(anSliceProfile);
 
         this.tnBHSliceTaskInfo.setSuggestNssiId(paramMap.get("TN.BH.SuggestNSSIId"));
@@ -148,33 +149,31 @@ public class SliceTaskParamsAdapter implements Serializable {
         for (Map.Entry<String, Object> entry : serviceProfile.entrySet()) {
             jsonObject.addProperty("ServiceProfile." + entry.getKey(), entry.getValue().toString());
         }
-
         Map<String, Object> sliceProfileAn = bean2Map(anSliceTaskInfo.getSliceProfile());
-
         for (Map.Entry<String, Object> entry : sliceProfileAn.entrySet()) {
-            jsonObject.addProperty("SliceProfile.AN." + entry.getKey(), entry.getValue().toString());
+            String value = entry.getValue() == null ? "" : entry.getValue().toString();
+            jsonObject.addProperty("SliceProfile.AN." + entry.getKey(), value);
         }
-
         Map<String, Object> sliceProfileCn = bean2Map(cnSliceTaskInfo.getSliceProfile());
         for (Map.Entry<String, Object> entry : sliceProfileCn.entrySet()) {
-            jsonObject.addProperty("SliceProfile.CN." + entry.getKey(), entry.getValue().toString());
+            String value = entry.getValue() == null ? "" : entry.getValue().toString();
+            jsonObject.addProperty("SliceProfile.CN." + entry.getKey(), value);
         }
-
         Map<String, Object> sliceProfileTnBH = bean2Map(tnBHSliceTaskInfo.getSliceProfile());
         for (Map.Entry<String, Object> entry : sliceProfileTnBH.entrySet()) {
-            jsonObject.addProperty("SliceProfile.TN.BH." + entry.getKey(), entry.getValue().toString());
+            String value = entry.getValue() == null ? "" : entry.getValue().toString();
+            jsonObject.addProperty("SliceProfile.TN.BH." + entry.getKey(), value);
         }
-
         Map<String, Object> sliceProfileTnMH = bean2Map(tnMHSliceTaskInfo.getSliceProfile());
         for (Map.Entry<String, Object> entry : sliceProfileTnMH.entrySet()) {
-            jsonObject.addProperty("SliceProfile.TN.MH." + entry.getKey(), entry.getValue().toString());
+            String value = entry.getValue() == null ? "" : entry.getValue().toString();
+            jsonObject.addProperty("SliceProfile.TN.MH." + entry.getKey(), value);
         }
-
         Map<String, Object> sliceProfileTnFH = bean2Map(tnFHSliceTaskInfo.getSliceProfile());
         for (Map.Entry<String, Object> entry : sliceProfileTnFH.entrySet()) {
-            jsonObject.addProperty("SliceProfile.TN.FH." + entry.getKey(), entry.getValue().toString());
+            String value = entry.getValue() == null ? "" : entry.getValue().toString();
+            jsonObject.addProperty("SliceProfile.TN.FH." + entry.getKey(), value);
         }
-
         jsonObject.addProperty("TN.BH.SuggestNSSIId", tnBHSliceTaskInfo.getSuggestNssiId());
         jsonObject.addProperty("TN.BH.SuggestNSSIName", tnBHSliceTaskInfo.getSuggestNssiName());
         jsonObject.addProperty("TN.BH.progress", tnBHSliceTaskInfo.getProgress());
@@ -182,7 +181,6 @@ public class SliceTaskParamsAdapter implements Serializable {
         jsonObject.addProperty("TN.BH.statusDescription", tnBHSliceTaskInfo.getStatusDescription());
         jsonObject.addProperty("TN.BH.ScriptName", tnBHSliceTaskInfo.getScriptName());
 
-
         jsonObject.addProperty("TN.MH.SuggestNSSIId", tnMHSliceTaskInfo.getSuggestNssiId());
         jsonObject.addProperty("TN.MH.SuggestNSSIName", tnMHSliceTaskInfo.getSuggestNssiName());
         jsonObject.addProperty("TN.MH.progress", tnMHSliceTaskInfo.getProgress());
@@ -190,7 +188,6 @@ public class SliceTaskParamsAdapter implements Serializable {
         jsonObject.addProperty("TN.MH.statusDescription", tnMHSliceTaskInfo.getStatusDescription());
         jsonObject.addProperty("TN.MH.ScriptName", tnMHSliceTaskInfo.getScriptName());
 
-
         jsonObject.addProperty("TN.FH.SuggestNSSIId", tnFHSliceTaskInfo.getSuggestNssiId());
         jsonObject.addProperty("TN.FH.SuggestNSSIName", tnFHSliceTaskInfo.getSuggestNssiName());
         jsonObject.addProperty("TN.FH.progress", tnFHSliceTaskInfo.getProgress());
@@ -198,7 +195,6 @@ public class SliceTaskParamsAdapter implements Serializable {
         jsonObject.addProperty("TN.FH.statusDescription", tnFHSliceTaskInfo.getStatusDescription());
         jsonObject.addProperty("TN.FH.ScriptName", tnFHSliceTaskInfo.getScriptName());
 
-
         jsonObject.addProperty("CN.SuggestNSSIId", cnSliceTaskInfo.getSuggestNssiId());
         jsonObject.addProperty("CN.SuggestNSSIName", cnSliceTaskInfo.getSuggestNssiName());
         jsonObject.addProperty("CN.progress", cnSliceTaskInfo.getProgress());
@@ -206,7 +202,6 @@ public class SliceTaskParamsAdapter implements Serializable {
         jsonObject.addProperty("CN.statusDescription", cnSliceTaskInfo.getStatusDescription());
         jsonObject.addProperty("CN.ScriptName", cnSliceTaskInfo.getScriptName());
 
-
         jsonObject.addProperty("AN.SuggestNSSIId", anSliceTaskInfo.getSuggestNssiId());
         jsonObject.addProperty("AN.SuggestNSSIName", anSliceTaskInfo.getSuggestNssiName());
         jsonObject.addProperty("AN.progress", anSliceTaskInfo.getProgress());
@@ -219,7 +214,7 @@ public class SliceTaskParamsAdapter implements Serializable {
 
     /**
      * change T t to {@link Map}
-     * 
+     *
      * @param t input
      * @param <T> Object
      * @return {@link Map}
@@ -234,9 +229,18 @@ public class SliceTaskParamsAdapter implements Serializable {
             Field[] fields = t.getClass().getDeclaredFields();
             for (Field field : fields) {
                 String name = field.getName();
-                Method method = t.getClass().getMethod("get" + name);
+                String key = name;
+                if (name == null || "".equals(name) || "serialVersionUID".equalsIgnoreCase(name)) {
+                    continue;
+                }
+                JsonProperty annotation = field.getAnnotation(JsonProperty.class);
+                if (annotation != null && !annotation.value().equals(JsonProperty.USE_DEFAULT_NAME)) {
+                    key = annotation.value();
+                }
+
+                Method method = t.getClass().getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1));
                 Object value = method.invoke(t);
-                resMap.put(name, value);
+                resMap.put(key, value);
             }
 
         } catch (Exception e) {
@@ -247,7 +251,7 @@ public class SliceTaskParamsAdapter implements Serializable {
 
     /**
      * replace of slice profile
-     * 
+     *
      * @param paramMap params map
      * @param header starts of key
      * @return Map
index ccd6001..1effb4e 100644 (file)
@@ -21,7 +21,9 @@
 package org.onap.so.beans.nsmf;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
+import java.util.List;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Data
@@ -29,8 +31,15 @@ public class TnSliceProfile {
 
     private String sliceProfileId;
 
+    @JsonProperty(value = "maxBandwidth")
     private String bandwidth;
 
     @JsonInclude(JsonInclude.Include.NON_DEFAULT)
     private int latency;
+
+    @JsonProperty(value = "sNSSAIList", required = true)
+    private List<String> sNSSAIList;
+
+    @JsonProperty(value = "pLMNIdList", required = true)
+    private List<String> pLMNIdList;
 }