Controller Blueprints Component Core 91/72391/1
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Sun, 11 Nov 2018 22:41:48 +0000 (17:41 -0500)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Sun, 11 Nov 2018 22:41:48 +0000 (17:41 -0500)
Implement Blueprint context, run time service, metadata utils.

Change-Id: Ifc3aa1e1b04b326778e431e972e5d997275c013b
Issue-ID: CCSDK-670
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
13 files changed:
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt
components/core/src/test/resources/properties/convert.json

index 5071703..0000621 100644 (file)
  */\r
 \r
 package org.onap.ccsdk.apps.controllerblueprints.core\r
+\r
 /**\r
  *\r
  *\r
  * @author Brinda Santh\r
  */\r
-class BluePrintProcessorException : Exception {\r
+class BluePrintProcessorException : RuntimeException {\r
     var code: Int = 100\r
 \r
     constructor(message: String, cause: Throwable) : super(message, cause)\r
index 7302f2b..c32e15f 100644 (file)
 \r
 package org.onap.ccsdk.apps.controllerblueprints.core\r
 \r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.BooleanNode\r
+import com.fasterxml.jackson.databind.node.DoubleNode\r
+import com.fasterxml.jackson.databind.node.IntNode\r
+import com.fasterxml.jackson.databind.node.TextNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
 import org.slf4j.helpers.MessageFormatter\r
 import java.io.File\r
 import java.io.InputStream\r
@@ -27,14 +33,30 @@ import kotlin.reflect.KClass
  * @author Brinda Santh\r
  */\r
 \r
-fun format(message: String, vararg args: Any?) : String{\r
-    if(args != null && args.isNotEmpty()){\r
+fun String.asJsonPrimitive(): TextNode {\r
+    return TextNode(this)\r
+}\r
+\r
+fun Boolean.asJsonPrimitive(): BooleanNode {\r
+    return BooleanNode.valueOf(this)\r
+}\r
+\r
+fun Int.asJsonPrimitive(): IntNode {\r
+    return IntNode.valueOf(this)\r
+}\r
+\r
+fun Double.asJsonPrimitive(): DoubleNode {\r
+    return DoubleNode.valueOf(this)\r
+}\r
+\r
+fun format(message: String, vararg args: Any?): String {\r
+    if (args != null && args.isNotEmpty()) {\r
         return MessageFormatter.arrayFormat(message, args).message\r
     }\r
-   return message\r
+    return message\r
 }\r
 \r
-fun <T : Any> MutableMap<String, *>.getCastOptionalValue(key: String, valueType: KClass<T>): T? {\r
+fun <T : Any> MutableMap<String, *>.castOptionalValue(key: String, valueType: KClass<T>): T? {\r
     if (containsKey(key)) {\r
         return get(key) as? T\r
     } else {\r
@@ -42,27 +64,54 @@ fun <T : Any> MutableMap<String, *>.getCastOptionalValue(key: String, valueType:
     }\r
 }\r
 \r
-fun <T : Any> MutableMap<String, *>.getCastValue(key: String, valueType: KClass<T>): T {\r
+fun <T : Any> MutableMap<String, *>.castValue(key: String, valueType: KClass<T>): T {\r
     if (containsKey(key)) {\r
         return get(key) as T\r
     } else {\r
-        throw BluePrintException("couldn't find the key " + key)\r
+        throw BluePrintException("couldn't find the key $key")\r
     }\r
 }\r
 \r
-fun checkNotEmpty(value : String?) : Boolean{\r
+fun MutableMap<String, JsonNode>.putJsonElement(key: String, value: Any) {\r
+    when (value) {\r
+        is JsonNode ->\r
+            this.put(key, value)\r
+        is String ->\r
+            this.put(key, TextNode(value))\r
+        is Boolean ->\r
+            this.put(key, BooleanNode.valueOf(value))\r
+        is Int ->\r
+            this.put(key, IntNode.valueOf(value.toInt()))\r
+        is Double ->\r
+            this.put(key, DoubleNode.valueOf(value.toDouble()))\r
+        else ->\r
+            this.put(key, JacksonUtils.jsonNodeFromObject(value))\r
+    }\r
+}\r
+\r
+fun MutableMap<String, JsonNode>.getAsString(key: String): String {\r
+    return this[key]?.asText() ?: throw BluePrintException("couldn't find value for key($key)")\r
+}\r
+\r
+fun MutableMap<String, JsonNode>.getAsBoolean(key: String): Boolean {\r
+    return this[key]?.asBoolean() ?: throw BluePrintException("couldn't find value for key($key)")\r
+}\r
+\r
+// Checks\r
+\r
+fun checkNotEmpty(value: String?): Boolean {\r
     return value != null && value.isNotEmpty()\r
 }\r
 \r
-fun checkNotEmptyNThrow(value : String?, message : String? = value.plus(" is null/empty ")) : Boolean{\r
+fun checkNotEmptyNThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean {\r
     val notEmpty = value != null && value.isNotEmpty()\r
-    if(!notEmpty){\r
+    if (!notEmpty) {\r
         throw BluePrintException(message!!)\r
     }\r
     return notEmpty\r
 }\r
 \r
-fun InputStream.toFile(path: String) : File {\r
+fun InputStream.toFile(path: String): File {\r
     val file = File(path)\r
     file.outputStream().use { this.copyTo(it) }\r
     return file\r
index 70f3c55..9b6fbbf 100644 (file)
@@ -91,7 +91,7 @@ A node filter definition defines criteria for selection of a TOSCA Node Template
 \r
 class NodeFilterDefinition {\r
     var properties: MutableMap<String, PropertyDefinition>? = null\r
-    var capabilities : MutableList<String>? = null\r
+    var capabilities: MutableList<String>? = null\r
 }\r
 \r
 /*\r
@@ -348,7 +348,7 @@ class ArtifactType : EntityType() {
 A Data Type definition defines the schema for new named datatypes in TOSCA.\r
  */\r
 \r
-class DataType : EntityType(){\r
+class DataType : EntityType() {\r
     var constraints: MutableList<ConstraintClause>? = null\r
 }\r
 \r
@@ -410,7 +410,7 @@ class GroupType : EntityType() {
     topology at some stage of its lifecycle, but is not explicitly part of the topology itself\r
     (i.e., it does not prevent the application or service from being deployed or run if it did not exist).\r
  */\r
-class PolicyType : EntityType(){\r
+class PolicyType : EntityType() {\r
     lateinit var targets: MutableList<String>\r
 }\r
 \r
@@ -434,10 +434,10 @@ class GroupDefinition {
     var id: String? = null\r
     lateinit var type: String\r
     var description: String? = null\r
-    var metadata : MutableMap<String, String>? = null\r
-    var properties : MutableMap<String, JsonNode>? = null\r
+    var metadata: MutableMap<String, String>? = null\r
+    var properties: MutableMap<String, JsonNode>? = null\r
     var members = ArrayList<String>()\r
-    var interfaces : MutableMap<String, InterfaceDefinition>?= null\r
+    var interfaces: MutableMap<String, InterfaceDefinition>? = null\r
 }\r
 \r
 /*\r
@@ -597,7 +597,7 @@ class ServiceTemplate {
     @get:JsonProperty("node_types")\r
     var nodeTypes: MutableMap<String, NodeType>? = null\r
     @get:JsonProperty("policy_types")\r
-    var policyTypes: PolicyType? = null\r
+    var policyTypes: MutableMap<String, PolicyType>? = null\r
     @get:JsonProperty("topology_template")\r
     var topologyTemplate: TopologyTemplate? = null\r
 }\r
index 46da9d9..4764479 100644 (file)
@@ -22,17 +22,16 @@ import com.fasterxml.jackson.databind.JsonNode
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+\r
 /**\r
  *\r
  *\r
  * @author Brinda Santh\r
  */\r
-class BluePrintContext(serviceTemplate: ServiceTemplate) {\r
+class BluePrintContext(val serviceTemplate: ServiceTemplate) {\r
 \r
     private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
 \r
-    val serviceTemplate: ServiceTemplate = serviceTemplate\r
-\r
     val imports: List<ImportDefinition>? = serviceTemplate.imports\r
 \r
     val metadata: MutableMap<String, String>? = serviceTemplate.metadata\r
@@ -41,18 +40,33 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) {
 \r
     val inputs: MutableMap<String, PropertyDefinition>? = serviceTemplate.topologyTemplate?.inputs\r
 \r
-    val workflows: MutableMap<String, Workflow>? = serviceTemplate.topologyTemplate?.workflows\r
-\r
     fun blueprintJson(pretty: Boolean = false): String = print("json", pretty)\r
 \r
-    fun blueprintYaml(pretty: Boolean = false): String = print("yaml", pretty)\r
-\r
     private fun print(type: String? = "json", pretty: Boolean = false): String {\r
         return JacksonUtils.getJson(serviceTemplate, pretty)\r
     }\r
 \r
     // Workflow\r
-    fun workflowByName(name: String): Workflow? = workflows?.get(name)\r
+    val workflows: MutableMap<String, Workflow>? = serviceTemplate.topologyTemplate?.workflows\r
+\r
+    fun workflowByName(workFlowName: String): Workflow = workflows?.get(workFlowName)\r
+            ?: throw BluePrintException("could't get workflow($workFlowName)")\r
+\r
+    fun workflowStepByName(workFlowName: String, stepName: String): Step {\r
+        return workflowByName(workFlowName).steps?.get(stepName)\r
+                ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)")\r
+    }\r
+\r
+    fun workflowStepNodeTemplate(workFlowName: String, stepName: String): NodeTemplate {\r
+        val nodeTemplateName = workflowStepByName(workFlowName, stepName).target\r
+                ?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)")\r
+        return nodeTemplateByName(nodeTemplateName)\r
+    }\r
+\r
+    fun workflowStepFirstCallOperation(workFlowName: String, stepName: String): String {\r
+        return workflowStepByName(workFlowName, stepName).activities?.filter { it.callOperation != null }?.single()?.callOperation\r
+                ?: throw BluePrintException("could't get first callOperation for WorkFlow($workFlowName) ")\r
+    }\r
 \r
     // Data Type\r
     fun dataTypeByName(name: String): DataType? = dataTypes?.get(name)\r
@@ -60,41 +74,65 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) {
     // Artifact Type\r
     val artifactTypes: MutableMap<String, ArtifactType>? = serviceTemplate.artifactTypes\r
 \r
+    // Policy Types\r
+    val policyTypes: MutableMap<String, PolicyType>? = serviceTemplate.policyTypes\r
+\r
+    fun policyTypeByName(policyName: String) = policyTypes?.get(policyName)\r
+            ?: throw BluePrintException("could't get policy type for the name($policyName)")\r
+\r
+    fun policyTypesDerivedFrom(name: String): MutableMap<String, PolicyType>? {\r
+        return policyTypes?.filterValues { policyType -> policyType.derivedFrom == name }?.toMutableMap()\r
+    }\r
+\r
+    fun policyTypesTarget(target: String): MutableMap<String, PolicyType>? {\r
+        return policyTypes?.filterValues { it.targets.contains(target) }?.toMutableMap()\r
+    }\r
+\r
+    fun policyTypesTargetNDerivedFrom(target: String, derivedFrom: String): MutableMap<String, PolicyType>? {\r
+        return policyTypesDerivedFrom(derivedFrom)?.filterValues {\r
+            it.targets.contains(target)\r
+        }?.toMutableMap()\r
+    }\r
+\r
     // Node Type Methods\r
     val nodeTypes: MutableMap<String, NodeType>? = serviceTemplate.nodeTypes\r
 \r
     fun nodeTypeByName(name: String): NodeType =\r
-            nodeTypes?.get(name) ?: throw BluePrintException(String.format("Failed to get node type for the name : %s", name))\r
+            nodeTypes?.get(name)\r
+                    ?: throw BluePrintException("could't get node type for the name($name)")\r
 \r
     fun nodeTypeDerivedFrom(name: String): MutableMap<String, NodeType>? {\r
         return nodeTypes?.filterValues { nodeType -> nodeType.derivedFrom == name }?.toMutableMap()\r
     }\r
 \r
-    fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition? {\r
+    fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition {\r
         return nodeTypeByName(nodeTypeName).interfaces?.get(interfaceName)\r
+                ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName)")\r
     }\r
 \r
-    fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition? {\r
-        return nodeTypeInterface(nodeTypeName, interfaceName)?.operations?.get(operationName)\r
+    fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition {\r
+        return nodeTypeInterface(nodeTypeName, interfaceName).operations?.get(operationName)\r
+                ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName) operation definition($operationName)")\r
     }\r
 \r
-    fun interfaceNameForNodeType(nodeTypeName: String): String? {\r
+    fun interfaceNameForNodeType(nodeTypeName: String): String {\r
         return nodeTypeByName(nodeTypeName).interfaces?.keys?.first()\r
+                ?: throw BluePrintException("could't get NodeType($nodeTypeName)'s first InterfaceDefinition name")\r
     }\r
 \r
     fun nodeTypeInterfaceOperationInputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap<String, PropertyDefinition>? {\r
-        return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName)?.inputs\r
+        return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).inputs\r
     }\r
 \r
     fun nodeTypeInterfaceOperationOutputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap<String, PropertyDefinition>? {\r
-        return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName)?.outputs\r
+        return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).outputs\r
     }\r
 \r
     // Node Template Methods\r
     val nodeTemplates: MutableMap<String, NodeTemplate>? = serviceTemplate.topologyTemplate?.nodeTemplates\r
 \r
     fun nodeTemplateByName(name: String): NodeTemplate =\r
-            nodeTemplates?.get(name) ?: throw BluePrintException("Failed to get node template for the name " + name)\r
+            nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name) ")\r
 \r
     fun nodeTemplateForNodeType(name: String): MutableMap<String, NodeTemplate>? {\r
         return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap()\r
@@ -113,55 +151,62 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) {
         return nodeTemplateByName(nodeTemplateName).artifacts\r
     }\r
 \r
-    fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition? {\r
+    fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition {\r
         return nodeTemplateArtifacts(nodeTemplateName)?.get(artifactName)\r
+                ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)")\r
     }\r
 \r
-    fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment? {\r
+    fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment {\r
         return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first()\r
+                ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment")\r
     }\r
 \r
-    fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String? {\r
+    fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String {\r
         return nodeTemplateByName(nodeTemplateName).interfaces?.keys?.first()\r
+                ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment name")\r
     }\r
 \r
-    fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String? {\r
-        return nodeTemplateFirstInterface(nodeTemplateName)?.operations?.keys?.first()\r
+    fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String {\r
+        return nodeTemplateFirstInterface(nodeTemplateName).operations?.keys?.first()\r
+                ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment's first OperationAssignment name")\r
     }\r
 \r
     fun nodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>? {\r
-        return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)?.operations?.get(operationName)?.inputs\r
+        return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).inputs\r
     }\r
 \r
     fun nodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>? {\r
-        return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)?.operations?.get(operationName)?.outputs\r
+        return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).outputs\r
     }\r
 \r
-    fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment? {\r
+    fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment {\r
         return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)\r
+                ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName)")\r
     }\r
 \r
-\r
-    fun nodeTemplateInterfaceOperation(nodeTemplateName: String, interfaceName: String, operationName: String): OperationAssignment? {\r
-        return nodeTemplateInterface(nodeTemplateName, interfaceName)?.operations?.get(operationName)\r
+    fun nodeTemplateInterfaceOperation(nodeTemplateName: String, interfaceName: String, operationName: String): OperationAssignment {\r
+        return nodeTemplateInterface(nodeTemplateName, interfaceName).operations?.get(operationName)\r
+                ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName) OperationAssignment($operationName)")\r
     }\r
 \r
-    fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment? {\r
+    fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment {\r
         return nodeTemplateByName(nodeTemplateName).capabilities?.get(capabilityName)\r
+                ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s CapabilityAssignment($capabilityName)")\r
     }\r
 \r
-    fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment? {\r
+    fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment {\r
         return nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)\r
+                ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first RequirementAssignment($requirementName)")\r
     }\r
 \r
     fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate {\r
-        val requirementNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node\r
-                ?: throw BluePrintException(String.format("failed to get node name for node template's (%s) requirement's (%s) " + nodeTemplateName, requirementName))\r
-        return nodeTemplateByName(requirementNodeTemplateName)\r
+        val filteredNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node\r
+                ?: throw BluePrintException("could't NodeTemplate for NodeTemplate's($nodeTemplateName) requirement's ($requirementName) ")\r
+        return nodeTemplateByName(filteredNodeTemplateName)\r
     }\r
 \r
     fun nodeTemplateCapabilityProperty(nodeTemplateName: String, capabilityName: String, propertyName: String): Any? {\r
-        return nodeTemplateCapability(nodeTemplateName, capabilityName)?.properties?.get(propertyName)\r
+        return nodeTemplateCapability(nodeTemplateName, capabilityName).properties?.get(propertyName)\r
     }\r
 \r
     // Chained Functions\r
index 2485abd..f84b2c5 100644 (file)
 package org.onap.ccsdk.apps.controllerblueprints.core.service\r
 \r
 \r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
 import com.fasterxml.jackson.databind.JsonNode\r
 import com.fasterxml.jackson.databind.node.NullNode\r
+import com.fasterxml.jackson.databind.node.ObjectNode\r
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
@@ -27,31 +31,123 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
 import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
-import com.att.eelf.configuration.EELFLogger\r
-import com.att.eelf.configuration.EELFManager\r
-import com.fasterxml.jackson.databind.node.ObjectNode\r
-import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
+\r
+interface BluePrintRuntimeService<T> {\r
+\r
+    fun id(): String\r
+\r
+    fun bluePrintContext(): BluePrintContext\r
+\r
+    fun getExecutionContext(): T\r
+\r
+    fun setExecutionContext(executionContext: T)\r
+\r
+    fun put(key: String, value: JsonNode)\r
+\r
+    fun get(key: String): JsonNode?\r
+\r
+    fun cleanRuntime()\r
+\r
+    /*\r
+      Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing\r
+   */\r
+    fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, JsonNode>\r
+\r
+    fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>\r
+\r
+    fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>\r
+\r
+    fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String\r
+\r
+    fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)\r
+\r
+    fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)\r
+\r
+    fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode)\r
+\r
+    fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode)\r
+\r
+    fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode)\r
+\r
+    fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode)\r
+\r
+    fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode)\r
+\r
+    fun getInputValue(propertyName: String): JsonNode\r
+\r
+    fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode\r
+\r
+    fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode?\r
+\r
+    fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode?\r
+\r
+    fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: String): JsonNode?\r
+\r
+    fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: String): JsonNode?\r
+\r
+    fun assignInputs(jsonNode: JsonNode)\r
+\r
+    fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode)\r
+\r
+    fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List<String>): JsonNode\r
+}\r
 \r
 /**\r
  *\r
  *\r
  * @author Brinda Santh\r
  */\r
-open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var context: MutableMap<String, Any> = hashMapOf()) {\r
+open class DefaultBluePrintRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)\r
+    : BluePrintRuntimeService<MutableMap<String, JsonNode>> {\r
 \r
     private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString())\r
 \r
+    private var store: MutableMap<String, JsonNode> = hashMapOf()\r
+\r
+    override fun id(): String {\r
+        return id\r
+    }\r
+\r
+    override fun bluePrintContext(): BluePrintContext {\r
+        return bluePrintContext\r
+    }\r
+\r
+    override fun getExecutionContext(): MutableMap<String, JsonNode> {\r
+        return store\r
+    }\r
+\r
+    @Suppress("UNCHECKED_CAST")\r
+    override fun setExecutionContext(executionContext: MutableMap<String, JsonNode>) {\r
+        this.store = executionContext\r
+    }\r
+\r
+    override fun put(key: String, value: JsonNode) {\r
+        store[key] = value\r
+    }\r
+\r
+    override fun get(key: String): JsonNode {\r
+        return store[key] ?: throw BluePrintProcessorException("failed to get execution property($key)")\r
+    }\r
+\r
+    override fun cleanRuntime() {\r
+        store.clear()\r
+    }\r
+\r
+    private fun getJsonNode(key: String): JsonNode {\r
+        return get(key)\r
+    }\r
+\r
     /*\r
         Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing\r
      */\r
-    open fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, Any?> {\r
+    override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, JsonNode> {\r
         log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName)\r
-        val propertyAssignmentValue: MutableMap<String, Any?> = hashMapOf()\r
+        val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()\r
 \r
         val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)\r
 \r
-        val propertyAssignments: MutableMap<String, Any?> =\r
-                nodeTemplate.properties as MutableMap<String, Any?>\r
+        val propertyAssignments: MutableMap<String, JsonNode> =\r
+                nodeTemplate.properties as MutableMap<String, JsonNode>\r
 \r
         // Get the Node Type Definitions\r
         val nodeTypeProperties: MutableMap<String, PropertyDefinition> =\r
@@ -65,7 +161,7 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c
             var resolvedValue: JsonNode = NullNode.getInstance()\r
             if (propertyAssignment != null) {\r
                 // Resolve the Expressing\r
-                val propertyAssignmentExpression = PropertyAssignmentService(context, this)\r
+                val propertyAssignmentExpression = PropertyAssignmentService(this)\r
                 resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)\r
             } else {\r
                 // Assign default value to the Operation\r
@@ -80,12 +176,12 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c
         return propertyAssignmentValue\r
     }\r
 \r
-    open fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String,\r
-                                                         interfaceName: String, operationName: String): MutableMap<String, Any?> {\r
+    override fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String,\r
+                                                             interfaceName: String, operationName: String): MutableMap<String, JsonNode> {\r
         log.info("resolveNodeTemplateInterfaceOperationInputs for node template ({}),interface name ({}), " +\r
                 "operationName({})", nodeTemplateName, interfaceName, operationName)\r
 \r
-        val propertyAssignmentValue: MutableMap<String, Any?> = hashMapOf()\r
+        val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()\r
 \r
         val propertyAssignments: MutableMap<String, Any> =\r
                 bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>\r
@@ -109,7 +205,7 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c
             var resolvedValue: JsonNode = NullNode.getInstance()\r
             if (propertyAssignment != null) {\r
                 // Resolve the Expressing\r
-                val propertyAssignmentExpression = PropertyAssignmentService(context, this)\r
+                val propertyAssignmentExpression = PropertyAssignmentService(this)\r
                 resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)\r
             } else {\r
                 // Assign default value to the Operation\r
@@ -127,12 +223,12 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c
     }\r
 \r
 \r
-    open fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String,\r
-                                                          interfaceName: String, operationName: String): MutableMap<String, Any?>  {\r
+    override fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String,\r
+                                                              interfaceName: String, operationName: String): MutableMap<String, JsonNode> {\r
         log.info("resolveNodeTemplateInterfaceOperationOutputs for node template ({}),interface name ({}), " +\r
                 "operationName({})", nodeTemplateName, interfaceName, operationName)\r
 \r
-        val propertyAssignmentValue: MutableMap<String, Any?> = hashMapOf()\r
+        val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()\r
 \r
         val propertyAssignments: MutableMap<String, Any> =\r
                 bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>\r
@@ -155,7 +251,7 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c
             var resolvedValue: JsonNode = NullNode.getInstance()\r
             if (propertyAssignment != null) {\r
                 // Resolve the Expressing\r
-                val propertyAssignmentExpression = PropertyAssignmentService(context, this)\r
+                val propertyAssignmentExpression = PropertyAssignmentService(this)\r
                 resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)\r
             } else {\r
                 // Assign default value to the Operation\r
@@ -173,131 +269,131 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c
         return propertyAssignmentValue\r
     }\r
 \r
-    open fun resolveNodeTemplateArtifact(nodeTemplateName: String,\r
-                                         artifactName: String): String {\r
+    override fun resolveNodeTemplateArtifact(nodeTemplateName: String,\r
+                                             artifactName: String): String {\r
         val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)\r
 \r
         val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName)\r
                 ?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template"\r
                         , artifactName))\r
-        val propertyAssignmentExpression = PropertyAssignmentService(context, this)\r
+        val propertyAssignmentExpression = PropertyAssignmentService(this)\r
         return propertyAssignmentExpression.artifactContent(artifactDefinition)\r
     }\r
 \r
 \r
-    open fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) {\r
+    override fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) {\r
         val path = StringBuilder(BluePrintConstants.PATH_INPUTS)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
         log.trace("setting input path ({}), values ({})", path, value)\r
-        context[path] = value\r
+        put(path, value)\r
     }\r
 \r
-    open fun setWorkflowInputValue(workflowName: String, propertyName: String, value: JsonNode) {\r
+    override fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) {\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS).append(BluePrintConstants.PATH_DIVIDER).append(workflowName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
-        context[path] = value\r
+        put(path, value)\r
     }\r
 \r
-    open fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) {\r
+    override fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) {\r
 \r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
-        context[path] = value\r
+        put(path, value)\r
     }\r
 \r
-    open fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) {\r
+    override fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) {\r
 \r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString()\r
-        context[path] = value\r
+        put(path, value)\r
     }\r
 \r
-    open fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
-                                                   value: JsonNode) {\r
+    override fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
+                                                       value: JsonNode) {\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
         log.trace("setting operation property path ({}), values ({})", path, value)\r
-        context[path] = value\r
+        put(path, value)\r
     }\r
 \r
-    open fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
-                                                value: JsonNode) {\r
+    override fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
+                                                    value: JsonNode) {\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
-        context[path] = value\r
+        put(path, value)\r
     }\r
 \r
-    open fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
-                                                 value: JsonNode) {\r
+    override fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
+                                                     value: JsonNode) {\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
-        context[path] = value\r
+        put(path, value)\r
     }\r
 \r
 \r
-    open fun getInputValue(propertyName: String): JsonNode {\r
+    override fun getInputValue(propertyName: String): JsonNode {\r
         val path = StringBuilder(BluePrintConstants.PATH_INPUTS)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
-        return context[path] as? JsonNode ?: NullNode.instance\r
+        return getJsonNode(path)\r
     }\r
 \r
-    open fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode {\r
+    override fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode {\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS).append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
-        return context[path] as JsonNode\r
+        return getJsonNode(path)\r
     }\r
 \r
-    open fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? {\r
+    override fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode {\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
-        return context[path] as JsonNode\r
+        return getJsonNode(path)\r
     }\r
 \r
-    open fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode? {\r
+    override fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode {\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString()\r
-        return context[path] as JsonNode\r
+        return getJsonNode(path)\r
     }\r
 \r
-    open fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName:\r
-    String): JsonNode? {\r
+    override fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName:\r
+    String): JsonNode {\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_REQUIREMENTS).append(requirementName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
-        return context[path] as JsonNode\r
+        return getJsonNode(path)\r
     }\r
 \r
-    open fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName:\r
-    String): JsonNode? {\r
+    override fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName:\r
+    String): JsonNode {\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_CAPABILITIES).append(capabilityName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
-        return context[path] as JsonNode\r
+        return getJsonNode(path)\r
     }\r
 \r
-    open fun assignInputs(jsonNode: JsonNode) {\r
+    override fun assignInputs(jsonNode: JsonNode) {\r
         log.info("assignInputs from input JSON ({})", jsonNode.toString())\r
         bluePrintContext.inputs?.forEach { propertyName, property ->\r
             val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
@@ -306,27 +402,28 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c
         }\r
     }\r
 \r
-    open fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) {\r
+    override fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) {\r
         log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString())\r
-        bluePrintContext.workflowByName(workflowName)?.inputs?.forEach { propertyName, _ ->\r
+\r
+        bluePrintContext.workflowByName(workflowName).inputs?.forEach { propertyName, property ->\r
             val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
                     ?: NullNode.getInstance()\r
-            setWorkflowInputValue(workflowName, propertyName, valueNode)\r
+            setInputValue(propertyName, property, valueNode)\r
         }\r
     }\r
 \r
-    open fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List<String>): JsonNode {\r
+    override fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List<String>): JsonNode {\r
 \r
         val jsonNode: ObjectNode = jacksonObjectMapper().createObjectNode()\r
         val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
                 .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES)\r
                 .append(BluePrintConstants.PATH_DIVIDER).toString()\r
-        context.keys.filter {\r
+        store.keys.filter {\r
             it.startsWith(path)\r
         }.map {\r
             val key = it.replace(path, "")\r
             if (keys.contains(key)) {\r
-                val value = context[it] as JsonNode\r
+                val value = store[it] as JsonNode\r
                 jsonNode.set(key, value)\r
             }\r
         }\r
index 131bb30..5b511f1 100644 (file)
@@ -18,6 +18,8 @@
 package org.onap.ccsdk.apps.controllerblueprints.core.service\r
 \r
 \r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
 import com.fasterxml.jackson.databind.JsonNode\r
 import com.fasterxml.jackson.databind.node.NullNode\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
@@ -26,19 +28,16 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.*
 import org.onap.ccsdk.apps.controllerblueprints.core.format\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils\r
-import com.att.eelf.configuration.EELFLogger\r
-import com.att.eelf.configuration.EELFManager\r
 \r
 /**\r
  *\r
  *\r
  * @author Brinda Santh\r
  */\r
-class PropertyAssignmentService(var context: MutableMap<String, Any>,\r
-                                var bluePrintRuntimeService: BluePrintRuntimeService) {\r
+class PropertyAssignmentService(var bluePrintRuntimeService: BluePrintRuntimeService<MutableMap<String, JsonNode>>) {\r
     private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
 \r
-    private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext\r
+    private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext()\r
 \r
 /*\r
 \r
@@ -198,7 +197,7 @@ If Property Assignment is Expression.
     }\r
 \r
     fun artifactContent(artifactDefinition: ArtifactDefinition): String {\r
-        val bluePrintBasePath: String = context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] as? String\r
+        val bluePrintBasePath: String = bluePrintRuntimeService.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) as? String\r
                 ?: throw BluePrintException(format("failed to get property (%s) from context", BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH))\r
 \r
         if (artifactDefinition.repository != null) {\r
index b7f9fc7..43d55fe 100644 (file)
 package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
 \r
 \r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import com.fasterxml.jackson.databind.JsonNode\r
 import org.apache.commons.io.FileUtils\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData\r
-import com.att.eelf.configuration.EELFLogger\r
-import com.att.eelf.configuration.EELFManager\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService\r
 import java.io.File\r
 import java.nio.charset.Charset\r
 \r
@@ -57,39 +62,46 @@ object BluePrintMetadataUtils {
         return toscaMetaData\r
     }\r
 \r
-    /*\r
+    @JvmStatic\r
     fun getBluePrintContext(blueprintBasePath: String): BluePrintContext {\r
 \r
-        val metaDataFile = StringBuilder().append(blueprintBasePath).append(File.separator)\r
-                .append(BluePrintConstants.DEFAULT_TOSCA_METADATA_ENTRY_DEFINITION_FILE).toString()\r
-\r
-        val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(metaDataFile)\r
+        val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)\r
 \r
-        log.info("Processing blueprint base path ({}) and entry definition file ({})", blueprintBasePath, toscaMetaData.entityDefinitions)\r
+        log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})")\r
 \r
-        return BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
-                .readBlueprintFile(toscaMetaData.entityDefinitions!!, blueprintBasePath)\r
+        return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath)\r
     }\r
 \r
-    fun getBluePrintRuntime(requestId: String, blueprintBasePath: String): BluePrintRuntimeService {\r
-\r
-        val metaDataFile = StringBuilder().append(blueprintBasePath).append(File.separator)\r
-                .append(BluePrintConstants.DEFAULT_TOSCA_METADATA_ENTRY_DEFINITION_FILE).toString()\r
-\r
-        val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(metaDataFile)\r
+    @JvmStatic\r
+    fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {\r
 \r
-        log.info("Processing blueprint base path ({}) and entry definition file ({})", blueprintBasePath, toscaMetaData.entityDefinitions)\r
+        val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)\r
 \r
-        val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
-                .readBlueprintFile(toscaMetaData.entityDefinitions!!, blueprintBasePath)\r
+        val context: MutableMap<String, JsonNode> = hashMapOf()\r
+        context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive()\r
+        context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive()\r
 \r
-        val context: MutableMap<String, Any> = hashMapOf()\r
-        context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath\r
-        context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = requestId\r
+        val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)\r
+        bluePrintRuntimeService.setExecutionContext(context)\r
 \r
-        val bluePrintRuntimeService: BluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)\r
+        return bluePrintRuntimeService\r
+    }\r
 \r
+    @JvmStatic\r
+    fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap<String, JsonNode>): BluePrintRuntimeService<MutableMap<String, JsonNode>> {\r
+        val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)\r
+        val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)\r
+        bluePrintRuntimeService.setExecutionContext(executionContext)\r
         return bluePrintRuntimeService\r
     }\r
-    */\r
+\r
+    @JvmStatic\r
+    fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext {\r
+        val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions)\r
+        val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)\r
+        // TODO ("Fix for Multiple Service Template file definitions")\r
+//        val schemaImportResolverUtils = BluePrintResolverService(rootServiceTemplate, basePath)\r
+//        val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate()\r
+        return BluePrintContext(rootServiceTemplate)\r
+    }\r
 }
\ No newline at end of file
index 0e4c3e3..4501275 100644 (file)
 \r
 package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
 \r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
 import com.fasterxml.jackson.databind.JsonNode\r
 import com.fasterxml.jackson.databind.node.NullNode\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext\r
-import com.att.eelf.configuration.EELFLogger\r
-import com.att.eelf.configuration.EELFManager\r
 \r
 /**\r
  *\r
@@ -31,17 +31,23 @@ import com.att.eelf.configuration.EELFManager
 object BluePrintRuntimeUtils {\r
     private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
 \r
-    fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, Any>) {\r
+    fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, JsonNode>) {\r
         val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName)\r
         return assignInputs(bluePrintContext, jsonNode, context)\r
     }\r
 \r
-    fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap<String, Any>) {\r
+    fun assignInputsFromClassPathFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String,\r
+            JsonNode>) {\r
+        val jsonNode = JacksonUtils.jsonNodeFromClassPathFile(fileName)\r
+        return assignInputs(bluePrintContext, jsonNode, context)\r
+    }\r
+\r
+    fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap<String, JsonNode>) {\r
         val jsonNode: JsonNode = JacksonUtils.jsonNode(content)\r
         return assignInputs(bluePrintContext, jsonNode, context)\r
     }\r
 \r
-    fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap<String, Any>) {\r
+    fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap<String, JsonNode>) {\r
         log.info("assignInputs from input JSON ({})", jsonNode.toString())\r
         bluePrintContext.inputs?.forEach { propertyName, _ ->\r
             val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance()\r
index dcafa97..9d6fe08 100644 (file)
@@ -64,7 +64,7 @@ class TopologicalSortingUtils<V> {
     }\r
 \r
     fun outDegree(): Map<V, Int> {\r
-        var result: MutableMap<V, Int> = hashMapOf()\r
+        val result: MutableMap<V, Int> = hashMapOf()\r
         for (v in neighbors.keys)\r
             result[v] = neighbors[v]!!.size\r
         return result\r
@@ -108,7 +108,7 @@ class TopologicalSortingUtils<V> {
 \r
 \r
     fun bfsDistance(start: V): Map<*, *> {\r
-        var distance: MutableMap<V, Int> = hashMapOf()\r
+        val distance: MutableMap<V, Int> = hashMapOf()\r
         // Initially, all distance are infinity, except start node\r
         for (v in neighbors.keys)\r
             distance[v] = -1\r
index f1980d2..68031d2 100644 (file)
 \r
 package org.onap.ccsdk.apps.controllerblueprints.core.service\r
 \r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
 import com.fasterxml.jackson.databind.JsonNode\r
-import org.junit.Before\r
 import org.junit.Test\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
-import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory\r
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject\r
-import com.att.eelf.configuration.EELFLogger\r
-import com.att.eelf.configuration.EELFManager\r
 import kotlin.test.assertEquals\r
 import kotlin.test.assertNotNull\r
 \r
@@ -37,13 +37,6 @@ import kotlin.test.assertNotNull
  */\r
 class BluePrintRuntimeServiceTest {\r
     private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
-    val basepath = "load/blueprints"\r
-\r
-\r
-    @Before\r
-    fun setUp(): Unit {\r
-\r
-    }\r
 \r
     @Test\r
     fun testResolveNodeTemplateProperties() {\r
@@ -56,40 +49,32 @@ class BluePrintRuntimeServiceTest {
         val inputNode: JsonNode = jsonNodeFromFile(inputDataPath)\r
         bluePrintRuntimeService.assignInputs(inputNode)\r
 \r
-        val propContext: MutableMap<String, Any?> = bluePrintRuntimeService.resolveNodeTemplateProperties("resource-assignment-action")\r
-        log.info("Context {}", bluePrintRuntimeService.context)\r
+        val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateProperties("resource-assignment-action")\r
 \r
         assertNotNull(propContext, "Failed to populate interface property values")\r
-        assertEquals(propContext.get("mode"), jsonNodeFromObject("sync"), "Failed to populate parameter process-name")\r
-        assertEquals(propContext.get("version"), jsonNodeFromObject("1.0.0"), "Failed to populate parameter version")\r
+        assertEquals(propContext.get("mode"), "sync".asJsonPrimitive(), "Failed to populate parameter process-name")\r
+        assertEquals(propContext.get("version"), "1.0.0".asJsonPrimitive(), "Failed to populate parameter version")\r
     }\r
 \r
     @Test\r
     fun testResolveNodeTemplateInterfaceOperationInputs() {\r
         log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************")\r
-        val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
-                .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)\r
-        assertNotNull(bluePrintContext, "Failed to populate Blueprint context")\r
-\r
-        val context: MutableMap<String, Any> = hashMapOf()\r
-        context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")\r
-\r
-        val inputDataPath = "src/test/resources/data/default-context.json"\r
-        BluePrintRuntimeUtils.assignInputsFromFile(bluePrintContext, inputDataPath, context)\r
 \r
+        val bluePrintRuntimeService = getBluePrintRuntimeService()\r
 \r
-        val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)\r
+        val executionContext = bluePrintRuntimeService.getExecutionContext()\r
 \r
-        log.info("Prepared Context {}", context)\r
+        BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(),\r
+                "data/default-context.json", executionContext)\r
 \r
-        val inContext: MutableMap<String, Any?> = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component",\r
+        val inContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component",\r
                 "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process")\r
 \r
         log.info("In Context {}", inContext)\r
 \r
         assertNotNull(inContext, "Failed to populate interface input property values")\r
-        assertEquals(inContext.get("action-name"), jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")\r
-        assertEquals(inContext.get("request-id"), jsonNodeFromObject("12345"), "Failed to populate parameter action-name")\r
+        assertEquals(inContext.get("action-name"), "sample-action".asJsonPrimitive(), "Failed to populate parameter action-name")\r
+        assertEquals(inContext.get("request-id"), "12345".asJsonPrimitive(), "Failed to populate parameter action-name")\r
     }\r
 \r
     @Test\r
@@ -129,8 +114,6 @@ class BluePrintRuntimeServiceTest {
         bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2",\r
                 jsonNodeFromObject("context2-value"))\r
 \r
-        log.info("Context {}", bluePrintRuntimeService.context)\r
-\r
         val keys = listOf("context1", "context2")\r
 \r
         val jsonValueNode = bluePrintRuntimeService.getJsonForNodeTemplateAttributeProperties("resource-assignment-ra-component", keys)\r
@@ -139,15 +122,14 @@ class BluePrintRuntimeServiceTest {
 \r
     }\r
 \r
-    private fun getBluePrintRuntimeService(): BluePrintRuntimeService {\r
-        val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
-                .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)\r
-        assertNotNull(bluePrintContext, "Failed to populate Blueprint context")\r
+    private fun getBluePrintRuntimeService(): BluePrintRuntimeService<MutableMap<String, JsonNode>> {\r
+        val blueprintBasePath: String = ("load/blueprints/baseconfiguration")\r
+        val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)\r
+        val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)\r
 \r
-        val context: MutableMap<String, Any> = hashMapOf()\r
-        context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")\r
+        assertEquals(blueprintBasePath.asJsonPrimitive(), checkBasePath, "Failed to get base path after runtime creation")\r
 \r
-        return BluePrintRuntimeService(bluePrintContext, context)\r
+        return blueprintRuntime\r
     }\r
 \r
 }
\ No newline at end of file
index d13caa5..c5f451e 100644 (file)
@@ -35,7 +35,7 @@ class JacksonReactorUtilsTest {
         assertNotNull(serviceTemplate, "Failed to simple transform Service Template")\r
         assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")\r
 \r
-        val jsonContent = JacksonReactorUtils.getJson(serviceTemplate!!, true).block()\r
+        val jsonContent = JacksonReactorUtils.getJson(serviceTemplate, true).block()\r
         assertNotNull(jsonContent, "Failed to get json content")\r
 \r
         val jsonNode = JacksonReactorUtils.jsonNodeFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json")\r
index a5a630e..c3718b2 100644 (file)
@@ -44,7 +44,7 @@ class JacksonUtilsTest {
         assertNotNull(serviceTemplate, "Failed to simple transform Service Template")\r
         assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")\r
 \r
-        val jsonContent = JacksonUtils.getJson(serviceTemplate!!, true)\r
+        val jsonContent = JacksonUtils.getJson(serviceTemplate, true)\r
         assertNotNull(jsonContent, "Failed to get json content")\r
     }\r
 \r
index af79915..966b025 100644 (file)
@@ -1,33 +1,36 @@
 {\r
-       "type": "sdnc-component-getResourceAssignment",\r
-       "interfaces": {\r
-               "ResourceAssignmentService": {\r
-                       "operations": {\r
-                               "getResourceAssignment": {\r
-                                       "inputs": {\r
-                                               "assignment-mappings": [\r
-                                                       {\r
-                                                               "name": "service-name",\r
-                                                               "mapping-field": "service",\r
-                                                               "mapping-category": "SDN",\r
-                                                               "required": true\r
-                                                       },\r
-                                                       {\r
-                                                               "name": "region-name",\r
-                                                               "mapping-field": "region",\r
-                                                               "mapping-category": "SDN",\r
-                                                               "required": true\r
-                                                       }\r
-                                               ],\r
-                                               "pre-data": { "get_input" : "get-resource-assignment.config-params" },\r
-                                               "prifix": "get-resource-assignment"\r
-                                       },\r
-                                       "outputs": {\r
-                                               "resource-assignment-status": "success",\r
-                                               "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params" }\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-       }\r
+  "type": "sdnc-component-getResourceAssignment",\r
+  "interfaces": {\r
+    "ResourceAssignmentService": {\r
+      "operations": {\r
+        "getResourceAssignment": {\r
+          "inputs": {\r
+            "assignment-mappings": [\r
+              {\r
+                "name": "service-name",\r
+                "mapping-field": "service",\r
+                "mapping-category": "SDN",\r
+                "required": true\r
+              },\r
+              {\r
+                "name": "region-name",\r
+                "mapping-field": "region",\r
+                "mapping-category": "SDN",\r
+                "required": true\r
+              }\r
+            ],\r
+            "pre-data": {\r
+              "get_input": "get-resource-assignment.config-params"\r
+            },\r
+            "prifix": "get-resource-assignment"\r
+          },\r
+          "outputs": {\r
+            "resource-assignment-status": "success",\r
+            "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params"\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
 }\r
+\r