Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staff, search integration and major bugs fixes in client integration #1829

Merged
merged 1 commit into from
Aug 3, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ public Observable<GenericResponse> activateClient(int clientId,
response.setResponseFields(map);
return response;
});*/
// todo: this is work around to make older request work, changing YYYY to yyyy
clientActivate.setDateFormat("dd MMMM yyyy");
return mBaseApiManager.getClientsApi().activateClient(clientId, clientActivate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import com.mifos.api.BaseApiManager;
import com.mifos.api.local.databasehelper.DatabaseHelperNote;
import com.mifos.api.mappers.note.NoteMapper;
import com.mifos.objects.noncore.Note;

import org.apache.fineract.client.services.NotesApi;

import java.util.List;

import javax.inject.Inject;
Expand All @@ -21,19 +24,26 @@ public class DataManagerNote {

public final BaseApiManager mBaseApiManager;
public final DatabaseHelperNote mDatabaseHelperNote;
public final org.mifos.core.apimanager.BaseApiManager sdkBaseApiManager;

@Inject
public DataManagerNote(BaseApiManager baseApiManager,
DatabaseHelperNote databaseHelperNote) {
DatabaseHelperNote databaseHelperNote,
org.mifos.core.apimanager.BaseApiManager sdkBaseApiManager) {
mBaseApiManager = baseApiManager;
mDatabaseHelperNote = databaseHelperNote;
this.sdkBaseApiManager = sdkBaseApiManager;
}

private NotesApi getNotesApi() {
return sdkBaseApiManager.getNoteApi();
}

/**
* This Method Request the REST API of Note and In response give the List of Notes
*/
public Observable<List<Note>> getNotes(String entityType, int entityId) {
return mBaseApiManager.getNoteApi().getNotes(entityType, entityId);
return getNotesApi().retrieveNotesByResource(entityType, (long) entityId)
.map(NoteMapper.INSTANCE::mapFromEntityList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mifos.api.BaseApiManager;
import com.mifos.objects.SearchedEntity;

import org.apache.fineract.client.services.SearchApiApi;

import java.util.List;

import javax.inject.Inject;
Expand All @@ -17,14 +19,22 @@
public class DataManagerSearch {

public final BaseApiManager baseApiManager;
public final org.mifos.core.apimanager.BaseApiManager sdkBaseApiManager;

@Inject
public DataManagerSearch(BaseApiManager baseApiManager) {
public DataManagerSearch(BaseApiManager baseApiManager,
org.mifos.core.apimanager.BaseApiManager sdkBaseApiManager) {
this.baseApiManager = baseApiManager;
this.sdkBaseApiManager = sdkBaseApiManager;
}

private SearchApiApi getSearchApi() {
return sdkBaseApiManager.getSearchApi();
}

public Observable<List<SearchedEntity>> searchResources(String query, String resources,
Boolean exactMatch) {
// todo: invalid return type of method 'searchData'. It should be 'List<GetSearchResponse>'
return baseApiManager.getSearchApi().searchResources(query, resources, exactMatch);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

import com.mifos.api.BaseApiManager;
import com.mifos.api.local.databasehelper.DatabaseHelperStaff;
import com.mifos.api.mappers.staff.StaffMapper;
import com.mifos.objects.organisation.Staff;
import com.mifos.utils.PrefManager;

import org.apache.fineract.client.services.StaffApi;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;
import javax.inject.Singleton;

import rx.Observable;
import rx.functions.Func1;

/**
* Created by Rajan Maurya on 7/7/16.
Expand All @@ -22,14 +24,20 @@ public class DataManagerStaff {

public final BaseApiManager mBaseApiManager;
public final DatabaseHelperStaff mDatabaseHelperStaff;
public final org.mifos.core.apimanager.BaseApiManager sdkBaseApiManager;

@Inject
public DataManagerStaff(BaseApiManager baseApiManager,
DatabaseHelperStaff databaseHelperStaff) {
DatabaseHelperStaff databaseHelperStaff,
org.mifos.core.apimanager.BaseApiManager sdkBaseApiManager) {
mBaseApiManager = baseApiManager;
mDatabaseHelperStaff = databaseHelperStaff;
this.sdkBaseApiManager = sdkBaseApiManager;
}

private StaffApi getStaffApi() {
return sdkBaseApiManager.getStaffApi();
}

/**
* @param officeId
Expand All @@ -38,14 +46,13 @@ public DataManagerStaff(BaseApiManager baseApiManager,
public Observable<List<Staff>> getStaffInOffice(int officeId) {
switch (PrefManager.INSTANCE.getUserStatus()) {
case 0:
return mBaseApiManager.getStaffApi().getStaffForOffice(officeId)
.concatMap(new Func1<List<Staff>, Observable<? extends List<Staff>>>() {
@Override
public Observable<? extends List<Staff>> call(List<Staff> staffs) {
getStaffApi().retrieveAll16((long) officeId, null,
null, "all")
.map(StaffMapper.INSTANCE::mapFromEntityList)
.concatMap(staffs -> {
mDatabaseHelperStaff.saveAllStaffOfOffices(staffs);
return Observable.just(staffs);
}
});
});
case 1:
/**
* return all List of Staffs of Office from DatabaseHelperOffices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ object GetClientsClientIdAccsMapper: AbstractMapper<GetClientsClientIdAccountsRe
override fun mapFromEntity(entity: GetClientsClientIdAccountsResponse): ClientAccounts {
return ClientAccounts().apply {
savingsAccounts = entity.savingsAccounts?.let { SavingsAccMapper.mapFromEntityList(it) }
?: listOf()
loanAccounts = entity.loanAccounts?.let { LoanAccMapper.mapFromEntityList(it) }
?: listOf()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object ClientsClientIdResponseMapper: AbstractMapper<GetClientsClientIdResponse,
code = entity.status!!.code
value = entity.status!!.description
}
activationDate = entity.activationDate!!.toArray()
activationDate = entity.activationDate?.let { it.toArray() } ?: listOf()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ object TemplateMapper: AbstractMapper<GetClientsTemplateResponse, ClientsTemplat
return ClientsTemplate().apply {
activationDate = entity.activationDate!!.toIntArray()
officeId = entity.officeId!!
officeOptions = entity.officeOptions?.let { OfficeOptionMapper.mapFromEntityList(it) }
staffOptions = entity.staffOptions?.let { StaffOptionMapper.mapFromEntityList(it) }
officeOptions = entity.officeOptions?.let { OfficeOptionMapper.mapFromEntityList(it) } ?: listOf()
staffOptions = entity.staffOptions?.let { StaffOptionMapper.mapFromEntityList(it) } ?: listOf()
savingProductOptions = entity.savingProductOptions?.let {
SavingProductOptionMapper.mapFromEntityList(
it
)
}
} ?: listOf()
genderOptions = listOf()
clientTypeOptions = listOf()
clientClassificationOptions = listOf()
clientLegalFormOptions = listOf()
dataTables = entity.datatables?.let { ClientDataTableMapper.mapFromEntityList(it) }
dataTables = entity.datatables?.let { ClientDataTableMapper.mapFromEntityList(it) } ?: listOf()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.mifos.api.mappers.note

import com.mifos.objects.noncore.Note
import org.apache.fineract.client.models.GetResourceTypeResourceIdNotesResponse
import org.mifos.core.data.AbstractMapper
import java.util.*

object NoteMapper: AbstractMapper<GetResourceTypeResourceIdNotesResponse, Note>() {
override fun mapFromEntity(entity: GetResourceTypeResourceIdNotesResponse): Note {
return Note().apply {
id = entity.id!!
clientId = entity.clientId!!
noteContent = entity.note
createdById = entity.createdById!!
createdByUsername = entity.createdByUsername
createdOn = entity.createdOn!!.time
updatedById = entity.updatedById!!
updatedByUsername = entity.updatedByUsername
updatedOn = entity.updatedOn!!.time
}
}

override fun mapToEntity(domainModel: Note): GetResourceTypeResourceIdNotesResponse {
return GetResourceTypeResourceIdNotesResponse().apply {
id = domainModel.id
clientId = domainModel.clientId
note = domainModel.noteContent
createdById = domainModel.createdById
createdByUsername = domainModel.createdByUsername
createdOn = Date(domainModel.createdOn)
updatedById = domainModel.updatedById
updatedByUsername = domainModel.updatedByUsername
updatedOn = Date(domainModel.updatedOn)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.mifos.api.mappers.staff

import com.mifos.objects.organisation.Staff
import org.apache.fineract.client.models.RetrieveOneResponse
import org.mifos.core.data.AbstractMapper

object StaffMapper: AbstractMapper<RetrieveOneResponse, Staff>() {
override fun mapFromEntity(entity: RetrieveOneResponse): Staff {
return Staff().apply {
id = entity.id!!.toInt()
firstname = entity.firstname
lastname = entity.lastname
displayName = entity.displayName
officeId = entity.officeId!!.toInt()
officeName = entity.officeName
isLoanOfficer = entity.isLoanOfficer
isActive = entity.isActive
}
}

override fun mapToEntity(domainModel: Staff): RetrieveOneResponse {
return RetrieveOneResponse().apply {
id = domainModel.id.toLong()
firstname = domainModel.firstname
lastname = domainModel.lastname
displayName = domainModel.displayName
officeId = domainModel.officeId.toLong()
officeName = domainModel.officeName
isLoanOfficer = domainModel.isLoanOfficer
isActive = domainModel.isActive
}
}
}