Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions core/data/src/main/java/com/mifos/core/data/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.mifos.core.data.repository.CheckerInboxTasksRepository
import com.mifos.core.data.repository.ClientChargeRepository
import com.mifos.core.data.repository.ClientIdentifiersRepository
import com.mifos.core.data.repository.CreateNewCenterRepository
import com.mifos.core.data.repository.DataTableDataRepository
import com.mifos.core.data.repository.DocumentListRepository
import com.mifos.core.data.repository.GroupDetailsRepository
import com.mifos.core.data.repository.GroupListRepository
Expand All @@ -33,6 +34,7 @@ import com.mifos.core.data.repository_imp.CheckerInboxTasksRepositoryImp
import com.mifos.core.data.repository_imp.ClientChargeRepositoryImp
import com.mifos.core.data.repository_imp.ClientIdentifiersRepositoryImp
import com.mifos.core.data.repository_imp.CreateNewCenterRepositoryImp
import com.mifos.core.data.repository_imp.DataTableDataRepositoryImp
import com.mifos.core.data.repository_imp.DocumentListRepositoryImp
import com.mifos.core.data.repository_imp.GroupDetailsRepositoryImp
import com.mifos.core.data.repository_imp.GroupListRepositoryImp
Expand Down Expand Up @@ -126,4 +128,7 @@ abstract class DataModule {

@Binds
internal abstract fun bindChargeDialogRepository(impl: ChargeDialogRepositoryImp): ChargeDialogRepository

@Binds
internal abstract fun bindDataTableDataRepository(impl: DataTableDataRepositoryImp): DataTableDataRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.mifos.core.data.repository

import com.google.gson.JsonArray
import org.apache.fineract.client.models.DeleteDataTablesDatatableAppTableIdDatatableIdResponse
import rx.Observable

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

suspend fun getDataTableInfo(table: String, entityId: Int): JsonArray

fun deleteDataTableEntry(
table: String?,
entity: Int,
rowId: Int
): Observable<DeleteDataTablesDatatableAppTableIdDatatableIdResponse>

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mifos.mifosxdroid.online.datatabledata
package com.mifos.core.data.repository_imp

import com.google.gson.JsonArray
import com.mifos.core.data.repository.DataTableDataRepository
import com.mifos.core.network.datamanager.DataManagerDataTable
import org.apache.fineract.client.models.DeleteDataTablesDatatableAppTableIdDatatableIdResponse
import rx.Observable
Expand All @@ -12,7 +13,7 @@ import javax.inject.Inject
class DataTableDataRepositoryImp @Inject constructor(private val dataManagerDataTable: DataManagerDataTable) :
DataTableDataRepository {

override fun getDataTableInfo(table: String?, entityId: Int): Observable<JsonArray> {
override suspend fun getDataTableInfo(table: String, entityId: Int): JsonArray {
return dataManagerDataTable.getDataTableInfo(table, entityId)
}

Expand All @@ -24,5 +25,4 @@ class DataTableDataRepositoryImp @Inject constructor(private val dataManagerData
return dataManagerDataTable.deleteDataTableEntry(table, entity, rowId)
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fun MifosScaffold(
Text(
text = it,
style = TextStyle(
fontSize = 12.sp,
fontSize = 24.sp,
fontWeight = FontWeight.Medium,
fontStyle = FontStyle.Normal
),
Expand Down
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.DataTableDataRepository
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import org.apache.fineract.client.models.DeleteDataTablesDatatableAppTableIdDatatableIdResponse
import rx.Subscriber
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers
import javax.inject.Inject

class DeleteDataTableEntryUseCase @Inject constructor(private val repository: DataTableDataRepository) {

suspend operator fun invoke(
table: String?,
entity: Int,
rowId: Int
): Flow<Resource<DeleteDataTablesDatatableAppTableIdDatatableIdResponse>> = callbackFlow {
try {
trySend(Resource.Loading())
repository.deleteDataTableEntry(table, entity, rowId)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object :
Subscriber<DeleteDataTablesDatatableAppTableIdDatatableIdResponse>() {
override fun onCompleted() {}

override fun onError(exception: Throwable) {
trySend(Resource.Error(exception.message.toString()))
}

override fun onNext(response: DeleteDataTablesDatatableAppTableIdDatatableIdResponse) {
trySend(Resource.Success(response))
}
})
awaitClose { channel.close() }

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.mifos.core.domain.use_cases

import com.google.gson.JsonArray
import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.DataTableDataRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetDataTableInfoUseCase @Inject constructor(private val repository: DataTableDataRepository) {

suspend operator fun invoke(table: String, entityId: Int): Flow<Resource<JsonArray>> = flow {
try {
emit(Resource.Loading())
val data = repository.getDataTableInfo(table, entityId)
emit(Resource.Success(data))

} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DataManagerDataTable @Inject constructor(
)
}

fun getDataTableInfo(table: String?, entityId: Int): Observable<JsonArray> {
suspend fun getDataTableInfo(table: String, entityId: Int): JsonArray {
return mBaseApiManager.dataTableApi.getDataOfDataTable(table, entityId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ interface DataTableService {
fun getTableOf(@Query("apptable") table: String?): Observable<List<DataTable>>

@GET(APIEndPoint.DATATABLES + "/{dataTableName}/{entityId}/")
fun getDataOfDataTable(
@Path("dataTableName") dataTableName: String?,
suspend fun getDataOfDataTable(
@Path("dataTableName") dataTableName: String,
@Path("entityId") entityId: Int
): Observable<JsonArray>
): JsonArray

//TODO Improve Body Implementation with Payload
@POST(APIEndPoint.DATATABLES + "/{dataTableName}/{entityId}/")
Expand Down
1 change: 1 addition & 0 deletions feature/data-table/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions feature/data-table/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
alias(libs.plugins.mifos.android.library.jacoco)
}

android {
namespace = "com.mifos.feature.data_table"
}

dependencies {

implementation(projects.core.data)
implementation(projects.core.domain)
implementation(projects.core.datastore)

// swipe refresh
implementation(libs.accompanist.permission)
implementation(libs.accompanist.swiperefresh)

implementation(libs.coil.kt.compose)
implementation(libs.androidx.paging.compose)

testImplementation(libs.hilt.android.testing)
testImplementation(projects.core.testing)

androidTestImplementation(projects.core.testing)

implementation(libs.androidx.material)
}
Empty file.
21 changes: 21 additions & 0 deletions feature/data-table/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mifos.feature.data_table

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.mifos.feature.data_table.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions feature/data-table/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Loading