mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-12-25 06:15:35 +00:00
Began implementing requery.
This commit is contained in:
parent
bb180f95be
commit
65ec528a99
13
build.gradle
13
build.gradle
@ -5,6 +5,7 @@ mainClassName= 'de.fabianonline.telegram_backup.CommandLineRunnerKt'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven {
|
||||
url "https://jitpack.io"
|
||||
}
|
||||
@ -23,11 +24,15 @@ buildscript {
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.apiVersion = "1.0"
|
||||
kotlinOptions.apiVersion = "1.2"
|
||||
}
|
||||
|
||||
|
||||
kapt {
|
||||
generateStubs = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile('com.github.badoualy:kotlogram:666a81ef9d6707f117a3fecc2d21c91d51c7d075') {
|
||||
@ -39,6 +44,10 @@ dependencies {
|
||||
compile 'ch.qos.logback:logback-classic:1.1.7'
|
||||
compile 'com.google.code.gson:gson:2.5'
|
||||
|
||||
compile 'io.requery:requery:1.4.1'
|
||||
compile 'io.requery:requery-kotlin:1.4.1'
|
||||
kapt 'io.requery:requery-processor:1.4.1'
|
||||
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@ import com.github.badoualy.telegram.tl.core.TLVector
|
||||
import com.github.badoualy.telegram.api.TelegramClient
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.slf4j.Logger
|
||||
import io.requery.*
|
||||
import org.sqlite.SQLiteDataSource
|
||||
|
||||
import java.sql.Connection
|
||||
import java.sql.DriverManager
|
||||
@ -47,6 +49,39 @@ import java.text.SimpleDateFormat
|
||||
import de.fabianonline.telegram_backup.mediafilemanager.AbstractMediaFileManager
|
||||
import de.fabianonline.telegram_backup.mediafilemanager.FileManagerFactory
|
||||
|
||||
@Table(name = "messages")
|
||||
@Entity
|
||||
interface Message: Persistable {
|
||||
@get:Key
|
||||
@get:Generated
|
||||
var id: Int
|
||||
|
||||
@get:Index("unique_messages")
|
||||
@get:Column(unique = true)
|
||||
var message_id: Int
|
||||
|
||||
var message_type: String
|
||||
|
||||
@get:Index("unique_messages")
|
||||
@get:Column(unique = true)
|
||||
var source_type: String
|
||||
@get:Index("unique_messages")
|
||||
@get:Column(unique = true)
|
||||
var source_id: Int
|
||||
var sender_id: Int
|
||||
var fwd_from_id: Int
|
||||
var text: String
|
||||
var time: Int
|
||||
var has_media: Boolean
|
||||
var media_type: String
|
||||
var media_file: String
|
||||
var media_size: Int
|
||||
var media_json: String
|
||||
var markup_json: String
|
||||
var data: Array<Byte>
|
||||
var api_layer: Int
|
||||
}
|
||||
|
||||
class Database private constructor(var client: TelegramClient) {
|
||||
private var conn: Connection? = null
|
||||
private var stmt: Statement? = null
|
||||
@ -217,6 +252,12 @@ class Database private constructor(var client: TelegramClient) {
|
||||
// Run updates
|
||||
val updates = DatabaseUpdates(conn!!, this)
|
||||
updates.doUpdates()
|
||||
|
||||
logger.trace("Setting up requery")
|
||||
val ds = SQLiteDataSource()
|
||||
ds.setDatabaseName(path)
|
||||
val config = KotlinConfiguration(dataSource=ds, model=Models.DEFAULT)
|
||||
val foobarbaz
|
||||
|
||||
System.out.println("Database is ready.")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user