Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): migrate from dbflow to room for client #2300

Draft
wants to merge 34 commits into
base: kmp-impl
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8c972ad
refactor(core): migrate from dbflow to room in core:data and core:dat…
biplab1 Feb 6, 2025
8d10daa
refactor(core): replace var with val in core:database
biplab1 Feb 6, 2025
4b24e68
refactor(core): replace var with val in core:database and delete some…
biplab1 Feb 7, 2025
987119e
refactor(core): update files after ci-prepush
biplab1 Feb 7, 2025
a4299e0
refactor(core:database): remove columninfo annotations from room enti…
biplab1 Feb 10, 2025
4e1ecdb
chore: apply ci-prepush changes
biplab1 Feb 10, 2025
2f3b52b
refactor: correct import statements for client room entities
biplab1 Feb 12, 2025
1fedc46
chore: update ci-prepush changes
biplab1 Feb 12, 2025
054d4f4
feat(core:database): Update ClientDao
biplab1 Feb 13, 2025
3013709
refactor(core): migrate from dbflow to room in core:data and core:dat…
biplab1 Feb 6, 2025
5ee3508
refactor(core): replace var with val in core:database
biplab1 Feb 6, 2025
2859f22
refactor(core): replace var with val in core:database and delete some…
biplab1 Feb 7, 2025
cfec4d1
refactor(core): update files after ci-prepush
biplab1 Feb 7, 2025
a7f5dcb
refactor(core:database): remove columninfo annotations from room enti…
biplab1 Feb 10, 2025
ae7955f
chore: apply ci-prepush changes
biplab1 Feb 10, 2025
5163fa4
refactor: correct import statements for client room entities
biplab1 Feb 12, 2025
6165506
chore: update ci-prepush changes
biplab1 Feb 12, 2025
66991bb
feat(core:database): Update ClientDao
biplab1 Feb 13, 2025
9e1b2fd
refactor(core:database): remove columninfo annotaions from room:entit…
biplab1 Feb 14, 2025
b47d875
refactor(core:database): replace HashMap with emptyMap
biplab1 Feb 14, 2025
ed252ff
refactor(core): restore original files DataManagerClient and Activate…
biplab1 Feb 14, 2025
0ee1a44
refactor(core:data): migrate dbflow to room
biplab1 Feb 14, 2025
6fc8588
refactor(core:database): update ClientDao
biplab1 Feb 14, 2025
d69392c
Merge remote-tracking branch 'origin/client-dbflow-to-room' into clie…
biplab1 Feb 14, 2025
8df6669
Merge branch 'kmp-impl' into client-dbflow-to-room
biplab1 Feb 18, 2025
fd61561
Merge branch 'kmp-impl' into client-dbflow-to-room
biplab1 Feb 20, 2025
f71dafd
refactor(core): update ClientDao and other files in :core:data and :c…
biplab1 Feb 20, 2025
c8ec92b
refactor: [database.group] dbflow to room (#2313)
itsPronay Feb 17, 2025
9f9c075
refactor: [database.center] dbFlow to room migration (#2307)
itsPronay Feb 17, 2025
484beaa
refactor: [database.office] dbflow to room (#2314)
itsPronay Feb 18, 2025
dd69852
refactor: [database/charge] dbflow to room (#2312)
itsPronay Feb 19, 2025
edae2af
Merge remote-tracking branch 'origin/kmp-impl' into kmp-impl
biplab1 Feb 20, 2025
a734ff9
Merge branch 'client-dbflow-to-room' of https://github.com/biplab1/an…
biplab1 Feb 20, 2025
bad2298
refactor(core:database): update ClientDaoHelper and ClientAccounts
biplab1 Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ package com.mifos.core.data.pagingSource

import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.mifos.core.entity.client.Charges
import com.mifos.room.entities.client.Charges
import com.mifos.core.network.datamanager.DataManagerCharge
import com.mifos.core.objects.clients.Page
import com.mifos.room.entities.client.Page
import kotlinx.coroutines.suspendCancellableCoroutine
import rx.Subscriber
import rx.android.schedulers.AndroidSchedulers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ package com.mifos.core.data.pagingSource

import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.mifos.core.entity.client.Client
import com.mifos.room.entities.client.Client
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.objects.clients.Page
import com.mifos.room.entities.client.Page
import rx.Subscriber
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package com.mifos.core.data.repository

import androidx.paging.PagingData
import com.mifos.core.entity.client.Charges
import com.mifos.room.entities.client.Charges
import kotlinx.coroutines.flow.Flow

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.client.Client
import com.mifos.room.entities.client.Client
import com.mifos.room.entities.accounts.ClientAccounts
import okhttp3.MultipartBody
import okhttp3.ResponseBody
import rx.Observable
import kotlinx.coroutines.flow.Flow

/**
* Created by Aditya Gupta on 06/08/23.
*/
interface ClientDetailsRepository {

fun uploadClientImage(id: Int, file: MultipartBody.Part?): Observable<ResponseBody>
fun uploadClientImage(id: Int, file: MultipartBody.Part?): Flow<ResponseBody>

fun deleteClientImage(clientId: Int): Observable<ResponseBody>
fun deleteClientImage(clientId: Int): Flow<ResponseBody>

suspend fun getClientAccounts(clientId: Int): ClientAccounts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.objects.noncoreobjects.IdentifierCreationResponse
import com.mifos.core.objects.noncoreobjects.IdentifierPayload
import com.mifos.core.objects.noncoreobjects.IdentifierTemplate
import com.mifos.room.entities.noncore.IdentifierCreationResponse
import com.mifos.room.entities.noncore.IdentifierPayload
import com.mifos.room.entities.noncore.IdentifierTemplate

/**
* Created by Aditya Gupta on 16/08/23.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.objects.noncoreobjects.Identifier
import com.mifos.room.entities.noncore.Identifier
import org.openapitools.client.models.DeleteClientsClientIdIdentifiersIdentifierIdResponse

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
package com.mifos.core.data.repository

import androidx.paging.PagingData
import com.mifos.core.entity.client.Client
import com.mifos.core.objects.clients.Page
import com.mifos.room.entities.client.Client
import com.mifos.room.entities.client.Page
import kotlinx.coroutines.flow.Flow
import rx.Observable

/**
* Created by Aditya Gupta on 08/08/23.
Expand All @@ -22,5 +21,5 @@ interface ClientListRepository {

fun getAllClients(): Flow<PagingData<Client>>

fun allDatabaseClients(): Observable<Page<Client>>
fun allDatabaseClients(): Flow<Page<Client>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.client.Client
import com.mifos.core.entity.client.ClientPayload
import com.mifos.core.entity.organisation.Office
import com.mifos.core.entity.organisation.Staff
import com.mifos.core.entity.templates.clients.ClientsTemplate
import com.mifos.room.entities.client.Client
import com.mifos.room.entities.client.ClientPayload
import com.mifos.room.entities.organisation.Office
import com.mifos.room.entities.organisation.Staff
import com.mifos.room.entities.templates.clients.ClientsTemplate
import okhttp3.MultipartBody
import okhttp3.ResponseBody
import rx.Observable
import kotlinx.coroutines.flow.Flow

/**
* Created by Aditya Gupta on 10/08/23.
*/
interface CreateNewClientRepository {

fun clientTemplate(): Observable<ClientsTemplate>
fun clientTemplate(): Flow<ClientsTemplate>

suspend fun offices(): List<Office>

suspend fun getStaffInOffice(officeId: Int): List<Staff>

fun createClient(clientPayload: ClientPayload): Observable<Client>
fun createClient(clientPayload: ClientPayload): Flow<Client>

fun uploadClientImage(id: Int, file: MultipartBody.Part?): Observable<ResponseBody>
fun uploadClientImage(id: Int, file: MultipartBody.Part?): Flow<ResponseBody>
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.mifos.core.data.pagingSource.ClientChargesPagingSource
import com.mifos.core.data.repository.ClientChargeRepository
import com.mifos.core.entity.client.Charges
import com.mifos.room.entities.client.Charges
import com.mifos.core.network.datamanager.DataManagerCharge
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
* Created by Aditya Gupta on 08/08/23.
*/
class ClientChargeRepositoryImp @Inject constructor(private val dataManagerCharge: DataManagerCharge) :
ClientChargeRepository {
class ClientChargeRepositoryImp @Inject constructor(
private val dataManagerCharge: DataManagerCharge,
) : ClientChargeRepository {

override fun getClientCharges(
clientId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.ClientDetailsRepository
import com.mifos.core.entity.client.Client
import com.mifos.room.entities.client.Client
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.room.entities.accounts.ClientAccounts
import kotlinx.coroutines.flow.Flow
import okhttp3.MultipartBody
import okhttp3.ResponseBody
import rx.Observable
import javax.inject.Inject

/**
* Created by Aditya Gupta on 06/08/23.
*/
class ClientDetailsRepositoryImp @Inject constructor(private val dataManagerClient: DataManagerClient) :
ClientDetailsRepository {
class ClientDetailsRepositoryImp @Inject constructor(
private val dataManagerClient: DataManagerClient,
) : ClientDetailsRepository {

override fun uploadClientImage(id: Int, file: MultipartBody.Part?): Observable<ResponseBody> {
override fun uploadClientImage(id: Int, file: MultipartBody.Part?): Flow<ResponseBody> {
return dataManagerClient.uploadClientImage(id, file)
}

override fun deleteClientImage(clientId: Int): Observable<ResponseBody> {
override fun deleteClientImage(clientId: Int): Flow<ResponseBody> {
return dataManagerClient.deleteClientImage(clientId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.ClientIdentifierDialogRepository
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.objects.noncoreobjects.IdentifierCreationResponse
import com.mifos.core.objects.noncoreobjects.IdentifierPayload
import com.mifos.core.objects.noncoreobjects.IdentifierTemplate
import com.mifos.room.entities.noncore.IdentifierCreationResponse
import com.mifos.room.entities.noncore.IdentifierPayload
import com.mifos.room.entities.noncore.IdentifierTemplate
import javax.inject.Inject

/**
* Created by Aditya Gupta on 16/08/23.
*/
class ClientIdentifierDialogRepositoryImp @Inject constructor(private val dataManagerClient: DataManagerClient) :
ClientIdentifierDialogRepository {
class ClientIdentifierDialogRepositoryImp @Inject constructor(
private val dataManagerClient: DataManagerClient,
) : ClientIdentifierDialogRepository {

override suspend fun getClientIdentifierTemplate(clientId: Int): IdentifierTemplate {
return dataManagerClient.getClientIdentifierTemplate(clientId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.ClientIdentifiersRepository
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.objects.noncoreobjects.Identifier
import com.mifos.room.entities.noncore.Identifier
import org.openapitools.client.models.DeleteClientsClientIdIdentifiersIdentifierIdResponse
import javax.inject.Inject

/**
* Created by Aditya Gupta on 08/08/23.
*/
class ClientIdentifiersRepositoryImp @Inject constructor(private val dataManagerClient: DataManagerClient) :
ClientIdentifiersRepository {
class ClientIdentifiersRepositoryImp @Inject constructor(
private val dataManagerClient: DataManagerClient,
) : ClientIdentifiersRepository {

override suspend fun getClientIdentifiers(clientId: Int): List<Identifier> {
return dataManagerClient.getClientIdentifiers(clientId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.mifos.core.data.pagingSource.ClientListPagingSource
import com.mifos.core.data.repository.ClientListRepository
import com.mifos.core.entity.client.Client
import com.mifos.room.entities.client.Client
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.objects.clients.Page
import com.mifos.room.entities.client.Page
import kotlinx.coroutines.flow.Flow
import rx.Observable
import javax.inject.Inject

/**
Expand All @@ -39,7 +38,7 @@ class ClientListRepositoryImp @Inject constructor(
).flow
}

override fun allDatabaseClients(): Observable<Page<Client>> {
override fun allDatabaseClients(): Flow<Page<Client>> {
return dataManagerClient.allDatabaseClients
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import com.mifos.core.entity.templates.clients.ClientsTemplate
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.network.datamanager.DataManagerOffices
import com.mifos.core.network.datamanager.DataManagerStaff
import kotlinx.coroutines.flow.Flow
import okhttp3.MultipartBody
import okhttp3.ResponseBody
import rx.Observable
import javax.inject.Inject

/**
Expand All @@ -32,7 +32,7 @@ class CreateNewClientRepositoryImp @Inject constructor(
private val dataManagerStaff: DataManagerStaff,
) : CreateNewClientRepository {

override fun clientTemplate(): Observable<ClientsTemplate> {
override fun clientTemplate(): Flow<ClientsTemplate> {
return dataManagerClient.clientTemplate
}

Expand All @@ -44,11 +44,11 @@ class CreateNewClientRepositoryImp @Inject constructor(
return dataManagerStaff.getStaffInOffice(officeId)
}

override fun createClient(clientPayload: ClientPayload): Observable<Client> {
override fun createClient(clientPayload: ClientPayload): Flow<Client> {
return dataManagerClient.createClient(clientPayload)
}

override fun uploadClientImage(id: Int, file: MultipartBody.Part?): Observable<ResponseBody> {
override fun uploadClientImage(id: Int, file: MultipartBody.Part?): Flow<ResponseBody> {
return dataManagerClient.uploadClientImage(id, file)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2024 Mifos Initiative
*
* 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/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.room.entities.client

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

/**
* Created by Rajan Maurya on 09/02/17.
*/
@Parcelize
data class ActivatePayload(
val activationDate: String? = null,

val dateFormat: String? = "dd MMMM YYYY",

val locale: String? = "en",
) : Parcelable
19 changes: 19 additions & 0 deletions core/database/src/main/java/com/mifos/room/entities/client/Page.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2024 Mifos Initiative
*
* 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/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.room.entities.client

/**
* Created by ishankhanna on 09/02/14.
*/
data class Page<T>(
val totalFilteredRecords: Int = 0,

val pageItems: List<T> = ArrayList(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2024 Mifos Initiative
*
* 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/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.room.entities.noncore

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

/**
* Created by ishankhanna on 03/07/14.
*/
@Parcelize
data class DocumentType(
val id: Int? = null,
val name: String? = null,

val active: Boolean? = null,

val mandatory: Boolean? = null,

val description: String? = null,

val position: Int? = null,
) : Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2024 Mifos Initiative
*
* 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/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.room.entities.noncore

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

/**
* Created by ishankhanna on 03/07/14.
*/
@Parcelize
data class Identifier(
val id: Int? = null,

val clientId: Int? = null,

val documentKey: String? = null,

val documentType: DocumentType? = null,

val description: String? = null,

val status: String? = null,
) : Parcelable
Loading
Loading