Merge "Improve Rest Service API"
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / services / workflow-service / src / main / kotlin / org / onap / cds / blueprintsprocessor / services / workflow / BluePrintWorkflowExecutionServiceImpl.kt
index fbd9f4c..b186174 100644 (file)
@@ -20,8 +20,10 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asObjectNode
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.slf4j.LoggerFactory
 import org.springframework.stereotype.Service
 
@@ -41,6 +43,10 @@ open class BluePrintWorkflowExecutionServiceImpl(
 
         val workflowName = executionServiceInput.actionIdentifiers.actionName
 
+        // Assign Workflow inputs
+        val input = executionServiceInput.payload.get("$workflowName-request")
+        bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+
         // Get the DG Node Template
         val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
 
@@ -53,7 +59,7 @@ open class BluePrintWorkflowExecutionServiceImpl(
                 componentWorkflowExecutionService
                         .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
             }
-            derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_DG, true) -> {
+            derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW, true) -> {
                 dgWorkflowExecutionService
                         .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
             }
@@ -65,7 +71,12 @@ open class BluePrintWorkflowExecutionServiceImpl(
 
         executionServiceOutput.commonHeader = executionServiceInput.commonHeader
         executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
-        // TODO("Populate Response Payload and status")
+        // Resolve Workflow Outputs
+        val workflowOutputs = bluePrintRuntimeService.resolveWorkflowOutputs(workflowName)
+
+        // Set the Response Payload
+        executionServiceOutput.payload = JacksonUtils.objectMapper.createObjectNode()
+        executionServiceOutput.payload.set("$workflowName-response", workflowOutputs.asObjectNode())
         return executionServiceOutput
     }