Resource Resoulution Service 43/75643/4
authorSingal, Kapil (ks220y) <ks220y@att.com>
Thu, 10 Jan 2019 17:50:06 +0000 (12:50 -0500)
committerSingal, Kapil (ks220y) <ks220y@att.com>
Fri, 11 Jan 2019 15:08:58 +0000 (10:08 -0500)
Implement Input Resource Resolution Processor Service along with Resource Resolution Utilities

Change-Id: Ibb4899e415f4b79cd6cd1b190b0f4969b09c3fe4
Issue-ID: CCSDK-936
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
23 files changed:
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt
ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java

index 0187445..58a8207 100644 (file)
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
  */\r
-\r
 package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
 \r
 import com.att.eelf.configuration.EELFLogger\r
@@ -22,6 +21,9 @@ import com.att.eelf.configuration.EELFManager
 import com.fasterxml.jackson.annotation.JsonInclude\r
 import com.fasterxml.jackson.core.type.TypeReference\r
 import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.ArrayNode\r
+import com.fasterxml.jackson.databind.node.NullNode\r
+import com.fasterxml.jackson.databind.node.ObjectNode\r
 import com.fasterxml.jackson.databind.SerializationFeature\r
 import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
 import kotlinx.coroutines.Dispatchers\r
@@ -40,241 +42,209 @@ import java.nio.charset.Charset
  *\r
  * @author Brinda Santh\r
  */\r
-object JacksonUtils {\r
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
-\r
-    inline fun <reified T : Any> readValue(content: String): T =\r
-            jacksonObjectMapper().readValue(content, T::class.java)\r
+class JacksonUtils {\r
+    companion object {\r
+        private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+        inline fun <reified T : Any> readValue(content: String): T =\r
+                jacksonObjectMapper().readValue(content, T::class.java)\r
+\r
+        fun <T> readValue(content: String, valueType: Class<T>): T? {\r
+            return jacksonObjectMapper().readValue(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> readValue(content: String, valueType: Class<T>): T? {\r
-        return jacksonObjectMapper().readValue(content, valueType)\r
-    }\r
+        fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {\r
+            return jacksonObjectMapper().treeToValue(node, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {\r
-        return jacksonObjectMapper().treeToValue(node, valueType)\r
-    }\r
+        fun getContent(fileName: String): String = runBlocking {\r
+            async {\r
+                try {\r
+                    File(fileName).readText(Charsets.UTF_8)\r
+                } catch (e: Exception) {\r
+                    throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")\r
+                }\r
+            }.await()\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getContent(fileName: String): String = runBlocking {\r
-        async {\r
-            try {\r
-                File(fileName).readText(Charsets.UTF_8)\r
-            } catch (e: Exception) {\r
-                throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")\r
+        fun getClassPathFileContent(fileName: String): String {\r
+            return runBlocking {\r
+                withContext(Dispatchers.Default) {\r
+                    IOUtils.toString(JacksonUtils::class.java.classLoader\r
+                            .getResourceAsStream(fileName), Charset.defaultCharset())\r
+                }\r
             }\r
-        }.await()\r
-    }\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getClassPathFileContent(fileName: String): String {\r
-        return runBlocking {\r
-            withContext(Dispatchers.Default) {\r
-                IOUtils.toString(JacksonUtils::class.java.classLoader\r
-                        .getResourceAsStream(fileName), Charset.defaultCharset())\r
-            }\r
+        fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {\r
+            val content: String = getContent(fileName)\r
+            return readValue(content, valueType)\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {\r
-        val content: String = getContent(fileName)\r
-        return readValue(content, valueType)\r
-    }\r
+        fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {\r
+            val content: String = getClassPathFileContent(fileName)\r
+            return readValue(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {\r
-        val content: String = getClassPathFileContent(fileName)\r
-        return readValue(content, valueType)\r
-    }\r
+        fun jsonNodeFromObject(from: kotlin.Any): JsonNode {\r
+            return jacksonObjectMapper().convertValue(from, JsonNode::class.java)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java)\r
+        fun jsonNodeFromClassPathFile(fileName: String): JsonNode {\r
+            val content: String = getClassPathFileContent(fileName)\r
+            return jsonNode(content)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun jsonNodeFromClassPathFile(fileName: String): JsonNode {\r
-        val content: String = getClassPathFileContent(fileName)\r
-        return jsonNode(content)\r
-    }\r
+        fun jsonNodeFromFile(fileName: String): JsonNode {\r
+            val content: String = getContent(fileName)\r
+            return jsonNode(content)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun jsonNodeFromFile(fileName: String): JsonNode {\r
-        val content: String = getContent(fileName)\r
-        return jsonNode(content)\r
-    }\r
+        fun jsonNode(content: String): JsonNode {\r
+            return jacksonObjectMapper().readTree(content)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun jsonNode(content: String): JsonNode {\r
-        return jacksonObjectMapper().readTree(content)\r
-    }\r
+        fun getJson(any: kotlin.Any): String {\r
+            return getJson(any, false)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getJson(any: kotlin.Any): String {\r
-        return getJson(any, false)\r
-    }\r
+        fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {\r
+            val wrapperMap = hashMapOf<String, Any>()\r
+            wrapperMap[wrapper] = any\r
+            return getJson(wrapperMap, pretty)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {\r
-        val wrapperMap = hashMapOf<String, Any>()\r
-        wrapperMap[wrapper] = any\r
-        return getJson(wrapperMap, pretty)\r
-    }\r
+        fun getJson(any: kotlin.Any, pretty: Boolean = false): String {\r
+            val objectMapper = jacksonObjectMapper()\r
+            objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)\r
+            if (pretty) {\r
+                objectMapper.enable(SerializationFeature.INDENT_OUTPUT)\r
+            }\r
+            return objectMapper.writeValueAsString(any)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getJson(any: kotlin.Any, pretty: Boolean = false): String {\r
-        val objectMapper = jacksonObjectMapper()\r
-        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)\r
-        if (pretty) {\r
-            objectMapper.enable(SerializationFeature.INDENT_OUTPUT)\r
+        fun getJsonNode(any: kotlin.Any?, pretty: Boolean = false): JsonNode {\r
+            val objectMapper = jacksonObjectMapper()\r
+            objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)\r
+            if (pretty) {\r
+                objectMapper.enable(SerializationFeature.INDENT_OUTPUT)\r
+            }\r
+            return objectMapper.valueToTree(any)\r
         }\r
-        return objectMapper.writeValueAsString(any)\r
-    }\r
 \r
-    @JvmStatic\r
-    fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {\r
-        return getListFromJson(node.toString(), valueType)\r
-    }\r
+        fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {\r
+            return getListFromJson(node.toString(), valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {\r
-        val objectMapper = jacksonObjectMapper()\r
-        val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)\r
-        return objectMapper.readValue<List<T>>(content, javaType)\r
-    }\r
+        fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {\r
+            val objectMapper = jacksonObjectMapper()\r
+            val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)\r
+            return objectMapper.readValue<List<T>>(content, javaType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {\r
-        val content: String = getContent(fileName)\r
-        return getListFromJson(content, valueType)\r
-    }\r
+        fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {\r
+            val content: String = getContent(fileName)\r
+            return getListFromJson(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {\r
-        val content: String = getClassPathFileContent(fileName)\r
-        return getListFromJson(content, valueType)\r
-    }\r
+        fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {\r
+            val content: String = getClassPathFileContent(fileName)\r
+            return getListFromJson(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {\r
-        val objectMapper = jacksonObjectMapper()\r
-        val typeRef = object : TypeReference<MutableMap<String, T>>() {}\r
-        return objectMapper.readValue(content, typeRef)\r
-    }\r
+        fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {\r
+            val objectMapper = jacksonObjectMapper()\r
+            val typeRef = object : TypeReference<MutableMap<String, T>>() {}\r
+            return objectMapper.readValue(content, typeRef)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {\r
-        val content: String = getContent(fileName)\r
-        return getMapFromJson(content, valueType)\r
-    }\r
+        fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {\r
+            val content: String = getContent(fileName)\r
+            return getMapFromJson(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {\r
-        if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
-            return checkJsonNodeValueOfPrimitiveType(type, jsonNode)\r
-        } else if (BluePrintTypes.validCollectionTypes().contains(type)) {\r
-            return checkJsonNodeValueOfCollectionType(type, jsonNode)\r
+        fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {\r
+            if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
+                return checkJsonNodeValueOfPrimitiveType(type, jsonNode)\r
+            } else if (BluePrintTypes.validCollectionTypes().contains(type)) {\r
+                return checkJsonNodeValueOfCollectionType(type, jsonNode)\r
+            }\r
+            return false\r
         }\r
-        return false\r
-    }\r
 \r
-    @JvmStatic\r
-    fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {\r
-        when (primitiveType) {\r
-            BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual\r
-            BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean\r
-            BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt\r
-            BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble\r
-            BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual\r
-            else -> return false\r
+        fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble\r
+                BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual\r
+                else -> return false\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {\r
-        when (type) {\r
-            BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray\r
-            BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode\r
-            else -> return false\r
+        fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {\r
+            when (type) {\r
+                BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray\r
+                BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode\r
+                else -> return false\r
+            }\r
         }\r
 \r
-    }\r
-/*\r
-    @JvmStatic\r
-    fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {\r
-        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
-            objectNode.put(key, value as Boolean)\r
-        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
-            objectNode.put(key, value as Int)\r
-        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
-            objectNode.put(key, value as Float)\r
-        } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {\r
-            objectNode.put(key, value as String)\r
-        } else {\r
-            objectNode.put(key, value as String)\r
+        fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float)\r
+                BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String)\r
+                else -> objectNode.put(key, value as String)\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun populatePrimitiveValues(value: Any, primitiveType: String, objectNode: ArrayNode) {\r
-        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
-            objectNode.add(value as Boolean)\r
-        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
-            objectNode.add(value as Int)\r
-        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
-            objectNode.add(value as Float)\r
-        } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {\r
-            objectNode.add(value as String)\r
-        } else {\r
-            objectNode.add(value as String)\r
+        fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float)\r
+                BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String)\r
+                else -> arrayNode.add(value as String)\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {\r
-        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
-            objectNode.put(key, false)\r
-        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
-            objectNode.put(key, 0)\r
-        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
-            objectNode.put(key, 0.0)\r
-        } else {\r
-            objectNode.put(key, "")\r
+        fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0)\r
+                else -> objectNode.put(key, "")\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {\r
-        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
-            arrayNode.add(false)\r
-        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
-            arrayNode.add(0)\r
-        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
-            arrayNode.add(0.0)\r
-        } else {\r
-            arrayNode.add("")\r
+        fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0)\r
+                else -> arrayNode.add("")\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {\r
-        if (nodeValue == null || nodeValue is NullNode) {\r
-            objectNode.set(key, nodeValue)\r
-        } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
-            if (BluePrintConstants.DATA_TYPE_BOOLEAN == type) {\r
-                objectNode.put(key, nodeValue.asBoolean())\r
-            } else if (BluePrintConstants.DATA_TYPE_INTEGER == type) {\r
-                objectNode.put(key, nodeValue.asInt())\r
-            } else if (BluePrintConstants.DATA_TYPE_FLOAT == type) {\r
-                objectNode.put(key, nodeValue.floatValue())\r
-            } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == type) {\r
-                objectNode.put(key, nodeValue.asText())\r
+        fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {\r
+            if (nodeValue == null || nodeValue is NullNode) {\r
+                objectNode.set(key, nodeValue)\r
+            } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
+                populatePrimitiveValues(key, nodeValue, type, objectNode)\r
             } else {\r
-                objectNode.put(key, nodeValue.asText())\r
+                objectNode.set(key, nodeValue)\r
+            }\r
+        }\r
+\r
+        fun convertPrimitiveResourceValue(type: String, value: String): JsonNode? {\r
+            when (type) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> return JacksonUtils.getJsonNode(value as Boolean)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> return JacksonUtils.getJsonNode(value as Int)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> return JacksonUtils.getJsonNode(value as Float)\r
+                else -> return JacksonUtils.getJsonNode(value)\r
             }\r
-        } else {\r
-            objectNode.set(key, nodeValue)\r
         }\r
     }\r
-    */\r
 }
\ No newline at end of file
index 1dfb89a..c01b14b 100644 (file)
@@ -26,8 +26,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 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 org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
 import kotlin.test.assertEquals\r
 import kotlin.test.assertNotNull\r
 \r
@@ -47,7 +46,7 @@ class BluePrintRuntimeServiceTest {
 \r
         val inputDataPath = "src/test/resources/data/default-context.json"\r
 \r
-        val inputNode: JsonNode = jsonNodeFromFile(inputDataPath)\r
+        val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath)\r
         bluePrintRuntimeService.assignInputs(inputNode)\r
 \r
         val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process")\r
@@ -82,9 +81,9 @@ class BluePrintRuntimeServiceTest {
                 "ResourceAssignmentComponent", "process")\r
 \r
         assertNotNull(inContext, "Failed to populate interface input property values")\r
-        assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")\r
-        assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name")\r
-    }\r
+        assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")\r
+        assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name")\r
+      }\r
 \r
     @Test\r
     fun testResolveNodeTemplateInterfaceOperationOutputs() {\r
@@ -113,9 +112,9 @@ class BluePrintRuntimeServiceTest {
         val bluePrintRuntimeService = getBluePrintRuntimeService()\r
 \r
         bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1",\r
-                jsonNodeFromObject("context1-value"))\r
+                JacksonUtils.jsonNodeFromObject("context1-value"))\r
         bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2",\r
-                jsonNodeFromObject("context2-value"))\r
+                JacksonUtils.jsonNodeFromObject("context2-value"))\r
 \r
         val keys = listOf("context1", "context2")\r
 \r
index 7d850f2..6d771cd 100644 (file)
           "required": true,
           "type": "string"
         },
+        "service-instance-id": {
+          "required": true,
+          "type": "string"
+        },
+        "vnf-id": {
+          "required": true,
+          "type": "string"
+        },
         "action-name": {
           "required": true,
           "type": "string"
         "hostname": {
           "required": true,
           "type": "string"
+        },
+        "vnf_name": {
+          "required": true,
+          "type": "string"
         }
       },
       "derived_from": "tosca.datatypes.Dynamic"
index fde8000..cb39200 100644 (file)
@@ -31,7 +31,7 @@ public class ResourceDefinitionTest {
     public void testDictionaryDefinitionInputSource(){\r
 \r
         String fileName = basePath + "/input-source.json";\r
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);\r
         Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition);\r
     }\r
 \r
@@ -39,7 +39,7 @@ public class ResourceDefinitionTest {
     public void testDictionaryDefinitionDefaultSource(){\r
 \r
         String fileName = basePath + "/default-source.json";\r
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);\r
         Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition);\r
     }\r
 \r
@@ -47,14 +47,14 @@ public class ResourceDefinitionTest {
     public void testDictionaryDefinitionDBSource(){\r
 \r
         String fileName = basePath + "/db-source.json";\r
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);\r
         Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);\r
     }\r
 \r
     @Test\r
     public void testDictionaryDefinitionMDSALSource(){\r
         String fileName = basePath + "/mdsal-source.json";\r
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);\r
         Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition);\r
     }\r
 }\r
index 2b68585..f5c3567 100644 (file)
@@ -45,7 +45,7 @@ public class ResourceDefinitionValidationServiceTest {
 
     private void testValidate(String fileName) throws Exception {
 
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
         Assert.assertNotNull("Failed to populate dictionaryDefinition for  type", resourceDefinition);
 
         ResourceDefinitionValidationService resourceDictionaryValidationService =
index c7444db..a2c2310 100644 (file)
@@ -30,7 +30,7 @@ public class BulkResourceSequencingUtilsTest {
 \r
     @Test\r
     public void testProcess(){\r
-        List<ResourceAssignment> assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);\r
+        List<ResourceAssignment> assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);\r
         Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments);\r
         BulkResourceSequencingUtils.process(assignments);\r
     }\r
index 13bf819..fa24138 100644 (file)
@@ -86,7 +86,7 @@ public class ResourceDictionaryUtilsTest {
 \r
     @Test\r
     public void testAssignInputs() {\r
-        JsonNode data = JacksonUtils.jsonNodeFromClassPathFile("data/resource-assignment-input.json");\r
+        JsonNode data = JacksonUtils.Companion.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
index 66c919d..341ede5 100644 (file)
@@ -20,6 +20,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractCompon
 import org.python.core.PyObject
 import org.python.util.PythonInterpreter
 import org.slf4j.LoggerFactory
+import java.io.File
 import java.util.*
 
 class PythonExecutorUtils {
@@ -61,9 +62,9 @@ class PythonExecutorUtils {
             sb.append(System.getProperty("java.class.path"))
 
             for (p in pythonPath) {
-                sb.append(":").append(p)
+                sb.append(File.pathSeparator).append(p)
             }
-            log.debug("Paths : $sb")
+            log.debug("Python Paths : $sb")
 
             props["python.import.site"] = "true"
             props.setProperty("python.path", sb.toString())
index 431c6b8..c4fd546 100644 (file)
@@ -30,7 +30,7 @@ class PythonExecutorUtilsTest {
     @Test
     fun testGetPythonComponent() {
 
-        val pythonPath: MutableList<String> = arrayListOf()
+        val pythonPath: MutableList<String> = mutableListOf()
         pythonPath.add("./../../../../components/scripts/python/ccsdk_blueprints")
 
         val properties: MutableMap<String, Any> = hashMapOf()
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json
new file mode 100644 (file)
index 0000000..7142f04
--- /dev/null
@@ -0,0 +1,31 @@
+{\r
+  "actionIdentifiers": {\r
+    "actionName": "activate",\r
+    "blueprintName": "baseconfiguration",\r
+    "blueprintVersion": "1.0.0",\r
+    "mode": "sync"\r
+  },\r
+  "commonHeader": {\r
+    "flags": {\r
+      "force": true,\r
+      "ttl": 3600\r
+    },\r
+    "originatorId": "sdnc",\r
+    "requestId": "123456-1000",\r
+    "subRequestId": "sub-123456-1000",\r
+    "timestamp": "2012-04-23T18:25:43.511Z"\r
+  },\r
+  "payload": {\r
+    "resource-assignment-request": {\r
+      "resource-assignment-properties": {\r
+        "request-id": "1234",\r
+        "service-instance-id": "siid_1234",\r
+        "vnf-id": "vnf_1234",\r
+        "action-name": "assign-activate",\r
+        "scope-type": "vnf-type",\r
+        "hostname": "localhost",\r
+        "vnf_name": "temp_vnf"\r
+      }\r
+    }\r
+  }\r
+}\r
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt
new file mode 100644 (file)
index 0000000..9d6f4a6
--- /dev/null
@@ -0,0 +1,58 @@
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
+\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService\r
+\r
+class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)\r
+    : DefaultBluePrintRuntimeService(id, bluePrintContext){\r
+\r
+    private var resourceResolutionStore: MutableMap<String, JsonNode> = hashMapOf()\r
+\r
+    override fun getExecutionContext(): MutableMap<String, JsonNode> {\r
+        return resourceResolutionStore\r
+    }\r
+\r
+    @Suppress("UNCHECKED_CAST")\r
+    override fun setExecutionContext(executionContext: MutableMap<String, JsonNode>) {\r
+        this.resourceResolutionStore = executionContext\r
+    }\r
+\r
+    override fun put(key: String, value: JsonNode) {\r
+        resourceResolutionStore[key] = value\r
+    }\r
+\r
+    override fun get(key: String): JsonNode {\r
+        return resourceResolutionStore[key] ?: throw BluePrintProcessorException("failed to get execution property($key)")\r
+    }\r
+\r
+    override fun check(key: String): Boolean {\r
+        return resourceResolutionStore.containsKey(key)\r
+    }\r
+\r
+    override fun cleanRuntime() {\r
+        resourceResolutionStore.clear()\r
+    }\r
+\r
+    private fun getJsonNode(key: String): JsonNode {\r
+        return get(key)\r
+    }\r
+\r
+    override fun getAsString(key: String): String? {\r
+        return get(key).asText()\r
+    }\r
+\r
+    override fun getAsBoolean(key: String): Boolean? {\r
+        return get(key).asBoolean()\r
+    }\r
+\r
+    override fun getAsInt(key: String): Int? {\r
+        return get(key).asInt()\r
+    }\r
+\r
+    override fun getAsDouble(key: String): Double? {\r
+        return get(key).asDouble()\r
+    }\r
+\r
+}\r
index 9d47600..ccf3aee 100644 (file)
 
 package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
 
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceResolutionUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.*
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
 import org.springframework.stereotype.Service
+import com.fasterxml.jackson.databind.node.NullNode
 
 /**
  * InputResourceAssignmentProcessor
@@ -33,6 +36,20 @@ open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
     }
 
     override fun process(executionRequest: ResourceAssignment) {
+        try {
+            if (checkNotEmpty(executionRequest.name)) {
+                val value = bluePrintRuntimeService!!.getInputValue(executionRequest.name)
+                // if value is null don't call setResourceDataValue to populate the value
+                if (value != null && value !is NullNode) {
+                    ResourceResolutionUtils.setResourceDataValue(executionRequest, value)
+                }
+            }
+            // Check the value has populated for mandatory case
+            ResourceResolutionUtils.assertTemplateKeyValueNotNull(executionRequest)
+        } catch (e: Exception) {
+            ResourceResolutionUtils.setFailedResourceDataValue(executionRequest, e.message)
+            throw BluePrintProcessorException("Failed in template key ($executionRequest) assignments with : (${e.message})", e)
+        }
     }
 
     override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
index 6bcd21b..7c59088 100644 (file)
 
 package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils
 
+import java.util.Date
+import org.apache.commons.lang3.StringUtils
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
 import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
+import org.onap.ccsdk.apps.controllerblueprints.core.*
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
 
 class ResourceResolutionUtils {
     companion object {
 
+        private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceResolutionUtils::class.toString())
+
+        @Synchronized
+        @Throws(BluePrintProcessorException::class)
+        fun setResourceDataValue(resourceAssignment: ResourceAssignment, value: Any?) {
+
+            val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" }
+            checkNotEmptyNThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment")
+
+            if (checkNotEmpty(resourceAssignment.dictionaryName)) {
+                resourceAssignment.dictionaryName = resourceAssignment.name
+                logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})")
+            }
+
+            try {
+                if (checkNotEmpty(resourceProp.type)) {
+                    val convertedValue = convertResourceValue(resourceProp.type, value)
+                    logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})")
+                    resourceProp.value = convertedValue
+                    resourceAssignment.updatedDate = Date()
+                    resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
+                    resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS
+                }
+            } catch (e: Exception) {
+                throw BluePrintProcessorException("Failed in setting value for template key (%s) and " +
+                        "dictionary key (${resourceAssignment.name}) of type (${resourceProp.type}) with error message (${e.message})", e)
+            }
+        }
+
+        private fun convertResourceValue(type: String, value: Any?): JsonNode? {
+            var convertedValue: JsonNode?
+
+            if (value == null || value is NullNode) {
+                logger.info("Returning {} value from convertResourceValue", value)
+                return null
+            } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) {
+                convertedValue = JacksonUtils.convertPrimitiveResourceValue(type, value)
+            } else {
+                // Case where Resource is non-primitive type
+                if (value is String) {
+                    convertedValue = JacksonUtils.jsonNode(value)
+                } else {
+                    convertedValue = JacksonUtils.getJsonNode(value)
+                }
+            }
+            return convertedValue
+        }
+
+        @Synchronized
+        fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) {
+            if (checkNotEmpty(resourceAssignment.name)) {
+                resourceAssignment.updatedDate = Date()
+                resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
+                resourceAssignment.status = BluePrintConstants.STATUS_FAILURE
+                resourceAssignment.message = message
+            }
+        }
+
+        @Synchronized
+        @Throws(BluePrintProcessorException::class)
+        fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) {
+            val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" }
+            if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) {
+                logger.error("failed to populate mandatory resource mapping ($resourceAssignment)")
+                throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)")
+            }
+        }
+
+        @Synchronized
+        @Throws(BluePrintProcessorException::class)
+        fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String {
+            var result = "{}"
+            try {
+                val mapper = ObjectMapper()
+                val root = mapper.readTree(result)
+
+                assignments.forEach {
+                    if (checkNotEmpty(it.name) && it.property != null) {
+
+                        val type = it.property?.type
+                        val value = it.property?.value
+                        logger.info("Generating Resource name ({}), type ({}), value ({})", it.name, type,
+                                value)
+                        if (value == null) {
+                            (root as ObjectNode).set(it.name, null)
+                        } else if (value is JsonNode) {
+                            (root as ObjectNode).put(it.name, value as JsonNode)
+                        } else if (BluePrintConstants.DATA_TYPE_STRING.equals(type, ignoreCase = true)) {
+                            (root as ObjectNode).put(it.name, value as String)
+                        } else if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(type, ignoreCase = true)) {
+                            (root as ObjectNode).put(it.name, value as Boolean)
+                        } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(type, ignoreCase = true)) {
+                            (root as ObjectNode).put(it.name, value as Int)
+                        } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(type, ignoreCase = true)) {
+                            (root as ObjectNode).put(it.name, value as Float)
+                        } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(type, ignoreCase = true)) {
+                            (root as ObjectNode).put(it.name, value as String)
+                        } else {
+                            val jsonNode = JacksonUtils.getJsonNode(value)
+                            if (jsonNode != null) {
+                                (root as ObjectNode).put(it.name, jsonNode)
+                            } else {
+                                (root as ObjectNode).set(it.name, null)
+                            }
+                        }
+                    }
+                }
+                result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root)
+                logger.info("Generated Resource Param Data ({})", result)
+            } catch (e: Exception) {
+                throw BluePrintProcessorException("kapil is failing with $e.message", e)
+            }
+
+            return result
+        }
+
         fun <T> transformResourceSource(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
             val content = JacksonUtils.getJson(properties)
             return JacksonUtils.readValue(content, classType)
                     ?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)")
         }
+
     }
 }
\ No newline at end of file
index 7f41ba1..46ccb97 100644 (file)
@@ -19,8 +19,11 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
 import org.junit.Assert
 import org.junit.Test
 import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.test.context.ContextConfiguration
@@ -62,6 +65,12 @@ class ResourceResolutionServiceTest {
         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
                 "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
 
+        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+                ExecutionServiceInput::class.java)!!
+
+        // Prepare Inputs
+        PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+
         resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig")
 
     }
index 7889a7e..c4fe4ea 100644 (file)
     "resource-assignment-request": {\r
       "resource-assignment-properties": {\r
         "request-id": "1234",\r
+        "service-instance-id": "siid_1234",\r
+        "vnf-id": "vnf_1234",\r
         "action-name": "assign-activate",\r
         "scope-type": "vnf-type",\r
-        "hostname": "localhost"\r
+        "hostname": "localhost",\r
+        "vnf_name": "temp_vnf"\r
       }\r
     }\r
   }\r
index 89af9e9..3a1535a 100644 (file)
@@ -59,7 +59,7 @@ public class SchemaGeneratorService {
      */\r
     public String generateSchema(String serviceTemplateContent) throws BluePrintException {\r
         if (StringUtils.isNotBlank(serviceTemplateContent)) {\r
-            ServiceTemplate serviceTemplate = JacksonUtils.readValue(serviceTemplateContent,\r
+            ServiceTemplate serviceTemplate = JacksonUtils.Companion.readValue(serviceTemplateContent,\r
                     ServiceTemplate.class);\r
             return generateSchema(serviceTemplate);\r
         } else {\r
index 23d3a97..074483a 100644 (file)
@@ -30,11 +30,11 @@ public class JpaJsonNodeConverter implements
 \r
     @Override\r
     public String convertToDatabaseColumn(JsonNode node) {\r
-        return JacksonUtils.getJson(node, true);\r
+        return JacksonUtils.Companion.getJson(node, true);\r
     }\r
 \r
     @Override\r
     public JsonNode convertToEntityAttribute(String dbData) {\r
-        return JacksonUtils.jsonNode(dbData);\r
+        return JacksonUtils.Companion.jsonNode(dbData);\r
     }\r
 }
\ No newline at end of file
index 18672f1..e28cdcd 100644 (file)
@@ -29,11 +29,11 @@ public class JpaResourceDefinitionConverter implements
         AttributeConverter<ResourceDefinition, String> {\r
     @Override\r
     public String convertToDatabaseColumn(ResourceDefinition resourceDefinition) {\r
-        return JacksonUtils.getJson(resourceDefinition);\r
+        return JacksonUtils.Companion.getJson(resourceDefinition);\r
     }\r
 \r
     @Override\r
     public ResourceDefinition convertToEntityAttribute(String content) {\r
-        return JacksonUtils.readValue(content, ResourceDefinition.class);\r
+        return JacksonUtils.Companion.readValue(content, ResourceDefinition.class);\r
     }\r
 }\r
index 6d02544..5d15e08 100644 (file)
@@ -58,7 +58,7 @@ public class ServiceTemplateValidator extends BluePrintValidatorDefaultService {
     public boolean validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {\r
         if (StringUtils.isNotBlank(serviceTemplateContent)) {\r
             ServiceTemplate serviceTemplate =\r
-                    JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);\r
+                    JacksonUtils.Companion.readValue(serviceTemplateContent, ServiceTemplate.class);\r
             return validateServiceTemplate(serviceTemplate);\r
         } else {\r
             throw new BluePrintException(\r
@@ -131,11 +131,11 @@ public class ServiceTemplateValidator extends BluePrintValidatorDefaultService {
                 Object mappingObject =\r
                         capabilityAssignment.getProperties().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);\r
                 if (mappingObject != null) {\r
-                    String mappingContent = JacksonUtils.getJson(mappingObject);\r
+                    String mappingContent = JacksonUtils.Companion.getJson(mappingObject);\r
                     Preconditions.checkArgument(StringUtils.isNotBlank(mappingContent),\r
                             String.format("Failed to get capability mapping property (%s) ", ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING));\r
 \r
-                    resourceAssignment = JacksonUtils.getListFromJson(mappingContent, ResourceAssignment.class);\r
+                    resourceAssignment = JacksonUtils.Companion.getListFromJson(mappingContent, ResourceAssignment.class);\r
 \r
                     Preconditions.checkNotNull(resourceAssignment,\r
                             String.format("Failed to get resource assignment info from the content (%s) ", mappingContent));\r
index 412e960..42c6365 100644 (file)
@@ -56,12 +56,12 @@ public class ModelTypeServiceTest {
     public void test01SaveModelType() throws Exception {
         log.info("**************** test01SaveModelType  ********************");
 
-        String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json");
+        String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");
         ModelType modelType = new ModelType();
         modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
         modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
         modelType.setDescription("Definition for Sample Datatype ");
-        modelType.setDefinition(JacksonUtils.jsonNode(content));
+        modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));
         modelType.setModelName(modelName);
         modelType.setVersion("1.0.0");
         modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
index 7549b78..739ce51 100644 (file)
@@ -54,12 +54,12 @@ public class ModelTypeReactRepositoryTest {
     @Test
     @Commit
     public void test01Save() {
-        String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json");
+        String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");
         ModelType modelType = new ModelType();
         modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
         modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
         modelType.setDescription("Definition for Sample Datatype ");
-        modelType.setDefinition(JacksonUtils.jsonNode(content));
+        modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));
         modelType.setModelName(modelName);
         modelType.setVersion("1.0.0");
         modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
index 2a63683..fb11c39 100644 (file)
@@ -55,7 +55,7 @@ public class ResourceDictionaryReactRepositoryTest {
     @Test
     @Commit
     public void test01Save() {
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", ResourceDefinition.class);
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile("./../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", ResourceDefinition.class);
         Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition);
         resourceDefinition.setName(sourceName);
 
index bf5db34..64c87e0 100644 (file)
@@ -53,12 +53,12 @@ public class ModelTypeRestTest {
     public void test01SaveModelType() throws Exception {\r
         log.info("**************** test01SaveModelType  ********************");\r
 \r
-        String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json");\r
+        String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");\r
         ModelType modelType = new ModelType();\r
         modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);\r
         modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);\r
         modelType.setDescription("Definition for Sample Datatype ");\r
-        modelType.setDefinition(JacksonUtils.jsonNode(content));\r
+        modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));\r
         modelType.setModelName(modelName);\r
         modelType.setVersion("1.0.0");\r
         modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","\r