Skip to content

Commit d00bee6

Browse files
committed
merged the entity branch
2 parents 86ddb7f + 9f03e29 commit d00bee6

File tree

140 files changed

+2448
-7196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+2448
-7196
lines changed

core/data/src/main/java/org/mifos/mobilewallet/core/data/fineract/entity/mapper/AccountMapper.java

-48
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.mifos.mobilewallet.core.data.fineract.entity.mapper
2+
3+
import com.mifos.mobilewallet.model.domain.Account
4+
import com.mifos.mobilewallet.model.entity.client.ClientAccounts
5+
import javax.inject.Inject
6+
7+
/**
8+
* Created by naman on 11/7/17.
9+
*/
10+
class AccountMapper @Inject constructor() {
11+
@JvmField
12+
@Inject
13+
var currencyMapper: CurrencyMapper? = null
14+
fun transform(clientAccounts: ClientAccounts?): List<Account> {
15+
val accountList: MutableList<Account> = ArrayList()
16+
if (clientAccounts != null && clientAccounts.savingsAccounts != null && clientAccounts.savingsAccounts.size != 0) {
17+
for (savingAccount in clientAccounts.savingsAccounts) {
18+
val account: Account = Account()
19+
account.name = savingAccount.productName
20+
account.number = savingAccount.accountNo
21+
account.id = savingAccount.id
22+
account.balance = savingAccount.accountBalance
23+
account.currency = currencyMapper!!.transform(savingAccount.currency)
24+
account.productId = savingAccount.productId.toLong()
25+
accountList.add(account)
26+
}
27+
}
28+
return accountList
29+
}
30+
}

core/data/src/main/java/org/mifos/mobilewallet/core/data/fineract/entity/mapper/ClientDetailsMapper.java

-59
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.mifos.mobilewallet.core.data.fineract.entity.mapper
2+
3+
import com.mifos.mobilewallet.model.entity.client.Client
4+
import javax.inject.Inject
5+
6+
/**
7+
* Created by naman on 10/7/17.
8+
*/
9+
class ClientDetailsMapper @Inject constructor() {
10+
fun transformList(clients: List<Client?>?): List<com.mifos.mobilewallet.model.domain.client.Client> {
11+
val clientList: MutableList<com.mifos.mobilewallet.model.domain.client.Client> = ArrayList()
12+
if (clients != null && clients.size != 0) {
13+
for (client in clients) {
14+
clientList.add(transform(client))
15+
}
16+
}
17+
return clientList
18+
}
19+
20+
fun transform(client: Client?): com.mifos.mobilewallet.model.domain.client.Client {
21+
val clientDetails = com.mifos.mobilewallet.model.domain.client.Client()
22+
if (client != null) {
23+
clientDetails.name = client.displayName
24+
clientDetails.clientId = client.id.toLong()
25+
clientDetails.externalId = client.externalId
26+
clientDetails.mobileNo = client.mobileNo
27+
}
28+
return clientDetails
29+
}
30+
}

core/data/src/main/java/org/mifos/mobilewallet/core/data/fineract/entity/mapper/CurrencyMapper.java

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.mifos.mobilewallet.core.data.fineract.entity.mapper
2+
3+
import com.mifos.mobilewallet.model.entity.accounts.savings.Currency
4+
import javax.inject.Inject
5+
6+
/**
7+
* Created by naman on 17/8/17.
8+
*/
9+
class CurrencyMapper @Inject internal constructor() {
10+
fun transform(savingsCurrency: Currency): com.mifos.mobilewallet.model.domain.Currency {
11+
val currency: com.mifos.mobilewallet.model.domain.Currency =
12+
com.mifos.mobilewallet.model.domain.Currency()
13+
currency.code = savingsCurrency.code
14+
currency.displayLabel = savingsCurrency.displayLabel
15+
currency.displaySymbol = savingsCurrency.displaySymbol
16+
return currency
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.mifos.mobilewallet.core.data.fineract.entity.mapper
2+
3+
import org.mifos.mobilewallet.core.base.UseCase
4+
import org.mifos.mobilewallet.core.data.fineract.entity.mapper.AccountMapper
5+
import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository
6+
import org.mifos.mobilewallet.core.utils.Constants
7+
import com.mifos.mobilewallet.model.domain.Account
8+
import com.mifos.mobilewallet.model.entity.client.ClientAccounts
9+
import rx.Subscriber
10+
import rx.android.schedulers.AndroidSchedulers
11+
import rx.schedulers.Schedulers
12+
13+
import javax.inject.Inject
14+
15+
class FetchAccount @Inject constructor(
16+
private val fineractRepository: FineractRepository
17+
) : UseCase<FetchAccount.RequestValues, FetchAccount.ResponseValue>() {
18+
19+
@Inject
20+
lateinit var accountMapper: AccountMapper
21+
22+
override fun executeUseCase(requestValues: RequestValues) {
23+
fineractRepository.getSelfAccounts(requestValues.clientId)
24+
.observeOn(AndroidSchedulers.mainThread())
25+
.subscribeOn(Schedulers.io())
26+
.subscribe(object : Subscriber<ClientAccounts>() {
27+
override fun onCompleted() {}
28+
29+
override fun onError(e: Throwable) {
30+
useCaseCallback.onError(Constants.ERROR_FETCHING_ACCOUNTS)
31+
}
32+
33+
override fun onNext(clientAccounts: ClientAccounts) {
34+
val accounts: List<Account> = accountMapper.transform(clientAccounts)
35+
if (accounts.isNotEmpty()) {
36+
var walletAccount: Account? = null
37+
for (account in accounts) {
38+
if (account.productId.toInt() == Constants.WALLET_ACCOUNT_SAVINGS_PRODUCT_ID) {
39+
walletAccount = account
40+
break
41+
}
42+
}
43+
if (walletAccount != null) {
44+
useCaseCallback.onSuccess(ResponseValue(walletAccount))
45+
} else {
46+
useCaseCallback.onError(Constants.NO_ACCOUNT_FOUND)
47+
}
48+
} else {
49+
useCaseCallback.onError(Constants.ERROR_FETCHING_ACCOUNT)
50+
}
51+
}
52+
})
53+
}
54+
55+
class RequestValues(val clientId: Long) : UseCase.RequestValues
56+
57+
class ResponseValue(val account: Account) : UseCase.ResponseValue
58+
}

core/data/src/main/java/org/mifos/mobilewallet/core/data/fineract/entity/mapper/SearchedEntitiesMapper.java

-43
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.mifos.mobilewallet.core.data.fineract.entity.mapper
2+
3+
import com.mifos.mobilewallet.model.domain.SearchResult
4+
import com.mifos.mobilewallet.model.entity.SearchedEntity
5+
import javax.inject.Inject
6+
7+
/**
8+
* Created by naman on 19/8/17.
9+
*/
10+
class SearchedEntitiesMapper @Inject internal constructor() {
11+
fun transformList(searchedEntities: List<SearchedEntity>?): List<SearchResult> {
12+
val searchResults: MutableList<SearchResult> = ArrayList()
13+
if (searchedEntities != null && searchedEntities.size != 0) {
14+
for (entity in searchedEntities) {
15+
searchResults.add(transform(entity))
16+
}
17+
}
18+
return searchResults
19+
}
20+
21+
fun transform(searchedEntity: SearchedEntity): SearchResult {
22+
val searchResult = SearchResult()
23+
searchResult.resultId = searchedEntity.entityId
24+
searchResult.resultName = searchedEntity.entityName
25+
searchResult.resultType = searchedEntity.entityType
26+
return searchResult
27+
}
28+
}

0 commit comments

Comments
 (0)