From 2d6ae1c383a0cfadc0407db734d46508a26252e1 Mon Sep 17 00:00:00 2001 From: Hekmatullah Date: Wed, 22 Jan 2025 15:17:49 +0000 Subject: [PATCH] Remove unnecessary files and codes --- .../1.json | 174 ------------------ .../mobile/core/database/Room.android.kt | 2 - .../org/mifos/mobile/core/database/Room.kt | 23 ++- .../mobile/core/database/dao/ChargeDao.kt | 5 +- .../core/database/dao/MifosNotificationDao.kt | 3 +- .../mobile/core/database/Room.desktop.kt | 2 - .../mifos/mobile/core/database/Room.native.kt | 2 - 7 files changed, 16 insertions(+), 195 deletions(-) delete mode 100644 core/database/schemas/org.mifos.mobile.core.database.SelfServiceDatabase/1.json diff --git a/core/database/schemas/org.mifos.mobile.core.database.SelfServiceDatabase/1.json b/core/database/schemas/org.mifos.mobile.core.database.SelfServiceDatabase/1.json deleted file mode 100644 index 71b342fa1..000000000 --- a/core/database/schemas/org.mifos.mobile.core.database.SelfServiceDatabase/1.json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "formatVersion": 1, - "database": { - "version": 1, - "identityHash": "0ef6ac9f8492c3e3e0026cafe51bd414", - "entities": [ - { - "tableName": "charges", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `clientId` INTEGER, `chargeId` INTEGER, `name` TEXT, `dueDate` TEXT NOT NULL, `chargeTimeType` TEXT, `chargeCalculationType` TEXT, `currency` TEXT, `amount` REAL NOT NULL, `amountPaid` REAL NOT NULL, `amountWaived` REAL NOT NULL, `amountWrittenOff` REAL NOT NULL, `amountOutstanding` REAL NOT NULL, `penalty` INTEGER NOT NULL, `isActive` INTEGER NOT NULL, `isChargePaid` INTEGER NOT NULL, `isChargeWaived` INTEGER NOT NULL, `paid` INTEGER NOT NULL, `waived` INTEGER NOT NULL)", - "fields": [ - { - "fieldPath": "id", - "columnName": "id", - "affinity": "INTEGER", - "notNull": false - }, - { - "fieldPath": "clientId", - "columnName": "clientId", - "affinity": "INTEGER", - "notNull": false - }, - { - "fieldPath": "chargeId", - "columnName": "chargeId", - "affinity": "INTEGER", - "notNull": false - }, - { - "fieldPath": "name", - "columnName": "name", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "dueDate", - "columnName": "dueDate", - "affinity": "TEXT", - "notNull": true - }, - { - "fieldPath": "chargeTimeType", - "columnName": "chargeTimeType", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "chargeCalculationType", - "columnName": "chargeCalculationType", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "currency", - "columnName": "currency", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "amount", - "columnName": "amount", - "affinity": "REAL", - "notNull": true - }, - { - "fieldPath": "amountPaid", - "columnName": "amountPaid", - "affinity": "REAL", - "notNull": true - }, - { - "fieldPath": "amountWaived", - "columnName": "amountWaived", - "affinity": "REAL", - "notNull": true - }, - { - "fieldPath": "amountWrittenOff", - "columnName": "amountWrittenOff", - "affinity": "REAL", - "notNull": true - }, - { - "fieldPath": "amountOutstanding", - "columnName": "amountOutstanding", - "affinity": "REAL", - "notNull": true - }, - { - "fieldPath": "penalty", - "columnName": "penalty", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "isActive", - "columnName": "isActive", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "isChargePaid", - "columnName": "isChargePaid", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "isChargeWaived", - "columnName": "isChargeWaived", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "paid", - "columnName": "paid", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "waived", - "columnName": "waived", - "affinity": "INTEGER", - "notNull": true - } - ], - "primaryKey": { - "autoGenerate": true, - "columnNames": [ - "id" - ] - }, - "indices": [], - "foreignKeys": [] - }, - { - "tableName": "mifos_notifications", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`timeStamp` INTEGER NOT NULL, `msg` TEXT, `read` INTEGER, PRIMARY KEY(`timeStamp`))", - "fields": [ - { - "fieldPath": "timeStamp", - "columnName": "timeStamp", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "msg", - "columnName": "msg", - "affinity": "TEXT", - "notNull": false - }, - { - "fieldPath": "read", - "columnName": "read", - "affinity": "INTEGER", - "notNull": false - } - ], - "primaryKey": { - "autoGenerate": false, - "columnNames": [ - "timeStamp" - ] - }, - "indices": [], - "foreignKeys": [] - } - ], - "views": [], - "setupQueries": [ - "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '0ef6ac9f8492c3e3e0026cafe51bd414')" - ] - } -} \ No newline at end of file diff --git a/core/database/src/androidMain/kotlin/org/mifos/mobile/core/database/Room.android.kt b/core/database/src/androidMain/kotlin/org/mifos/mobile/core/database/Room.android.kt index d89e08245..415210c16 100644 --- a/core/database/src/androidMain/kotlin/org/mifos/mobile/core/database/Room.android.kt +++ b/core/database/src/androidMain/kotlin/org/mifos/mobile/core/database/Room.android.kt @@ -30,5 +30,3 @@ actual typealias ForeignKey = ForeignKey actual typealias Index = Index actual typealias Entity = Entity - -// actual typealias OnConflictStrategy = OnConflictStrategy diff --git a/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/Room.kt b/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/Room.kt index c6f196cce..37a11c268 100644 --- a/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/Room.kt +++ b/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/Room.kt @@ -21,18 +21,6 @@ expect annotation class Query( val value: String, ) -// @Suppress("NO_ACTUAL_FOR_EXPECT") -// expect annotation class OnConflictStrategy { -// companion object { -// val NONE: Int -// val REPLACE: Int -// val ROLLBACK: Int -// val ABORT: Int -// val FAIL: Int -// val IGNORE: Int -// } -// } - @Suppress("NO_ACTUAL_FOR_EXPECT") @Target(AnnotationTarget.FUNCTION) @Retention(AnnotationRetention.BINARY) @@ -69,3 +57,14 @@ expect annotation class Entity( val foreignKeys: Array, val ignoredColumns: Array, ) + +class OnConflictStrategy { + companion object { + const val NONE = 0 + const val REPLACE = 1 + const val ROLLBACK = 2 + const val ABORT = 3 + const val FAIL = 4 + const val IGNORE = 5 + } +} diff --git a/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/dao/ChargeDao.kt b/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/dao/ChargeDao.kt index 0100244a9..f335415e2 100644 --- a/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/dao/ChargeDao.kt +++ b/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/dao/ChargeDao.kt @@ -12,6 +12,7 @@ package org.mifos.mobile.core.database.dao import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.database.Dao import org.mifos.mobile.core.database.Insert +import org.mifos.mobile.core.database.OnConflictStrategy import org.mifos.mobile.core.database.Query import org.mifos.mobile.core.database.entity.ChargeEntity @@ -21,9 +22,9 @@ interface ChargeDao { @Query("SELECT * FROM charges") fun getAllLocalCharges(): Flow> - @Insert(entity = ChargeEntity::class, onConflict = 1) + @Insert(entity = ChargeEntity::class, onConflict = OnConflictStrategy.REPLACE) suspend fun insertCharge(charge: List) - @Insert(entity = ChargeEntity::class, onConflict = 1) + @Insert(entity = ChargeEntity::class, onConflict = OnConflictStrategy.REPLACE) suspend fun syncCharges(charges: List) } diff --git a/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/dao/MifosNotificationDao.kt b/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/dao/MifosNotificationDao.kt index aef5c6637..658e6e98c 100644 --- a/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/dao/MifosNotificationDao.kt +++ b/core/database/src/commonMain/kotlin/org/mifos/mobile/core/database/dao/MifosNotificationDao.kt @@ -12,6 +12,7 @@ package org.mifos.mobile.core.database.dao import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.database.Dao import org.mifos.mobile.core.database.Insert +import org.mifos.mobile.core.database.OnConflictStrategy import org.mifos.mobile.core.database.Query import org.mifos.mobile.core.database.entity.MifosNotificationEntity @@ -24,7 +25,7 @@ interface MifosNotificationDao { @Query("SELECT COUNT(*) FROM mifos_notification WHERE read = 0") fun getUnreadNotificationsCount(): Flow - @Insert(entity = MifosNotificationEntity::class, onConflict = 1) + @Insert(entity = MifosNotificationEntity::class, onConflict = OnConflictStrategy.REPLACE) suspend fun saveNotification(notification: MifosNotificationEntity) @Query("DELETE FROM mifos_notification WHERE timeStamp < :cutoffTime") diff --git a/core/database/src/desktopMain/kotlin/org/mifos/mobile/core/database/Room.desktop.kt b/core/database/src/desktopMain/kotlin/org/mifos/mobile/core/database/Room.desktop.kt index d89e08245..415210c16 100644 --- a/core/database/src/desktopMain/kotlin/org/mifos/mobile/core/database/Room.desktop.kt +++ b/core/database/src/desktopMain/kotlin/org/mifos/mobile/core/database/Room.desktop.kt @@ -30,5 +30,3 @@ actual typealias ForeignKey = ForeignKey actual typealias Index = Index actual typealias Entity = Entity - -// actual typealias OnConflictStrategy = OnConflictStrategy diff --git a/core/database/src/nativeMain/kotlin/org/mifos/mobile/core/database/Room.native.kt b/core/database/src/nativeMain/kotlin/org/mifos/mobile/core/database/Room.native.kt index d89e08245..415210c16 100644 --- a/core/database/src/nativeMain/kotlin/org/mifos/mobile/core/database/Room.native.kt +++ b/core/database/src/nativeMain/kotlin/org/mifos/mobile/core/database/Room.native.kt @@ -30,5 +30,3 @@ actual typealias ForeignKey = ForeignKey actual typealias Index = Index actual typealias Entity = Entity - -// actual typealias OnConflictStrategy = OnConflictStrategy