}
}
- fun transformToRARuntimeService(blueprintRuntimeService: BluePrintRuntimeService<*>,
- templateArtifactName: String): ResourceAssignmentRuntimeService {
+ fun transformToRARuntimeService(
+ blueprintRuntimeService: BluePrintRuntimeService<*>,
+ templateArtifactName: String
+ ): ResourceAssignmentRuntimeService {
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService(
blueprintRuntimeService.id(),
}
@Throws(BluePrintProcessorException::class)
- fun getPropertyType(raRuntimeService: ResourceAssignmentRuntimeService, dataTypeName: String,
- propertyName: String): String {
+ fun getPropertyType(
+ raRuntimeService: ResourceAssignmentRuntimeService, dataTypeName: String,
+ propertyName: String
+ ): String {
lateinit var type: String
try {
val dataTypeProps =
}
@Throws(BluePrintProcessorException::class)
- fun parseResponseNode(responseNode: JsonNode, resourceAssignment: ResourceAssignment,
- raRuntimeService: ResourceAssignmentRuntimeService, outputKeyMapping: MutableMap<String, String>): JsonNode {
+ fun parseResponseNode(
+ responseNode: JsonNode, resourceAssignment: ResourceAssignment,
+ raRuntimeService: ResourceAssignmentRuntimeService, outputKeyMapping: MutableMap<String, String>
+ ): JsonNode {
val metadata = resourceAssignment.property!!.metadata
try {
if ((resourceAssignment.property?.type).isNullOrEmpty()) {
}
}
- //TODO: Need to Refactor
- private fun parseResponseNodeForPrimitiveTypes(responseNode: JsonNode,
- outputKeyMapping: MutableMap<String, String>): JsonNode {
- var result: JsonNode? = responseNode
-
+ private fun parseResponseNodeForPrimitiveTypes(
+ responseNode: JsonNode,
+ outputKeyMapping: MutableMap<String, String>
+ ): JsonNode {
if (responseNode.isComplexType()) {
- val key = outputKeyMapping.keys.firstOrNull()
- var returnNode: JsonNode?
- if (responseNode is ArrayNode) {
+ val outputKey = outputKeyMapping.keys.firstOrNull()
+ var returnNode = if (responseNode is ArrayNode) {
val arrayNode = responseNode.toList()
- val firstElement = if (key.isNullOrEmpty()) {
+ if (outputKey.isNullOrEmpty()) {
arrayNode.first()
} else {
arrayNode.firstOrNull { element ->
- element.isComplexType() && element.has(outputKeyMapping[key])
+ element.isComplexType() && element.has(outputKeyMapping[outputKey])
}
}
- returnNode = firstElement
} else {
- returnNode = responseNode
+ responseNode
}
- if (returnNode.isNull() || (returnNode!!.isComplexType() && !returnNode.has(outputKeyMapping[key]))) {
- if (key.isNullOrEmpty()) {
- throw BluePrintProcessorException("Fail to find mapping in the responseNode.")
- } else {
- throw BluePrintProcessorException("Fail to find response with output key mapping ($key) in result.")
- }
+ if (returnNode.isNull() || returnNode!!.isComplexType() && !returnNode.has(outputKeyMapping[outputKey])) {
+ throw BluePrintProcessorException("Fail to find output key mapping ($outputKey) in the responseNode.")
}
- result = if (returnNode.isComplexType()) {
- returnNode[outputKeyMapping[key]]
+ return if (returnNode.isComplexType()) {
+ returnNode[outputKeyMapping[outputKey]]
} else {
- responseNode
- }
- } else {
- if (outputKeyMapping.isNotEmpty()) {
- throw BluePrintProcessorException("Fail to find key-value in response node to map output-key-mapping.")
+ returnNode
}
}
- return result!!
+ if (outputKeyMapping.isNotEmpty()) {
+ throw BluePrintProcessorException("Fail to find key-value in response node to map output-key-mapping.")
+ }
+ return responseNode
}
private fun parseResponseNodeForCollection(