diff --git a/modules/driver-jdbc/src/main/kotlin/datamaintain/db/driver/jdbc/serialization/KResultParser.kt b/modules/driver-jdbc/src/main/kotlin/datamaintain/db/driver/jdbc/serialization/KResultParser.kt deleted file mode 100644 index 6dd13434..00000000 --- a/modules/driver-jdbc/src/main/kotlin/datamaintain/db/driver/jdbc/serialization/KResultParser.kt +++ /dev/null @@ -1,62 +0,0 @@ -package datamaintain.db.driver.jdbc.serialization - -import datamaintain.core.script.ExecutedScript -import datamaintain.core.script.ExecutionStatus -import datamaintain.core.script.ScriptAction -import kotlinx.serialization.ContextualSerialization -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.builtins.list -import kotlinx.serialization.json.Json -import kotlinx.serialization.json.JsonConfiguration -import java.util.* - -// Copy of ExecutedScript, this is aim for add the Serializable annotation -// Annotation allow to serialize/deserialize this object to/from a bson document (support json only) -@Serializable -data class ExecutedScriptDb(@SerialName("_id") @ContextualSerialization val id: String = UUID.randomUUID().toString(), - val name: String, - val checksum: String, - val identifier: String, - val executionStatus: ExecutionStatus, - val scriptAction: ScriptAction, - val executionDurationInMillis: Long? = null, - val executionOutput: String? = null) - -// Mapping function -fun ExecutedScriptDb.toExecutedScript() = ExecutedScript( - name, - checksum, - identifier, - executionStatus, - scriptAction, - executionDurationInMillis, - executionOutput -) -fun ExecutedScript.toExecutedScriptDb() = ExecutedScriptDb( - name = name, - checksum = checksum, - identifier = identifier, - executionStatus = executionStatus, - executionDurationInMillis = executionDurationInMillis, - executionOutput = executionOutput, - scriptAction = action!! -) - -class KResultParser { - // Mapper between json and object - private val mapper = Json(JsonConfiguration.Stable.copy()) - - fun parseArrayOfExecutedScripts(executedScriptJsonArray: String): Sequence { - - return mapper.parse(ExecutedScriptDb.serializer().list, executedScriptJsonArray) - .map { it.toExecutedScript() } - .asSequence() - } - - fun serializeExecutedScript(executedScript: ExecutedScript): String { - val executedScriptDb = executedScript.toExecutedScriptDb() - - return mapper.stringify(ExecutedScriptDb.serializer(), executedScriptDb) - } -}