summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/blueprint-core
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2019-08-05 09:50:15 -0400
committerDan Timoney <dtimoney@att.com>2019-08-09 21:51:14 +0000
commit977287b586e27e2f835a5d24950abf1f2adae8be (patch)
tree86200548402e907c6cf969bd4f0a516eed937ed0 /ms/controllerblueprints/modules/blueprint-core
parent4001ac13397c082ee97c7ff440fa2ead5d50b421 (diff)
Add resource definition resolution service.
Change-Id: Ife75d290540e3ed0e0dfd0a82785a498607a2d25 Issue-ID: CCSDK-1577 Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-core')
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt7
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt6
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt13
3 files changed, 20 insertions, 6 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
index 2717c3be9..d148745df 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
@@ -21,8 +21,8 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.*
import org.apache.commons.lang3.ObjectUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-import org.slf4j.LoggerFactory
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JsonParserUtils
+import org.slf4j.LoggerFactory
import org.slf4j.helpers.MessageFormatter
import kotlin.reflect.KClass
@@ -156,6 +156,11 @@ fun ArrayNode.asListOfString(): List<String> {
return JacksonUtils.getListFromJsonNode(this, String::class.java)
}
+fun JsonNode.asListOfString(): List<String> {
+ check(this is ArrayNode) { "JsonNode is not of type ArrayNode" }
+ return this.asListOfString()
+}
+
fun JsonNode.returnNullIfMissing(): JsonNode? {
return if (this is NullNode || this is MissingNode) {
null
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt
index fdaf25c15..776e0411e 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt
@@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.springframework.context.ApplicationContext
+import kotlin.reflect.KClass
/**
* Generic Bluepring Dependency Service, which will be used mainly in scripts.
@@ -44,4 +45,9 @@ object BluePrintDependencyService {
return applicationContext.getBean(type)
?: throw BluePrintProcessorException("failed to get instance($type)")
}
+
+ inline fun <reified T> instance(type: KClass<*>): T {
+ return applicationContext.getBean(type.java) as? T
+ ?: throw BluePrintProcessorException("failed to get instance($type)")
+ }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
index 9b1b66b5b..768f8753f 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
@@ -238,11 +238,14 @@ class JacksonUtils {
fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {
when (primitiveType.toLowerCase()) {
- BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, (value as BooleanNode).booleanValue())
- BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, (value as IntNode).intValue())
- BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, (value as FloatNode).floatValue())
- BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, (value as DoubleNode).doubleValue())
- else -> objectNode.put(key, (value as TextNode).textValue())
+ BluePrintConstants.DATA_TYPE_STRING,
+ BluePrintConstants.DATA_TYPE_BOOLEAN,
+ BluePrintConstants.DATA_TYPE_INTEGER,
+ BluePrintConstants.DATA_TYPE_FLOAT,
+ BluePrintConstants.DATA_TYPE_DOUBLE,
+ BluePrintConstants.DATA_TYPE_TIMESTAMP ->
+ objectNode.set(key, value.asJsonPrimitive())
+ else -> objectNode.set(key, value.asJsonType())
}
}