aboutsummaryrefslogtreecommitdiff
path: root/kvision-server
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-05-05 22:36:44 +0200
committerRobert Jaros <rjaros@finn.pl>2018-05-05 22:36:44 +0200
commitb3475b4541c60545b32ac8e04d6d099f9edf5097 (patch)
treedb31ef784187e35b5133beb353aec893fba108c4 /kvision-server
parentf9e9edd177d7ff48f0300a328c4e7bb01ffc7368 (diff)
downloadkvision-b3475b4541c60545b32ac8e04d6d099f9edf5097.tar.gz
kvision-b3475b4541c60545b32ac8e04d6d099f9edf5097.tar.bz2
kvision-b3475b4541c60545b32ac8e04d6d099f9edf5097.zip
Kwery ORM integration.
Diffstat (limited to 'kvision-server')
-rw-r--r--kvision-server/build.gradle1
-rw-r--r--kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt15
2 files changed, 16 insertions, 0 deletions
diff --git a/kvision-server/build.gradle b/kvision-server/build.gradle
index 8be34ecf..6d623b3d 100644
--- a/kvision-server/build.gradle
+++ b/kvision-server/build.gradle
@@ -15,6 +15,7 @@ dependencies {
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
compile "org.jooby:jooby-lang-kotlin"
compile "org.jooby:jooby-jackson"
+ compile "com.github.andrewoma.kwery:mapper:${kweryVersion}"
compile "com.fasterxml.jackson.module:jackson-module-kotlin:${jacksonModuleKotlinVersion}"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
testCompile project(":kvision-common")
diff --git a/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt b/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt
index 1d174f88..ad4185d6 100644
--- a/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt
+++ b/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt
@@ -21,6 +21,11 @@
*/
package pl.treksoft.kvision.types
+import com.github.andrewoma.kwery.mapper.SimpleConverter
+import com.github.andrewoma.kwery.mapper.TableConfiguration
+import com.github.andrewoma.kwery.mapper.reifiedConverter
+import com.github.andrewoma.kwery.mapper.standardConverters
+import com.github.andrewoma.kwery.mapper.util.camelToLowerUnderscore
import java.text.SimpleDateFormat
import java.util.*
@@ -40,3 +45,13 @@ internal actual fun KDate.toStringF(format: String) =
SimpleDateFormat(format).format(this.toJava())
fun KDate.toJava(): java.util.Date = java.util.Date(this.time)
+
+object KDateConverter : SimpleConverter<KDate>(
+ { row, c -> KDate(row.date(c).time) },
+ { it.toJava() }
+)
+
+val kvTableConfig = TableConfiguration(
+ converters = standardConverters + reifiedConverter(KDateConverter),
+ namingConvention = camelToLowerUnderscore
+)