Store step inputs to blueprint runtime service.
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 6 Dec 2018 18:25:36 +0000 (13:25 -0500)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 6 Dec 2018 18:25:36 +0000 (13:25 -0500)
Change-Id: Ib01edfc358625d25ac0625f88739c7c57f7f967c
Issue-ID: CCSDK-670
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt

index 90a5ea0..05f6a2d 100644 (file)
@@ -24,6 +24,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
 import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.springframework.beans.factory.annotation.Autowired
@@ -62,15 +63,15 @@ class ComponentNetconfExecutorTest {
         componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
 
 
-        val metaData: MutableMap<String, JsonNode> = hashMapOf()
-        metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "activate-jython")
-
         val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
-        metaData.putJsonElement("activate-jython-step-inputs", stepMetaData)
-        executionServiceInput.metadata = metaData
+        // Set Step Inputs in Blueprint Runtime Service
+        bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())
+
+        componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+        componentNetconfExecutor.stepName = "activate-jython"
 
         componentNetconfExecutor.apply(executionServiceInput)
 
index 7087974..07591a5 100644 (file)
@@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
 import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.springframework.beans.factory.annotation.Autowired
@@ -58,18 +59,14 @@ class ComponentJythonExecutorTest {
         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
                 "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
 
-        componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
-
-
-        val metaData: MutableMap<String, JsonNode> = hashMapOf()
-        metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "activate-jython")
-
         val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
-        metaData.putJsonElement("activate-jython-step-inputs", stepMetaData)
-        executionServiceInput.metadata = metaData
+        bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())
+
+        componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+        componentJythonExecutor.stepName = "activate-jython"
 
         componentJythonExecutor.apply(executionServiceInput)
 
index 427063e..3cad627 100644 (file)
@@ -18,7 +18,6 @@
 package org.onap.ccsdk.apps.blueprintsprocessor.core.api.data\r
 \r
 import com.fasterxml.jackson.annotation.JsonFormat\r
-import com.fasterxml.jackson.databind.JsonNode\r
 import com.fasterxml.jackson.databind.node.ObjectNode\r
 import io.swagger.annotations.ApiModelProperty\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
@@ -59,7 +58,6 @@ open class ExecutionServiceInput {
     lateinit var actionIdentifiers: ActionIdentifiers\r
     @get:ApiModelProperty(required = true)\r
     lateinit var payload: ObjectNode\r
-    var metadata: MutableMap<String, JsonNode> = hashMapOf()\r
 }\r
 \r
 open class ExecutionServiceOutput {\r
@@ -71,7 +69,6 @@ open class ExecutionServiceOutput {
     var status: Status = Status()\r
     @get:ApiModelProperty(required = true)\r
     lateinit var payload: ObjectNode\r
-    var metadata: MutableMap<String, JsonNode> = hashMapOf()\r
 }\r
 \r
 open class ActionIdentifiers {\r
index a6eb7a8..47ace85 100644 (file)
         "hostname": "localhost"
       }
     }
-  },
-  "metadata": {
-    "current-node-template": "resource-assignment-py",
-    "current-step": "resource-assignment-py",
-    "current-operation": "process",
-    "current-interface": "ResourceAssignmentComponent"
   }
 }
\ No newline at end of file
index 37f1492..c6ce465 100644 (file)
@@ -24,9 +24,9 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode\r
 import org.onap.ccsdk.apps.controllerblueprints.core.getAsString\r
 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode\r
-import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement\r
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
 import org.slf4j.LoggerFactory\r
 \r
@@ -49,36 +49,46 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
     var nodeTemplateName: String = ""\r
     var operationInputs: MutableMap<String, JsonNode> = hashMapOf()\r
 \r
+    override fun getName(): String {\r
+        return stepName\r
+    }\r
 \r
     override fun prepareRequest(executionServiceInput: ExecutionServiceInput): ExecutionServiceInput {\r
         checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }\r
 \r
+        check(stepName.isNotEmpty()) { "failed to assign step name" }\r
+\r
         this.executionServiceInput = executionServiceInput\r
 \r
         processId = executionServiceInput.commonHeader.requestId\r
+        check(processId.isNotEmpty()) { "couldn't get process id for step($stepName)" }\r
+\r
         workflowName = executionServiceInput.actionIdentifiers.actionName\r
+        check(workflowName.isNotEmpty()) { "couldn't get action name for step($stepName)" }\r
 \r
-        val metadata = executionServiceInput.metadata\r
-        stepName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_STEP)\r
         log.info("preparing request id($processId) for workflow($workflowName) step($stepName)")\r
 \r
-        val operationInputs = metadata.get("$stepName-step-inputs") ?: JsonNodeFactory.instance.objectNode()\r
+        val operationInputs = bluePrintRuntimeService!!.get("$stepName-step-inputs")\r
+                ?: JsonNodeFactory.instance.objectNode()\r
 \r
         operationInputs.fields().forEach {\r
             this.operationInputs[it.key] = it.value\r
         }\r
 \r
         nodeTemplateName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)\r
+        check(nodeTemplateName.isNotEmpty()) { "couldn't get NodeTemplate name for step($stepName)" }\r
+\r
         interfaceName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)\r
+        check(interfaceName.isNotEmpty()) { "couldn't get Interface name for step($stepName)" }\r
+\r
         operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)\r
+        check(operationName.isNotEmpty()) { "couldn't get Operation name for step($stepName)" }\r
 \r
 \r
         val operationResolvedProperties = bluePrintRuntimeService!!.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)\r
 \r
         this.operationInputs.putAll(operationResolvedProperties)\r
 \r
-\r
-\r
         return executionServiceInput\r
     }\r
 \r
@@ -87,12 +97,10 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
         executionServiceOutput.commonHeader = executionServiceInput!!.commonHeader\r
 \r
         // Resolve the Output Expression\r
-        val operationResolvedProperties = bluePrintRuntimeService!!\r
+        val stepOutputs = bluePrintRuntimeService!!\r
                 .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)\r
 \r
-        val metadata = executionServiceOutput.metadata\r
-        metadata.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, stepName)\r
-        metadata.putJsonElement("$stepName-step-outputs", operationResolvedProperties)\r
+        bluePrintRuntimeService!!.put("$stepName-step-outputs", stepOutputs.asJsonNode())\r
 \r
         // Populate Status\r
         val status = Status()\r
@@ -110,6 +118,6 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
     }\r
 \r
     fun getOperationInput(key: String): JsonNode {\r
-        return operationInputs.get(key) ?: NullNode.instance\r
+        return operationInputs[key] ?: NullNode.instance\r
     }\r
 }
\ No newline at end of file
index 87c0c53..e514a1f 100644 (file)
@@ -21,6 +21,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp
 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintSvcLogicContext
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
 import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext
 import org.onap.ccsdk.sli.core.sli.SvcLogicException
@@ -69,18 +70,18 @@ open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() {
             val plugin = this.getComponentFunction(componentName)
             // Set the Blueprint Service
             plugin.bluePrintRuntimeService = ctx.getBluePrintService()
+            plugin.stepName = nodeTemplateName
 
             val executionInput = ctx.getRequest() as ExecutionServiceInput
 
-            val metaData = executionInput.metadata
-            metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, nodeTemplateName)
             // Populate Step Meta Data
-            val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
-            stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
-            stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
-            stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
+            val stepInputs: MutableMap<String, JsonNode> = hashMapOf()
+            stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
+            stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
+            stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
+
+            plugin.bluePrintRuntimeService!!.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
 
-            metaData.putJsonElement("$nodeTemplateName-step-inputs", stepMetaData)
             // Get the Request from the Context and Set to the Function Input and Invoke the function
             val executionOutput = plugin.apply(executionInput)