From 8bec4a04cffac2ba03af3078d090c0b9466d78d7 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Tue, 8 Jan 2019 11:17:05 -0500 Subject: Add relationships type files load structure. Change-Id: I1be3ba493956674b476058094e05d681ce358711 Issue-ID: CCSDK-746 Signed-off-by: Muthuramalingam, Brinda Santh --- .../core/service/BluePrintExpressionService.kt | 22 +++++-------- .../core/service/BluePrintRuntimeService.kt | 38 +++++++++++++++------- .../core/service/PropertyAssignmentService.kt | 2 +- .../core/service/BluePrintRuntimeServiceTest.kt | 14 +++++++- 4 files changed, 49 insertions(+), 27 deletions(-) (limited to 'components/core/src') diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt index 6a50680e..8caec75f 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt @@ -16,15 +16,15 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.databind.node.ObjectNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager /** * @@ -34,12 +34,6 @@ import com.att.eelf.configuration.EELFManager object BluePrintExpressionService { val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - @JvmStatic - fun getExpressionData(propertyAssignment: Any): ExpressionData { - val propertyAssignmentNode: JsonNode = JacksonUtils.jsonNodeFromObject(propertyAssignment) - return getExpressionData(propertyAssignmentNode) - } - @JvmStatic fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData { log.trace("Assignment Data/Expression : {}", propertyAssignmentNode) @@ -53,19 +47,19 @@ object BluePrintExpressionService { expressionData.expressionNode = propertyAssignmentNode when (expressionData.command) { - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT -> { + BluePrintConstants.EXPRESSION_GET_INPUT -> { expressionData.inputExpression = populateInputExpression(propertyAssignmentNode) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY -> { + BluePrintConstants.EXPRESSION_GET_PROPERTY -> { expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { + BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode) } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 5540047c..bd19ae47 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -67,6 +67,12 @@ interface BluePrintRuntimeService { */ fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap + fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capability: String): MutableMap + + fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap + fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap @@ -193,17 +199,15 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) - val propertyAssignments: MutableMap = - nodeTemplate.properties as MutableMap + val propertyAssignments: MutableMap = nodeTemplate.properties!! // Get the Node Type Definitions - val nodeTypeProperties: MutableMap = - bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!! + val nodeTypeProperties: MutableMap = bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!! // Iterate Node Type Properties nodeTypeProperties.forEach { nodeTypePropertyName, nodeTypeProperty -> // Get the Express or Value for the Node Template - val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName] + val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] var resolvedValue: JsonNode = NullNode.getInstance() if (propertyAssignment != null) { @@ -223,6 +227,18 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl return propertyAssignmentValue } + override fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String): + MutableMap { + log.info("resolveNodeTemplateCapabilityProperties for node template($nodeTemplateName) capability " + + "($capabilityName)") + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap { + log.info("resolveNodeTemplateRequirementProperties for node template($nodeTemplateName) requirement ($requirementName)") + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + override fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap { log.info("resolveNodeTemplateInterfaceOperationInputs for node template ({}),interface name ({}), " + @@ -230,8 +246,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val propertyAssignmentValue: MutableMap = hashMapOf() - val propertyAssignments: MutableMap = - bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap + val propertyAssignments: MutableMap = + bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) ?: hashMapOf() val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type @@ -245,7 +261,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl // Iterate Node Type Properties nodeTypeInterfaceOperationInputs.forEach { nodeTypePropertyName, nodeTypeProperty -> // Get the Express or Value for the Node Template - val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName] + val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] var resolvedValue: JsonNode = NullNode.getInstance() if (propertyAssignment != null) { @@ -275,8 +291,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val propertyAssignmentValue: MutableMap = hashMapOf() - val propertyAssignments: MutableMap = - bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap + val propertyAssignments: MutableMap = + bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) ?: hashMapOf() val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type @@ -289,7 +305,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty -> // Get the Express or Value for the Node Template - val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName] + val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] var resolvedValue: JsonNode = NullNode.getInstance() if (propertyAssignment != null) { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt index 36c141f5..17380fc0 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -47,7 +47,7 @@ If Property Assignment is Expression. */ fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String, - assignment: Any): JsonNode { + assignment: JsonNode): JsonNode { val valueNode: JsonNode log.trace("Assignment ({})", assignment) val expressionData = BluePrintExpressionService.getExpressionData(assignment) diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 7ecf44b6..1dfb89a5 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -55,6 +55,18 @@ class BluePrintRuntimeServiceTest { assertNotNull(propContext, "Failed to populate interface property values") } + @Test + fun testResolveNodeTemplateCapabilityProperties() { + log.info("************************ testResolveNodeTemplateRequirementProperties **********************") + //TODO + } + + @Test + fun testResolveNodeTemplateRequirementProperties() { + log.info("************************ testResolveNodeTemplateRequirementProperties **********************") + //TODO + } + @Test fun testResolveNodeTemplateInterfaceOperationInputs() { log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************") @@ -72,7 +84,7 @@ class BluePrintRuntimeServiceTest { assertNotNull(inContext, "Failed to populate interface input property values") assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name") - } + } @Test fun testResolveNodeTemplateInterfaceOperationOutputs() { -- cgit 1.2.3-korg