summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/services/execution-service
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/services/execution-service')
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt52
1 files changed, 46 insertions, 6 deletions
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 dfdf6259e..37f14925d 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<ExecutionServiceInput, ExecutionServiceOutput> {
+ @Transient
private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)
var executionServiceInput: ExecutionServiceInput? = null
@@ -41,29 +47,59 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
var interfaceName: String = ""
var operationName: String = ""
var nodeTemplateName: String = ""
+ var operationInputs: MutableMap<String, JsonNode> = 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<ExecutionServic
process(executionServiceInput)
return prepareResponse()
}
+
+ fun getOperationInput(key: String): JsonNode {
+ return operationInputs.get(key) ?: NullNode.instance
+ }
} \ No newline at end of file