mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 08:46:15 +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 {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
maven {
|
maven {
|
||||||
url "https://jitpack.io"
|
url "https://jitpack.io"
|
||||||
}
|
}
|
||||||
@ -23,11 +24,15 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
kotlinOptions.apiVersion = "1.0"
|
kotlinOptions.apiVersion = "1.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kapt {
|
||||||
|
generateStubs = true
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile('com.github.badoualy:kotlogram:666a81ef9d6707f117a3fecc2d21c91d51c7d075') {
|
compile('com.github.badoualy:kotlogram:666a81ef9d6707f117a3fecc2d21c91d51c7d075') {
|
||||||
@ -39,6 +44,10 @@ dependencies {
|
|||||||
compile 'ch.qos.logback:logback-classic:1.1.7'
|
compile 'ch.qos.logback:logback-classic:1.1.7'
|
||||||
compile 'com.google.code.gson:gson:2.5'
|
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'
|
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 com.github.badoualy.telegram.api.TelegramClient
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
|
import io.requery.*
|
||||||
|
import org.sqlite.SQLiteDataSource
|
||||||
|
|
||||||
import java.sql.Connection
|
import java.sql.Connection
|
||||||
import java.sql.DriverManager
|
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.AbstractMediaFileManager
|
||||||
import de.fabianonline.telegram_backup.mediafilemanager.FileManagerFactory
|
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) {
|
class Database private constructor(var client: TelegramClient) {
|
||||||
private var conn: Connection? = null
|
private var conn: Connection? = null
|
||||||
private var stmt: Statement? = null
|
private var stmt: Statement? = null
|
||||||
@ -217,6 +252,12 @@ class Database private constructor(var client: TelegramClient) {
|
|||||||
// Run updates
|
// Run updates
|
||||||
val updates = DatabaseUpdates(conn!!, this)
|
val updates = DatabaseUpdates(conn!!, this)
|
||||||
updates.doUpdates()
|
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.")
|
System.out.println("Database is ready.")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user