- // Primitive Types
- when (type) {
- in BluePrintTypes.validPrimitiveTypes() -> {
- val dbColumnValue = rows[0][outputKeyMapping[dName]]
- logger.info("For template key (${resourceAssignment.name}) setting value as ($dbColumnValue)")
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, dbColumnValue)
- }
- in BluePrintTypes.validCollectionTypes() -> {
- val entrySchemaType = returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
- val arrayNode = JsonNodeFactory.instance.arrayNode()
- rows.forEach {
- if (entrySchemaType in BluePrintTypes.validPrimitiveTypes()) {
- val dbColumnValue = it[outputKeyMapping[dName]]
- // Add Array JSON
- JacksonUtils.populatePrimitiveValues(dbColumnValue!!, entrySchemaType, arrayNode)
- } else {
- val arrayChildNode = JsonNodeFactory.instance.objectNode()
- for (mapping in outputKeyMapping.entries) {
- val dbColumnValue = checkNotNull(it[mapping.key])
- val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, mapping.key)
- JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, arrayChildNode)
- }
- arrayNode.add(arrayChildNode)
- }
- }
- logger.info("For template key (${resourceAssignment.name}) setting value as ($arrayNode)")
- // Set the List of Complex Values
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, arrayNode)
- }
- else -> {
- // Complex Types
- val row = rows[0]
- val objectNode = JsonNodeFactory.instance.objectNode()
- for (mapping in outputKeyMapping.entries) {
- val dbColumnValue = checkNotNull(row[mapping.key])
- val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key)
- JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, objectNode)
- }
- logger.info("For template key (${resourceAssignment.name}) setting value as ($objectNode)")
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, objectNode)
- }