From ddafb6298d3b1a66516a68f76e991f2fc0c89937 Mon Sep 17 00:00:00 2001 From: asolovieff Date: Tue, 5 Oct 2021 11:50:09 +0200 Subject: [PATCH] refacto #143 Removed useless methods in driver-mongo ExecutedScript are only serialized and LightExecutedScript are only deserialized. --- .../driver/mongo/ExecutedScriptJsonParser.kt | 5 +---- .../mongo/LightExecutedScriptJsonParser.kt | 3 --- .../driver/mongo/serialization/KJsonParser.kt | 18 ------------------ 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/ExecutedScriptJsonParser.kt b/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/ExecutedScriptJsonParser.kt index 6c0acd1a..abad0a9c 100644 --- a/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/ExecutedScriptJsonParser.kt +++ b/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/ExecutedScriptJsonParser.kt @@ -3,9 +3,6 @@ package datamaintain.db.driver.mongo import datamaintain.core.script.ExecutedScript interface ExecutedScriptJsonParser { - // parse a stringify json array to an Array of ExecutedScript - fun parseArrayOfExecutedScripts(executedScriptJsonArray: String): Sequence - // Serialize an ExecutedScript to a stringify json document fun serializeExecutedScript(executedScript:ExecutedScript): String -} \ No newline at end of file +} diff --git a/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/LightExecutedScriptJsonParser.kt b/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/LightExecutedScriptJsonParser.kt index a3c925c6..ea12d5f8 100644 --- a/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/LightExecutedScriptJsonParser.kt +++ b/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/LightExecutedScriptJsonParser.kt @@ -5,7 +5,4 @@ import datamaintain.core.script.LightExecutedScript interface LightExecutedScriptJsonParser { // parse a stringify json array to an Array of LightExecutedScript fun parseArrayOfLightExecutedScripts(lightExecutedScriptJsonArray: String): Sequence - - // Serialize an LightExecutedScript to a stringify json document - fun serializeLightExecutedScript(lightExecutedScript: LightExecutedScript): String } diff --git a/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/serialization/KJsonParser.kt b/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/serialization/KJsonParser.kt index 63f118ef..644ba12f 100644 --- a/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/serialization/KJsonParser.kt +++ b/modules/driver-mongo/src/main/kotlin/datamaintain/db/driver/mongo/serialization/KJsonParser.kt @@ -28,11 +28,6 @@ fun LightExecutedScriptDb.toLightExecutedScript() = LightExecutedScript( checksum, identifier ) -fun LightExecutedScript.toLightExecutedScriptDb() = LightExecutedScriptDb( - name = name, - checksum = checksum, - identifier = identifier -) // 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) @@ -71,13 +66,6 @@ class KJsonParser: ExecutedScriptJsonParser, LightExecutedScriptJsonParser { val configuration = JsonConfiguration.Stable.copy(ignoreUnknownKeys = true) private val mapper = Json(configuration) - override fun parseArrayOfExecutedScripts(executedScriptJsonArray: String): Sequence { - - return mapper.parse(ExecutedScriptDb.serializer().list, executedScriptJsonArray) - .map { it.toExecutedScript() } - .asSequence() - } - override fun serializeExecutedScript(executedScript: ExecutedScript): String { val executedScriptDb = executedScript.toExecutedScriptDb() @@ -89,10 +77,4 @@ class KJsonParser: ExecutedScriptJsonParser, LightExecutedScriptJsonParser { .map { it.toLightExecutedScript() } .asSequence() } - - override fun serializeLightExecutedScript(lightExecutedScript: LightExecutedScript): String { - val lightExecutedScriptDb = lightExecutedScript.toLightExecutedScriptDb() - - return mapper.stringify(LightExecutedScriptDb.serializer(), lightExecutedScriptDb) - } }