Skip to content
Snippets Groups Projects
Unverified Commit ebf80ffc authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

wip: persistence layer

parent 63dd4625
Branches api-redesign
No related tags found
No related merge requests found
Pipeline #3031 failed
......@@ -13,7 +13,9 @@ kotlinx-coroutines = "1.9.0"
kotlinx-serialization = "2.0.21"
ktlint = "12.1.1"
nexus-publish = "2.0.0"
room = "2.7.0-alpha07"
slf4j = "1.7.30"
sqlite = "2.5.0-alpha07"
threetenbp = "1.7.0"
[libraries]
......@@ -36,6 +38,10 @@ junit-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit"}
junit-kotlin = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "kotlin"}
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
sqlite = { module = "androidx.sqlite:sqlite-bundled", version.ref = "sqlite" }
nexus-publish-gradlePlugin = { module = "io.github.gradle-nexus:publish-plugin", version.ref = "nexus-publish" }
kotlin-gradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
dokka-gradlePlugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
......
......@@ -12,10 +12,21 @@ plugins {
id("justjanne.publication")
}
repositories {
google()
mavenCentral()
}
dependencies {
api(project(":libquassel-protocol"))
api(project(":libquassel-api"))
implementation(libs.slf4j)
api(project(":libquassel-persistence"))
api(project(":libquassel-protocol"))
implementation(libs.dagger.core)
ksp(libs.dagger.compiler)
implementation(libs.slf4j)
testImplementation(libs.room.runtime)
testImplementation(libs.sqlite)
}
......@@ -9,6 +9,8 @@
package de.justjanne.libquassel.client
import androidx.room.Room
import androidx.sqlite.driver.bundled.BundledSQLiteDriver
import dagger.Binds
import dagger.Component
import dagger.Module
......@@ -28,8 +30,25 @@ import de.justjanne.libquassel.backend.IrcUserPersister
import de.justjanne.libquassel.backend.NetworkConfigPersister
import de.justjanne.libquassel.backend.NetworkPersister
import de.justjanne.libquassel.backend.RpcPersister
import de.justjanne.libquassel.persistence.AppDatabase
import de.justjanne.libquassel.persistence.TodoEntity
import de.justjanne.libquassel.protocol.api.ObjectName
import de.justjanne.libquassel.protocol.api.client.*
import de.justjanne.libquassel.protocol.api.client.AliasManagerClientApi
import de.justjanne.libquassel.protocol.api.client.BacklogManagerClientApi
import de.justjanne.libquassel.protocol.api.client.BufferSyncerClientApi
import de.justjanne.libquassel.protocol.api.client.BufferViewConfigClientApi
import de.justjanne.libquassel.protocol.api.client.BufferViewManagerClientApi
import de.justjanne.libquassel.protocol.api.client.CertManagerClientApi
import de.justjanne.libquassel.protocol.api.client.CoreInfoClientApi
import de.justjanne.libquassel.protocol.api.client.HighlightRuleManagerClientApi
import de.justjanne.libquassel.protocol.api.client.IdentityClientApi
import de.justjanne.libquassel.protocol.api.client.IgnoreListManagerClientApi
import de.justjanne.libquassel.protocol.api.client.IrcChannelClientApi
import de.justjanne.libquassel.protocol.api.client.IrcListHelperClientApi
import de.justjanne.libquassel.protocol.api.client.IrcUserClientApi
import de.justjanne.libquassel.protocol.api.client.NetworkClientApi
import de.justjanne.libquassel.protocol.api.client.NetworkConfigClientApi
import de.justjanne.libquassel.protocol.api.client.RpcClientApi
import de.justjanne.libquassel.protocol.api.dispatcher.ClientDispatcherModule
import de.justjanne.libquassel.protocol.api.dispatcher.RpcDispatcher
import de.justjanne.libquassel.protocol.api.dispatcher.SyncHandler
......@@ -54,6 +73,8 @@ import de.justjanne.libquassel.protocol.models.types.QtType
import de.justjanne.libquassel.protocol.variant.QVariantList
import de.justjanne.libquassel.protocol.variant.QVariant_
import de.justjanne.libquassel.protocol.variant.qVariant
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Test
import javax.inject.Inject
import javax.inject.Singleton
......@@ -148,4 +169,22 @@ class QuasselApiTest {
client.api().identity.requestUpdate(ObjectName(""), emptyMap())
println("hi!")
}
@Test
fun testDb() = runBlocking {
val db = Room.inMemoryDatabaseBuilder<AppDatabase>()
.setDriver(BundledSQLiteDriver())
.setQueryCoroutineContext(Dispatchers.IO)
.build()
val dao = db.getDao()
println(dao.count())
dao.insert(
TodoEntity(
title = "kids",
content = "bring kids home from school"
)
)
println(dao.count())
}
}
/*
* libquassel
* Copyright (c) 2024 Janne Mareike Koschinski
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
plugins {
id("justjanne.kotlin")
id("justjanne.publication")
}
repositories {
google()
mavenCentral()
}
dependencies {
api(project(":libquassel-protocol"))
api(project(":libquassel-api"))
implementation(libs.dagger.core)
ksp(libs.dagger.compiler)
implementation(libs.room.runtime)
ksp(libs.room.compiler)
implementation(libs.slf4j)
}
/*
* libquassel
* Copyright (c) 2024 Janne Mareike Koschinski
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
package de.justjanne.libquassel.persistence
import androidx.room.Database
import androidx.room.RoomDatabase
@Database(entities = [TodoEntity::class], version = 1)
abstract class AppDatabase : RoomDatabase() {
abstract fun getDao(): TodoDao
}
/*
* libquassel
* Copyright (c) 2024 Janne Mareike Koschinski
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
package de.justjanne.libquassel.persistence
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import kotlinx.coroutines.flow.Flow
@Dao
interface TodoDao {
@Insert
suspend fun insert(item: TodoEntity)
@Query("SELECT count(*) FROM TodoEntity")
suspend fun count(): Int
@Query("SELECT * FROM TodoEntity")
fun getAllAsFlow(): Flow<List<TodoEntity>>
}
/*
* libquassel
* Copyright (c) 2024 Janne Mareike Koschinski
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
package de.justjanne.libquassel.persistence
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity
data class TodoEntity(
@PrimaryKey(autoGenerate = true) val id: Long = 0,
val title: String,
val content: String
)
......@@ -15,6 +15,7 @@ include(
":libquassel-annotations",
":libquassel-api",
":libquassel-client",
":libquassel-persistence",
":libquassel-generator",
":libquassel-irc",
":libquassel-protocol"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment