Merge "Controller Blueprints Microservice"
authorDan Timoney <dt5972@att.com>
Tue, 4 Sep 2018 14:53:25 +0000 (14:53 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 4 Sep 2018 14:53:25 +0000 (14:53 +0000)
ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java [deleted file]
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt [new file with mode: 0644]
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt [moved from ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt with 91% similarity]
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java [moved from ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java with 85% similarity]
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
ms/controllerblueprints/modules/resource-dict/src/test/resources/data/resource-assignment-input.json [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionValidationService.java [moved from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java with 77% similarity]
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java

index b03fdf9..5a8d542 100644 (file)
@@ -26,6 +26,7 @@ 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 org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
 import org.slf4j.Logger\r
 import org.slf4j.LoggerFactory\r
 /**\r
@@ -33,14 +34,14 @@ import org.slf4j.LoggerFactory
  *\r
  * @author Brinda Santh\r
  */\r
-class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var context: MutableMap<String, Any> = hashMapOf()) {\r
+open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var context: MutableMap<String, Any> = hashMapOf()) {\r
 \r
     private val logger: Logger = LoggerFactory.getLogger(this::class.toString())\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, Any?> {\r
+    open fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, Any?> {\r
         logger.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName)\r
         val propertyAssignmentValue: MutableMap<String, Any?> = hashMapOf()\r
 \r
@@ -76,7 +77,7 @@ class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var contex
         return propertyAssignmentValue\r
     }\r
 \r
-    fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String,\r
+    open fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String,\r
                                                     interfaceName: String, operationName: String): MutableMap<String, Any?> {\r
         logger.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " +\r
                 "operationName({})", nodeTemplateName, interfaceName, operationName)\r
@@ -105,7 +106,7 @@ class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var contex
             var resolvedValue: JsonNode = NullNode.getInstance()\r
             if (propertyAssignment != null) {\r
                 // Resolve the Expressing\r
-                val propertyAssignmentExpression = PropertyAssignmentService( context, this)\r
+                val propertyAssignmentExpression = PropertyAssignmentService(context, this)\r
                 resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)\r
             } else {\r
                 // Assign default value to the Operation\r
@@ -122,8 +123,8 @@ class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var contex
     }\r
 \r
 \r
-    fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String,\r
-                                                     interfaceName: String, operationName: String, componentContext: MutableMap<String, Any?>): Unit {\r
+    open fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String,\r
+                                                     interfaceName: String, operationName: String, componentContext: MutableMap<String, Any?>) {\r
         logger.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " +\r
                 "operationName({})", nodeTemplateName, interfaceName, operationName)\r
 \r
@@ -150,125 +151,127 @@ class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var contex
         }\r
     }\r
 \r
-    fun resolveNodeTemplateArtifact(nodeTemplateName: String,\r
+    open 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(context, this)\r
         return propertyAssignmentExpression.artifactContent(artifactDefinition)\r
     }\r
 \r
 \r
-    fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode): Unit {\r
-        val path = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_INPUTS)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) {\r
+        val path = StringBuilder(BluePrintConstants.PATH_INPUTS)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
         logger.trace("setting input path ({}), values ({})", path, value)\r
         context[path] = value\r
     }\r
 \r
-    fun setWorkflowInputValue(workflowName: String, propertyName: String, value: JsonNode): Unit {\r
-        val path: String = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_NODE_WORKFLOWS).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(workflowName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_INPUTS)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_PROPERTIES)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open fun setWorkflowInputValue(workflowName: String, propertyName: String, 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
     }\r
 \r
-    fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode): Unit {\r
+    open fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) {\r
 \r
-        val path: String = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_NODE_TEMPLATES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_PROPERTIES)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\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
     }\r
 \r
-    fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
-                                              value: JsonNode): Unit {\r
-        val path: String = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_NODE_TEMPLATES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_INTERFACES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(interfaceName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_OPERATIONS).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(operationName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_PROPERTIES)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open 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
         logger.trace("setting operation property path ({}), values ({})", path, value)\r
         context[path] = value\r
     }\r
 \r
-    fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
-                                           value: JsonNode): Unit {\r
-        val path: String = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_NODE_TEMPLATES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_INTERFACES).append(interfaceName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_OPERATIONS).append(operationName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_INPUTS)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_PROPERTIES)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open 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(interfaceName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).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
     }\r
 \r
-    fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
-                                            value: JsonNode): Unit {\r
-        val path: String = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_NODE_TEMPLATES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_INTERFACES).append(interfaceName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_OPERATIONS).append(operationName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_OUTPUTS)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_PROPERTIES)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open 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(interfaceName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).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
     }\r
 \r
 \r
-    fun getInputValue(propertyName: String): JsonNode {\r
-        val path = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_INPUTS)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open 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
     }\r
 \r
-    fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode {\r
-        val path: String = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_NODE_TEMPLATES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_INTERFACES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(interfaceName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_OPERATIONS).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(operationName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_PROPERTIES)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open 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_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
         return context[path] as JsonNode\r
     }\r
 \r
-    fun getPropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? {\r
-        val path: String = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_NODE_TEMPLATES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_PROPERTIES)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open fun getPropertyValue(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
     }\r
 \r
-    fun getRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: String): JsonNode? {\r
-        val path: String = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_NODE_TEMPLATES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_REQUIREMENTS).append(requirementName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_PROPERTIES)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open fun getRequirementPropertyValue(nodeTemplateName: String, requirementName: 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_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
     }\r
 \r
-    fun getCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: String): JsonNode? {\r
-        val path: String = StringBuilder(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_NODE_TEMPLATES).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_CAPABILITIES).append(capabilityName)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_PROPERTIES)\r
-                .append(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+    open fun getCapabilityPropertyValue(nodeTemplateName: String, capabilityName: 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_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
     }\r
 \r
-    fun assignInputs(jsonNode: JsonNode): Unit {\r
+    open fun assignInputs(jsonNode: JsonNode) {\r
         logger.info("assignInputs from input JSON ({})", jsonNode.toString())\r
         bluePrintContext.inputs?.forEach { propertyName, property ->\r
-            val valueNode: JsonNode = jsonNode.at("/" + propertyName) ?: NullNode.getInstance()\r
+            val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
+                    ?: NullNode.getInstance()\r
             setInputValue(propertyName, property, valueNode)\r
         }\r
     }\r
 \r
-    fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode): Unit {\r
+    open fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) {\r
         logger.info("assign workflow {} input value ({})", workflowName, jsonNode.toString())\r
         bluePrintContext.workflowByName(workflowName)?.inputs?.forEach { propertyName, property ->\r
-            val valueNode: JsonNode = jsonNode.at("/" + propertyName) ?: NullNode.getInstance()\r
+            val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
+                    ?: NullNode.getInstance()\r
             setWorkflowInputValue(workflowName, propertyName, valueNode)\r
         }\r
     }\r
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
deleted file mode 100644 (file)
index 48b89bd..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*\r
- *  Copyright Â© 2017-2018 AT&T Intellectual Property.\r
- *  Modifications Copyright Â© 2018 IBM.\r
- *\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *  You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict;\r
-\r
-public class ResourceDictionaryConstants {\r
-    public static final String SOURCE_INPUT= "input";\r
-    public static final String SOURCE_DEFAULT = "default";\r
-    public static final String SOURCE_DB = "db";\r
-    public static final String SOURCE_MDSAL = "mdsal";\r
-\r
-    public static final String PROPERTY_TYPE = "type";\r
-    public static final String PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping";\r
-    public static final String PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping";\r
-    public static final String PROPERTY_KEY_DEPENDENCIES = "key-dependencies";\r
-}\r
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
new file mode 100644 (file)
index 0000000..9b89f6f
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  Copyright Â© 2018 IBM.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict
+/**
+ * ResourceDictionaryConstants
+ *
+ * @author Brinda Santh
+ */
+object ResourceDictionaryConstants {
+    const val SOURCE_INPUT = "input"
+    const val SOURCE_DEFAULT = "default"
+    const val SOURCE_DB = "db"
+
+    const val PROPERTY_TYPE = "type"
+    const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping"
+    const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping"
+    const val PROPERTY_KEY_DEPENDENCIES = "key-dependencies"
+}
\ No newline at end of file
@@ -32,24 +32,24 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
 import org.slf4j.LoggerFactory
 import java.io.Serializable
 /**
- * ResourceDictionaryValidationService.
+ * ResourceDefinitionValidationService.
  *
  * @author Brinda Santh
  */
-interface ResourceDictionaryValidationService : Serializable {
+interface ResourceDefinitionValidationService : Serializable {
 
     @Throws(BluePrintException::class)
     fun validate(resourceDefinition: ResourceDefinition)
 
 }
 /**
- * ResourceDictionaryDefaultValidationService.
+ * ResourceDefinitionValidationService.
  *
  * @author Brinda Santh
  */
-open class ResourceDictionaryDefaultValidationService(private val bluePrintRepoService: BluePrintRepoService) : ResourceDictionaryValidationService {
+open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService {
 
-    private val log = LoggerFactory.getLogger(ResourceDictionaryDefaultValidationService::class.java)
+    private val log = LoggerFactory.getLogger(ResourceDefinitionValidationService::class.java)
 
     override fun validate(resourceDefinition: ResourceDefinition) {
         Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition")
@@ -90,7 +90,7 @@ open class ResourceDictionaryDefaultValidationService(private val bluePrintRepoS
 
     open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) {
         val propertyType = propertyDefinition.type
-        var isValid = false
+        val isValid : Boolean
 
         if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
             isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
@@ -102,8 +102,7 @@ open class ResourceDictionaryDefaultValidationService(private val bluePrintRepoS
             bluePrintRepoService.getDataType(propertyType)
                     ?: throw BluePrintException(format("property({}) defined of data type({}) is not in repository",
                             propertyName, propertyType))
-
-            isValid = true;
+            isValid = true
         }
 
         check(isValid) {
index e08c09c..733a443 100644 (file)
 
 package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils
 
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.NullNode
 import org.apache.commons.collections.MapUtils
 import org.apache.commons.lang3.StringUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
@@ -59,4 +62,16 @@ object ResourceDictionaryUtils {
         }
         return source
     }
+
+    @JvmStatic
+    fun assignInputs(data: JsonNode, context: MutableMap<String, Any>) {
+        log.trace("assignInputs from input JSON ({})", data.toString())
+        data.fields().forEach { field ->
+            val valueNode: JsonNode = data.at("/".plus(field.key)) ?: NullNode.getInstance()
+
+            val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(field.key)
+            log.trace("setting path ({}), values ({})", path, valueNode)
+            context[path] = valueNode
+        }
+    }
 }
\ No newline at end of file
@@ -22,10 +22,10 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileSe
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
 
-public class ResourceDictionaryValidationServiceTest {
+public class ResourceDefinitionValidationServiceTest {
     private String basePath = "load/model_type";
-    String dictionaryPath = "load/resource_dictionary";
-    BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath);
+    private String dictionaryPath = "load/resource_dictionary";
+    private BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath);
 
     @Test
     public void testValidateSource() throws Exception {
@@ -48,8 +48,8 @@ public class ResourceDictionaryValidationServiceTest {
         ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
         Assert.assertNotNull("Failed to populate dictionaryDefinition for  type", resourceDefinition);
 
-        ResourceDictionaryValidationService resourceDictionaryValidationService =
-                new ResourceDictionaryDefaultValidationService(bluePrintRepoFileService);
+        ResourceDefinitionValidationService resourceDictionaryValidationService =
+                new ResourceDefinitionDefaultValidationService(bluePrintRepoFileService);
         resourceDictionaryValidationService.validate(resourceDefinition);
         Assert.assertNotNull(String.format("Failed to populate dictionaryDefinition for : %s", fileName), resourceDefinition);
     }
index 2a207e0..5c22f65 100644 (file)
 package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;\r
 \r
 \r
+import com.fasterxml.jackson.databind.JsonNode;\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
@@ -76,4 +79,16 @@ public class ResourceDictionaryUtilsTest {
 \r
     }\r
 \r
+    @Test\r
+    public void testAssignInputs() {\r
+        JsonNode data = JacksonUtils.jsonNodeFromClassPathFile("data/resource-assignment-input.json");\r
+        Map<String, Object> context = new HashMap<>();\r
+        ResourceDictionaryUtils.assignInputs(data, context);\r
+        String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue");\r
+        log.info("populated context {}", context);\r
+        Assert.assertTrue(String.format("failed to get variable : %s",path),context.containsKey(path));\r
+\r
+    }\r
+\r
+\r
 }\r
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/resources/data/resource-assignment-input.json b/ms/controllerblueprints/modules/resource-dict/src/test/resources/data/resource-assignment-input.json
new file mode 100644 (file)
index 0000000..d79c906
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "intValue" : 1,
+  "floatValue" : 1.34,
+  "booleanValue" : true,
+  "stringValue" : "sample-String",
+  "timeValue" : "2018-09-29",
+  "arrayStringValue" : ["one", "two"],
+  "mapValue" : {"profile_name1":"profile_name1",
+    "profile_name2":"profile_name2"}
+}
\ No newline at end of file
 package org.onap.ccsdk.apps.controllerblueprints.service;
 
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDictionaryDefaultValidationService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionDefaultValidationService;
 import org.springframework.stereotype.Service;
 
 @Service
-public class ResourceDictionaryValidationService extends ResourceDictionaryDefaultValidationService {
+public class ResourceDefinitionValidationService extends ResourceDefinitionDefaultValidationService {
 
-    private BluePrintRepoService bluePrintRepoService;
-
-    public ResourceDictionaryValidationService(BluePrintRepoService bluePrintRepoService) {
+    public ResourceDefinitionValidationService(BluePrintRepoService bluePrintRepoService) {
         super(bluePrintRepoService);
     }
 }
index 85e701b..ccf4ffc 100644 (file)
@@ -18,6 +18,7 @@
 package org.onap.ccsdk.apps.controllerblueprints.service;\r
 \r
 import com.google.common.base.Preconditions;\r
+import org.apache.commons.collections.CollectionUtils;\r
 import org.apache.commons.lang3.StringUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;\r
@@ -43,16 +44,16 @@ public class ResourceDictionaryService {
 \r
     private ResourceDictionaryRepository resourceDictionaryRepository;\r
 \r
-    private ResourceDictionaryValidationService resourceDictionaryValidationService;\r
+    private ResourceDefinitionValidationService resourceDictionaryValidationService;\r
 \r
     /**\r
      * This is a DataDictionaryService, used to save and get the Resource Mapping stored in database\r
      *\r
-     * @param dataDictionaryRepository\r
-     * @param resourceDictionaryValidationService\r
+     * @param dataDictionaryRepository            dataDictionaryRepository\r
+     * @param resourceDictionaryValidationService resourceDictionaryValidationService\r
      */\r
     public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository,\r
-                                     ResourceDictionaryValidationService resourceDictionaryValidationService) {\r
+                                     ResourceDefinitionValidationService resourceDictionaryValidationService) {\r
         this.resourceDictionaryRepository = dataDictionaryRepository;\r
         this.resourceDictionaryValidationService = resourceDictionaryValidationService;\r
     }\r
@@ -60,58 +61,49 @@ public class ResourceDictionaryService {
     /**\r
      * This is a getDataDictionaryByName service\r
      *\r
-     * @param name\r
+     * @param name name\r
      * @return DataDictionary\r
-     * @throws BluePrintException\r
+     * @throws BluePrintException BluePrintException\r
      */\r
     public ResourceDictionary getResourceDictionaryByName(String name) throws BluePrintException {\r
-        if (StringUtils.isNotBlank(name)) {\r
-            return resourceDictionaryRepository.findByName(name).get();\r
+        Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");\r
+        Optional<ResourceDictionary> resourceDictionaryDb = resourceDictionaryRepository.findByName(name);\r
+        if (resourceDictionaryDb.isPresent()) {\r
+            return resourceDictionaryDb.get();\r
         } else {\r
-            throw new BluePrintException("Resource Mapping Name Information is missing.");\r
+            throw new BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name));\r
         }\r
     }\r
 \r
     /**\r
      * This is a searchResourceDictionaryByNames service\r
      *\r
-     * @param names\r
+     * @param names names\r
      * @return List<ResourceDictionary>\r
-     * @throws BluePrintException\r
      */\r
-    public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names)\r
-            throws BluePrintException {\r
-        if (names != null && !names.isEmpty()) {\r
-            return resourceDictionaryRepository.findByNameIn(names);\r
-        } else {\r
-            throw new BluePrintException("No Search Information provide");\r
-        }\r
+    public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names) {\r
+        Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide");\r
+        return resourceDictionaryRepository.findByNameIn(names);\r
     }\r
 \r
     /**\r
      * This is a searchResourceDictionaryByTags service\r
      *\r
-     * @param tags\r
+     * @param tags tags\r
      * @return List<ResourceDictionary>\r
-     * @throws BluePrintException\r
      */\r
-    public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) throws BluePrintException {\r
-        if (StringUtils.isNotBlank(tags)) {\r
-            return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags);\r
-        } else {\r
-            throw new BluePrintException("No Search Information provide");\r
-        }\r
+    public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) {\r
+        Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide");\r
+        return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags);\r
     }\r
 \r
     /**\r
      * This is a saveDataDictionary service\r
      *\r
-     * @param resourceDictionary\r
+     * @param resourceDictionary resourceDictionary\r
      * @return DataDictionary\r
-     * @throws BluePrintException\r
      */\r
-    public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary)\r
-            throws BluePrintException {\r
+    public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) {\r
         Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");\r
         Preconditions.checkArgument(StringUtils.isNotBlank(resourceDictionary.getDefinition()),\r
                 "Resource Dictionary definition information is missing");\r
@@ -130,7 +122,7 @@ public class ResourceDictionaryService {
         PropertyDefinition propertyDefinition = resourceDefinition.getProperty();\r
         resourceDictionary.setDescription(propertyDefinition.getDescription());\r
         resourceDictionary.setDataType(propertyDefinition.getType());\r
-        if(propertyDefinition.getEntrySchema() != null){\r
+        if (propertyDefinition.getEntrySchema() != null) {\r
             resourceDictionary.setEntrySchema(propertyDefinition.getEntrySchema().getType());\r
         }\r
 \r
@@ -164,15 +156,10 @@ public class ResourceDictionaryService {
     /**\r
      * This is a deleteResourceDictionary service\r
      *\r
-     * @param name\r
-     * @throws BluePrintException\r
+     * @param name name\r
      */\r
-    public void deleteResourceDictionary(String name) throws BluePrintException {\r
-        if (name != null) {\r
-            resourceDictionaryRepository.deleteByName(name);\r
-        } else {\r
-            throw new BluePrintException("Resource Mapping Id Information is missing.");\r
-        }\r
-\r
+    public void deleteResourceDictionary(String name) {\r
+        Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");\r
+        resourceDictionaryRepository.deleteByName(name);\r
     }\r
 }\r