Workflow-spec returning error response 60/106060/2
authorjananib <janani.b@huawei.com>
Wed, 15 Apr 2020 22:22:31 +0000 (03:52 +0530)
committerjananib <janani.b@huawei.com>
Wed, 15 Apr 2020 23:00:30 +0000 (04:30 +0530)
Fix workflow-spec query

Change-Id: Ic66e2249b73c113cd25bd99c9cf33984520e31df
Issue-ID: CCSDK-2181
Signed-off-by: jananib <janani.b@huawei.com>
ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt

index f55fee0..48ca912 100644 (file)
@@ -42,6 +42,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
 import org.onap.ccsdk.cds.controllerblueprints.core.deleteNBDir
 import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
 import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService
 import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache
@@ -121,17 +122,29 @@ open class BluePrintModelHandler(
         workFlowData.inputs = workFlow.inputs
         workFlowData.outputs = workFlow.outputs
 
-        for ((k, v) in workFlow.inputs!!) {
-            addDataType(v.type, blueprintContext, wfRes)
+        if (workFlow.inputs != null) {
+            for ((k, v) in workFlow.inputs!!) {
+                addPropertyInfo(v, blueprintContext, wfRes)
+            }
         }
 
-        for ((k, v) in workFlow.outputs!!) {
-            addDataType(v.type, blueprintContext, wfRes)
+        if (workFlow.outputs != null) {
+            for ((k, v) in workFlow.outputs!!) {
+                addPropertyInfo(v, blueprintContext, wfRes)
+            }
         }
+
         wfRes.workFlowData = workFlowData
         return wfRes
     }
 
+    private fun addPropertyInfo(prop: PropertyDefinition, ctx: BluePrintContext, res: WorkFlowSpecResponse) {
+        addDataType(prop.type, ctx, res)
+        if (prop.entrySchema != null && prop.entrySchema!!.type != null) {
+            addDataType(prop.entrySchema!!.type, ctx, res)
+        }
+    }
+
     private fun addDataType(name: String, ctx: BluePrintContext, res: WorkFlowSpecResponse) {
         var data = ctx.dataTypeByName(name)
         if (data != null) {
@@ -141,8 +154,10 @@ open class BluePrintModelHandler(
     }
 
     private fun addParentDataType(data: DataType, ctx: BluePrintContext, res: WorkFlowSpecResponse) {
-        for ((k, v) in data.properties!!) {
-            addDataType(v.type, ctx, res)
+        if (data.properties != null) {
+            for ((k, v) in data.properties!!) {
+                addPropertyInfo(v, ctx, res)
+            }
         }
     }