aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/services/execution-service
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-04 10:25:44 -0500
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-04 10:31:15 -0500
commit04425ebaae2abc1862160acc7674205377078b4f (patch)
tree2eeaa43a96f72cafca82e378d39b42a173655fea /ms/blueprintsprocessor/modules/services/execution-service
parent2b5b2c3003ba18259b424ffc48daeb94ca0e4e20 (diff)
Add Blueprint Runtime Input/Output logic
Change-Id: I0355e78862096b7b4074faa882d66ce27d6e1844 Issue-ID: CCSDK-670 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
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 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<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