forked from openMF/android-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: [database.staff] dbflow to room (openMF#2311)
* MIFOSAC-391 database.staff dbflow to room * remove suspend * made suggested changes * fix
- Loading branch information
Showing
11 changed files
with
134 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
core/database/src/main/java/com/mifos/room/dao/StaffDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2025 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.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import com.mifos.room.entities.organisation.Staff | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
/** | ||
* Created by Pronay Sarker on 14/02/2025 (1:54 AM) | ||
*/ | ||
@Dao | ||
interface StaffDao { | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun insertStaffs(staffs: List<Staff>) | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun insertStaff(staff: Staff) | ||
|
||
@Query("SELECT * FROM Staff WHERE officeId = :officeId") | ||
fun getAllStaff(officeId: Int): Flow<List<Staff>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
core/database/src/main/java/com/mifos/room/helper/StaffDaoHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2025 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.helper | ||
|
||
import com.mifos.room.dao.StaffDao | ||
import com.mifos.room.entities.organisation.Staff | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Pronay Sarker on 14/02/2025 (2:17 AM) | ||
*/ | ||
class StaffDaoHelper @Inject constructor( | ||
private val staffDao: StaffDao, | ||
) { | ||
suspend fun saveAllStaffOfOffices(staffs: List<Staff>) { | ||
staffDao.insertStaffs(staffs) | ||
} | ||
|
||
fun getAllStaffOffices(officeId: Int): Flow<List<Staff>> { | ||
return staffDao.getAllStaff(officeId) | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
...src/main/java/com/mifos/core/domain/useCases/GetStaffInOfficeForCreateNewClientUseCase.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters