|
1 | 1 | package com.ctrlhub.core.datacapture.resource |
2 | 2 |
|
3 | | -import com.ctrlhub.core.datacapture.response.FormSchema |
4 | 3 | import com.ctrlhub.core.datacapture.response.Form |
| 4 | +import com.ctrlhub.core.datacapture.response.FormSchema |
5 | 5 | import com.ctrlhub.core.datacapture.response.FormSubmission |
6 | 6 | import com.ctrlhub.core.geo.Property |
7 | 7 | import com.ctrlhub.core.iam.response.User |
| 8 | +import com.ctrlhub.core.json.JsonConfig |
8 | 9 | import com.ctrlhub.core.media.response.Image |
9 | 10 | import com.ctrlhub.core.projects.operations.response.Operation |
10 | 11 | import com.ctrlhub.core.projects.schemes.response.Scheme |
11 | 12 | import com.ctrlhub.core.projects.workorders.response.WorkOrder |
12 | 13 | import com.fasterxml.jackson.annotation.JsonCreator |
13 | 14 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties |
14 | 15 | import com.fasterxml.jackson.annotation.JsonProperty |
15 | | -import com.fasterxml.jackson.databind.DeserializationFeature |
16 | 16 | import com.fasterxml.jackson.databind.ObjectMapper |
17 | | -import com.fasterxml.jackson.module.kotlin.kotlinModule |
18 | 17 | import com.github.jasminb.jsonapi.StringIdHandler |
19 | 18 | import com.github.jasminb.jsonapi.annotations.Id |
20 | 19 | import com.github.jasminb.jsonapi.annotations.Meta |
@@ -74,14 +73,14 @@ class FormSubmissionVersion @JsonCreator constructor( |
74 | 73 | val rawPayload: String? |
75 | 74 | get() = payload?.let { |
76 | 75 | try { |
77 | | - mapper.writeValueAsString(it) |
| 76 | + resourceMapper().writeValueAsString(it) |
78 | 77 | } catch (e: Exception) { |
79 | 78 | null |
80 | 79 | } |
81 | 80 | } |
82 | 81 |
|
83 | 82 | // shared Jackson mapper configured to ignore unknown properties when hydrating attribute maps |
84 | | - private fun resourceMapper(): ObjectMapper = mapper |
| 83 | + private fun resourceMapper(): ObjectMapper = JsonConfig.getMapper() |
85 | 84 |
|
86 | 85 | /** |
87 | 86 | * Convert the raw resources list (List<Map<...>>) into typed JsonApiEnvelope objects. |
@@ -126,7 +125,7 @@ class FormSubmissionVersion @JsonCreator constructor( |
126 | 125 | fun autoHydrateById(id: String): Any? { |
127 | 126 | val env = findResourceEnvelopeById(id) ?: return null |
128 | 127 | val type = env.data?.type ?: return null |
129 | | - val clazz = Companion.getRegisteredClass(type) ?: return null |
| 128 | + val clazz = getRegisteredClass(type) ?: return null |
130 | 129 | return hydrateResourceAttributesById(id, clazz) |
131 | 130 | } |
132 | 131 |
|
@@ -154,10 +153,6 @@ class FormSubmissionVersion @JsonCreator constructor( |
154 | 153 | } |
155 | 154 |
|
156 | 155 | companion object { |
157 | | - private val mapper: ObjectMapper = ObjectMapper() |
158 | | - .registerModule(kotlinModule()) |
159 | | - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) |
160 | | - |
161 | 156 | // simple type registry mapping jsonapi resource "type" -> Class |
162 | 157 | private val typeRegistry: MutableMap<String, Class<*>> = mutableMapOf() |
163 | 158 |
|
|
0 commit comments