From 04425ebaae2abc1862160acc7674205377078b4f Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 4 Dec 2018 10:25:44 -0500 Subject: Add Blueprint Runtime Input/Output logic Change-Id: I0355e78862096b7b4074faa882d66ce27d6e1844 Issue-ID: CCSDK-670 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../execution/AbstractComponentFunction.kt | 52 +++++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) (limited to 'ms/blueprintsprocessor/modules/services/execution-service/src') diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt index dfdf6259..37f14925 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt @@ -17,11 +17,16 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.execution +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.JsonNodeFactory +import com.fasterxml.jackson.databind.node.NullNode import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.getAsString import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode +import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService import org.slf4j.LoggerFactory @@ -30,6 +35,7 @@ import org.slf4j.LoggerFactory * @author Brinda Santh */ abstract class AbstractComponentFunction : BlueprintFunctionNode { + @Transient private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java) var executionServiceInput: ExecutionServiceInput? = null @@ -41,29 +47,59 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode = hashMapOf() override fun prepareRequest(executionServiceInput: ExecutionServiceInput): ExecutionServiceInput { + checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" } - this.executionServiceInput = this.executionServiceInput + this.executionServiceInput = executionServiceInput processId = executionServiceInput.commonHeader.requestId workflowName = executionServiceInput.actionIdentifiers.actionName val metadata = executionServiceInput.metadata stepName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_STEP) - nodeTemplateName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE) - interfaceName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE) - operationName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION) + log.info("preparing request id($processId) for workflow($workflowName) step($stepName)") + + val operationInputs = metadata.get("$stepName-step-inputs") ?: JsonNodeFactory.instance.objectNode() + + operationInputs.fields().forEach { + this.operationInputs[it.key] = it.value + } + + nodeTemplateName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE) + interfaceName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE) + operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION) + + + val operationResolvedProperties = bluePrintRuntimeService!!.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) + + this.operationInputs.putAll(operationResolvedProperties) + - checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" } - log.info("prepareRequest...") return executionServiceInput } override fun prepareResponse(): ExecutionServiceOutput { log.info("Preparing Response...") + executionServiceOutput.commonHeader = executionServiceInput!!.commonHeader + + // Resolve the Output Expression + val operationResolvedProperties = bluePrintRuntimeService!! + .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) + + val metadata = executionServiceOutput.metadata + metadata.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, stepName) + metadata.putJsonElement("$stepName-step-outputs", operationResolvedProperties) + + // Populate Status + val status = Status() + status.eventType = "EVENT-COMPONENT-EXECUTED" + status.code = 200 + status.message = BluePrintConstants.STATUS_SUCCESS + executionServiceOutput.status = status return this.executionServiceOutput } @@ -72,4 +108,8 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode