-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved createNewGroup & syncGroupPayload to group module (#2175)
b moved createNewGroup & syncGroupPayload to group module
- Loading branch information
Showing
38 changed files
with
673 additions
and
343 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
3 changes: 2 additions & 1 deletion
3
...reatenewgroup/CreateNewGroupRepository.kt → ...ta/repository/CreateNewGroupRepository.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
2 changes: 1 addition & 1 deletion
2
...uppayloads/SyncGroupPayloadsRepository.kt → ...repository/SyncGroupPayloadsRepository.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
3 changes: 2 additions & 1 deletion
3
...tenewgroup/CreateNewGroupRepositoryImp.kt → ...sitory_imp/CreateNewGroupRepositoryImp.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
3 changes: 2 additions & 1 deletion
3
...ayloads/SyncGroupPayloadsRepositoryImp.kt → ...ory_imp/SyncGroupPayloadsRepositoryImp.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
45 changes: 45 additions & 0 deletions
45
core/domain/src/main/java/com/mifos/core/domain/use_cases/AllDatabaseGroupPayloadUseCase.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,45 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.SyncGroupPayloadsRepository | ||
import com.mifos.core.objects.group.GroupPayload | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Pronay Sarker on 02/08/2024 (12:04 AM) | ||
*/ | ||
class AllDatabaseGroupPayloadUseCase @Inject constructor(private val repository: SyncGroupPayloadsRepository) { | ||
|
||
suspend operator fun invoke(): Flow<Resource<List<GroupPayload>>> = | ||
callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
|
||
repository.allDatabaseGroupPayload() | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<List<GroupPayload>>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(e: Throwable) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
|
||
override fun onNext(groupPayloads: List<GroupPayload> ) { | ||
trySend(Resource.Success(groupPayloads)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
} catch (e: Exception) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
core/domain/src/main/java/com/mifos/core/domain/use_cases/CreateGroupUseCase.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,41 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.CreateNewGroupRepository | ||
import com.mifos.core.objects.group.GroupPayload | ||
import com.mifos.core.objects.response.SaveResponse | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
class CreateGroupUseCase @Inject constructor(private val repository: CreateNewGroupRepository) { | ||
|
||
suspend operator fun invoke(groupPayload : GroupPayload): Flow<Resource<SaveResponse>> = callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
|
||
repository.createGroup(groupPayload) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<SaveResponse>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(e: Throwable) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
|
||
override fun onNext(group: SaveResponse) { | ||
trySend(Resource.Success(group)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
} catch (e: Exception) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
core/domain/src/main/java/com/mifos/core/domain/use_cases/CreateNewGroupUseCase.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,46 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.CreateNewGroupRepository | ||
import com.mifos.core.objects.group.GroupPayload | ||
import com.mifos.core.objects.response.SaveResponse | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Pronay Sarker on 01/08/2024 (9:18 AM) | ||
*/ | ||
class CreateNewGroupUseCase @Inject constructor(private val repository: CreateNewGroupRepository) { | ||
|
||
suspend operator fun invoke(groupPayload: GroupPayload): Flow<Resource<SaveResponse>> = callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
|
||
repository.createGroup(groupPayload) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<SaveResponse>() { | ||
override fun onCompleted() { | ||
} | ||
|
||
override fun onError(e: Throwable) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
|
||
override fun onNext(saveResponse: SaveResponse) { | ||
trySend(Resource.Success(saveResponse)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
} | ||
catch (e: Exception){ | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...omain/src/main/java/com/mifos/core/domain/use_cases/DeleteAndUpdateGroupPayloadUseCase.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,49 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.CenterPayload | ||
import com.mifos.core.data.repository.CreateNewCenterRepository | ||
import com.mifos.core.data.repository.SyncGroupPayloadsRepository | ||
import com.mifos.core.domain.R | ||
import com.mifos.core.objects.group.GroupPayload | ||
import com.mifos.core.objects.response.SaveResponse | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Pronay Sarker on 01/08/2024 (9:13 PM) | ||
*/ | ||
class DeleteAndUpdateGroupPayloadUseCase @Inject constructor(private val repository: SyncGroupPayloadsRepository) { | ||
|
||
suspend operator fun invoke(id: Int): Flow<Resource<List<GroupPayload>>> = | ||
callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
|
||
repository.deleteAndUpdateGroupPayloads(id) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<List<GroupPayload>>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(e: Throwable) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
|
||
override fun onNext(groupPayloads: List<GroupPayload>) { | ||
trySend(Resource.Success(groupPayloads)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
} catch (e: Exception) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
core/domain/src/main/java/com/mifos/core/domain/use_cases/GetGroupOfficesUseCase.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,48 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.CreateNewGroupRepository | ||
import com.mifos.core.data.repository.GroupListRepository | ||
import com.mifos.core.objects.organisation.Office | ||
import com.mifos.core.objects.zipmodels.GroupAndGroupAccounts | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import kotlinx.coroutines.flow.flow | ||
import rx.Observable | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Pronay Sarker on 01/08/2024 (8:23 AM) | ||
*/ | ||
|
||
class GetGroupOfficesUseCase @Inject constructor(private val repository: CreateNewGroupRepository) { | ||
|
||
suspend operator fun invoke(): Flow<Resource<List<Office>>> = callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
|
||
repository.offices() | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<List<Office>>() { | ||
override fun onCompleted() { } | ||
|
||
override fun onError(e: Throwable) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
|
||
override fun onNext(offices: List<Office>) { | ||
trySend(Resource.Success(offices)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
} catch (e: Exception) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
core/domain/src/main/java/com/mifos/core/domain/use_cases/UpdateGroupPayloadUseCase.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,45 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.SyncGroupPayloadsRepository | ||
import com.mifos.core.objects.group.GroupPayload | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Pronay Sarker on 01/08/2024 (10:26 PM) | ||
*/ | ||
class UpdateGroupPayloadUseCase @Inject constructor(private val repository: SyncGroupPayloadsRepository) { | ||
|
||
suspend operator fun invoke(groupPayload : GroupPayload): Flow<Resource<GroupPayload>> = | ||
callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
|
||
repository.updateGroupPayload(groupPayload) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<GroupPayload>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(e: Throwable) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
|
||
override fun onNext(groupPayload: GroupPayload) { | ||
trySend(Resource.Success(groupPayload)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
} catch (e: Exception) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.