From c8b1fa15595660304accefc179e6c329336aabee Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Tue, 2 Jul 2024 15:26:59 +0200 Subject: [PATCH] core: Init realm models --- .../db/models/ContainerDB.kt | 47 +++++++++++++++++++ .../db/models/FileDB.kt | 39 +++++++++++++++ .../db/models/TransferDB.kt | 36 ++++++++++++++ .../db/models/setting/AppSettings.kt | 25 ++++++++++ .../db/models/upload/UploadTasks.kt | 29 ++++++++++++ 5 files changed, 176 insertions(+) create mode 100644 DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/ContainerDB.kt create mode 100644 DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/FileDB.kt create mode 100644 DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/TransferDB.kt create mode 100644 DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/setting/AppSettings.kt create mode 100644 DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/upload/UploadTasks.kt diff --git a/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/ContainerDB.kt b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/ContainerDB.kt new file mode 100644 index 00000000..34105b46 --- /dev/null +++ b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/ContainerDB.kt @@ -0,0 +1,47 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.infomaniak.multiplatform_swisstransfer.db.models + +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.Container +import io.realm.kotlin.ext.realmListOf +import io.realm.kotlin.types.RealmList +import io.realm.kotlin.types.RealmObject +import io.realm.kotlin.types.annotations.PrimaryKey + +class ContainerDB : Container>, RealmObject { + @PrimaryKey + override var uuid: String = "" + override var duration: Long = 0 + override var createdDateTimestamp: Long = 0 + override var expiredDateTimestamp: Long = 0 + override var numberOfFile: Long = 0 + override var message: String? = "" + override var needPassword: Long = 0 // TODO: Boolean ? + override var lang: String = "" + override var sizeUploaded: Long = 0 + override var deletedDateTimestamp: Long? = null + override var swiftVersion: Long = 0 + override var downloadLimit: Long = 0 + override var source: String = "" + + // @SerialName("WSUser") TODO: What's it ? + //val wsUser: JsonElement? + + override var files: RealmList = realmListOf() +} diff --git a/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/FileDB.kt b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/FileDB.kt new file mode 100644 index 00000000..74b54888 --- /dev/null +++ b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/FileDB.kt @@ -0,0 +1,39 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.infomaniak.multiplatform_swisstransfer.db.models + +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.File +import io.realm.kotlin.types.RealmObject +import io.realm.kotlin.types.annotations.PrimaryKey + +class FileDB : File, RealmObject { + @PrimaryKey + override var containerUUID: String = "" + override var uuid: String = "" + override var fileName: String = "" + override var fileSizeInBytes: Long = 0 + override var downloadCounter: Long = 0 + override var createdDateTimestamp: Long = 0 + override var expiredDateTimestamp: Long = 0 + override var eVirus: String = "" + override var deletedDate: String? = null + override var mimeType: String = "" + override var receivedSizeInBytes: Long = 0 + override var path: String? = "" +} diff --git a/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/TransferDB.kt b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/TransferDB.kt new file mode 100644 index 00000000..3993384e --- /dev/null +++ b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/TransferDB.kt @@ -0,0 +1,36 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.infomaniak.multiplatform_swisstransfer.db.models + +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.Transfer +import io.realm.kotlin.types.RealmObject +import io.realm.kotlin.types.annotations.PrimaryKey + +class TransferDB : Transfer, RealmObject { + @PrimaryKey + override var linkUUID: String = "" + override var containerUUID: String = "" + override var downloadCounterCredit: Long = 0 + override var createdDateTimestamp: Long = 0 + override var expiredDateTimestamp: Long = 0 + override var isDownloadOnetime: Long = 0 // TODO: Boolean ? + override var isMailSent: Boolean = false + override var downloadHost: String = "" + override var container: ContainerDB = ContainerDB() +} diff --git a/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/setting/AppSettings.kt b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/setting/AppSettings.kt new file mode 100644 index 00000000..8d0762d3 --- /dev/null +++ b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/setting/AppSettings.kt @@ -0,0 +1,25 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.infomaniak.multiplatform_swisstransfer.db.models.setting + +import io.realm.kotlin.types.RealmObject + +class AppSettings : RealmObject { + //TODO: implement here +} diff --git a/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/upload/UploadTasks.kt b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/upload/UploadTasks.kt new file mode 100644 index 00000000..90d1390d --- /dev/null +++ b/DB/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/db/models/upload/UploadTasks.kt @@ -0,0 +1,29 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.infomaniak.multiplatform_swisstransfer.db.models.upload + +import io.realm.kotlin.types.RealmObject + +/** + * Class representing files to be uploaded + */ +class UploadTasks : RealmObject { + var userId: Long = 0 + //TODO: implement +}