Skip to content

Commit

Permalink
MIFOSAC-296 applied spotless and detekt on core:domain (#2258)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsPronay authored Dec 7, 2024
1 parent 009476d commit 086c5bb
Show file tree
Hide file tree
Showing 146 changed files with 1,326 additions and 470 deletions.
9 changes: 9 additions & 0 deletions core/domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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
*/
plugins {
alias(libs.plugins.mifos.android.library)
alias(libs.plugins.mifos.android.library.jacoco)
Expand Down
9 changes: 9 additions & 0 deletions core/domain/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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
-->
<manifest>

</manifest>
28 changes: 18 additions & 10 deletions core/domain/src/main/java/com/mifos/core/domain/di/UseCaseModule.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
/*
* 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.core.domain.di

import com.mifos.core.data.repository.LoginRepository
import com.mifos.core.domain.use_cases.LoginUseCase
import com.mifos.core.domain.use_cases.PasswordValidationUseCase
import com.mifos.core.domain.use_cases.UsernameValidationUseCase
import com.mifos.core.domain.use_cases.ValidateServerApiPathUseCase
import com.mifos.core.domain.use_cases.ValidateServerEndPointUseCase
import com.mifos.core.domain.use_cases.ValidateServerPortUseCase
import com.mifos.core.domain.use_cases.ValidateServerProtocolUseCase
import com.mifos.core.domain.use_cases.ValidateServerTenantUseCase
import com.mifos.core.domain.useCases.LoginUseCase
import com.mifos.core.domain.useCases.PasswordValidationUseCase
import com.mifos.core.domain.useCases.UsernameValidationUseCase
import com.mifos.core.domain.useCases.ValidateServerApiPathUseCase
import com.mifos.core.domain.useCases.ValidateServerEndPointUseCase
import com.mifos.core.domain.useCases.ValidateServerPortUseCase
import com.mifos.core.domain.useCases.ValidateServerProtocolUseCase
import com.mifos.core.domain.useCases.ValidateServerTenantUseCase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -41,5 +50,4 @@ object UseCaseModule {

@Provides
fun provideTenantValidationUseCase() = ValidateServerTenantUseCase()

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ActivateRepository
Expand All @@ -16,10 +25,9 @@ class ActivateCenterUseCase @Inject constructor(private val activateRepository:

suspend operator fun invoke(
centerId: Int,
centerPayload: ActivatePayload
centerPayload: ActivatePayload,
): Flow<Resource<PostCentersCenterIdResponse>> = callbackFlow {
try {

trySend(Resource.Loading())
activateRepository.activateCenter(centerId, centerPayload)
.subscribeOn(AndroidSchedulers.mainThread())
Expand All @@ -40,4 +48,4 @@ class ActivateCenterUseCase @Inject constructor(private val activateRepository:
trySend(Resource.Error(exception.message.toString()))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ActivateRepository
Expand All @@ -16,10 +25,9 @@ class ActivateClientUseCase @Inject constructor(private val activateRepository:

suspend operator fun invoke(
clientId: Int,
clientPayload: ActivatePayload
clientPayload: ActivatePayload,
): Flow<Resource<PostClientsClientIdResponse>> = callbackFlow {
try {

trySend(Resource.Loading())
activateRepository.activateClient(clientId, clientPayload)
.subscribeOn(AndroidSchedulers.mainThread())
Expand All @@ -40,4 +48,4 @@ class ActivateClientUseCase @Inject constructor(private val activateRepository:
trySend(Resource.Error(exception.message.toString()))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ActivateRepository
Expand All @@ -16,7 +25,7 @@ class ActivateGroupUseCase @Inject constructor(private val activateRepository: A

suspend operator fun invoke(
groupId: Int,
groupPayload: ActivatePayload
groupPayload: ActivatePayload,
): Flow<Resource<GenericResponse>> = callbackFlow {
try {
trySend(Resource.Loading())
Expand All @@ -39,4 +48,4 @@ class ActivateGroupUseCase @Inject constructor(private val activateRepository: A
trySend(Resource.Error(exception.message.toString()))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.SavingsPayload
import com.mifos.core.data.repository.SavingsAccountActivateRepository
import com.mifos.core.data.repository.SavingsAccountRepository
import com.mifos.core.network.GenericResponse
import com.mifos.core.objects.accounts.savings.Transaction_Table.savingsAccountId
import com.mifos.core.objects.client.Savings
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
Expand All @@ -20,7 +25,7 @@ import javax.inject.Inject
*/
class ActivateSavingsUseCase @Inject constructor(private val repository: SavingsAccountActivateRepository) {

suspend operator fun invoke(savingsAccountId : Int, request: HashMap<String, String>): Flow<Resource<GenericResponse>> =
suspend operator fun invoke(savingsAccountId: Int, request: HashMap<String, String>): Flow<Resource<GenericResponse>> =
callbackFlow {
try {
trySend(Resource.Loading())
Expand All @@ -45,4 +50,4 @@ class ActivateSavingsUseCase @Inject constructor(private val repository: Savings
send(Resource.Error(exception.message.toString()))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.PinPointClientRepository
Expand All @@ -12,15 +21,14 @@ class AddClientPinpointLocationUseCase @Inject constructor(private val pinPointC

suspend operator fun invoke(
clientId: Int,
address: ClientAddressRequest
address: ClientAddressRequest,
): Flow<Resource<GenericResponse>> = flow {
try {
emit(Resource.Loading())
val response = pinPointClientRepository.addClientPinpointLocation(clientId, address)
emit(Resource.Success(response))

} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.DataTableRowDialogRepository
Expand All @@ -12,16 +21,14 @@ class AddDataTableEntryUseCase @Inject constructor(private val repository: DataT
suspend operator fun invoke(
table: String,
entityId: Int,
payload: Map<String, String>
payload: Map<String, String>,
): Flow<Resource<GenericResponse>> = flow {
try {
emit(Resource.Loading())
val response = repository.addDataTableEntry(table, entityId, payload)
emit(Resource.Success(response))

} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.CenterPayload
import com.mifos.core.data.repository.SyncCenterPayloadsRepository
import com.mifos.core.objects.response.SaveResponse
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
Expand Down Expand Up @@ -42,4 +50,4 @@ class AllDatabaseCenterPayloadUseCase @Inject constructor(private val repository
trySend(Resource.Error(e.message.toString()))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.SyncGroupPayloadsRepository
Expand Down Expand Up @@ -31,7 +40,7 @@ class AllDatabaseGroupPayloadUseCase @Inject constructor(private val repository:
trySend(Resource.Error(e.message.toString()))
}

override fun onNext(groupPayloads: List<GroupPayload> ) {
override fun onNext(groupPayloads: List<GroupPayload>) {
trySend(Resource.Success(groupPayloads))
}
})
Expand All @@ -41,5 +50,4 @@ class AllDatabaseGroupPayloadUseCase @Inject constructor(private val repository:
trySend(Resource.Error(e.message.toString()))
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.SavingsAccountActivateRepository
import com.mifos.core.data.repository.SyncSavingsAccountTransactionRepository
import com.mifos.core.network.GenericResponse
import com.mifos.core.objects.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.core.objects.accounts.savings.Transaction_Table.savingsAccountId
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
Expand Down Expand Up @@ -44,4 +50,4 @@ class AllSavingsAccountTransactionsUseCase @Inject constructor(private val repos
send(Resource.Error(exception.message.toString()))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.core.domain.use_cases
/*
* 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.core.domain.useCases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.CheckerInboxRepository
Expand All @@ -18,4 +27,4 @@ class ApproveCheckerUseCase @Inject constructor(val repository: CheckerInboxRepo
emit(Resource.Error(exception.message.toString()))
}
}
}
}
Loading

0 comments on commit 086c5bb

Please sign in to comment.