forked from openMF/community-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataManagerDataTable.java
110 lines (93 loc) · 3.84 KB
/
DataManagerDataTable.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.mifos.api.datamanager;
import com.google.gson.JsonArray;
import com.mifos.api.BaseApiManager;
import com.mifos.api.GenericResponse;
import com.mifos.api.local.databasehelper.DatabaseHelperDataTable;
import com.mifos.objects.noncore.DataTable;
import com.mifos.objects.user.UserLocation;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import rx.Observable;
/**
* This DataManager is for Managing DataTable API, In which Request is going to Server
* and In Response, We are getting DataTable API Observable Response using Retrofit2
*
* Created by Rajan Maurya on 3/7/16.
*/
@Singleton
public class DataManagerDataTable {
public final BaseApiManager mBaseApiManager;
public final DatabaseHelperDataTable mDatabaseHelperDataTable;
@Inject
public DataManagerDataTable(BaseApiManager baseApiManager,
DatabaseHelperDataTable databaseHelperDataTable) {
mBaseApiManager = baseApiManager;
mDatabaseHelperDataTable = databaseHelperDataTable;
}
/**
* This Method Request the REST API of Datatable and In response give the List of DataTable
* for a given appTable
* Type of DataTable is
* 1. m_client
* 2. m_savings_account
* 3. m_loan
* @param appTableName App Table Name
* @return List<DataTable>
*/
public Observable<List<DataTable>> getDataTable(String appTableName) {
return mBaseApiManager.getDataTableApi().getTableOf(appTableName);
}
/**
* This Method Request the REST API of Datatable and In response give the DataTable with
* the given name.
* @param dataTableName DataTable Name
* @return DataTable
*/
public Observable<DataTable> getDataTableByDataTableName(String dataTableName) {
return mBaseApiManager.getDataTableApi().getTableOfByDataTableName(dataTableName);
}
public Observable<JsonArray> getDataTableInfo(String table, int entityId) {
return mBaseApiManager.getDataTableApi().getDataOfDataTable(table, entityId);
}
public Observable<GenericResponse> addDataTableEntry(
String table, int entityId, Map<String, Object> payload) {
return mBaseApiManager.getDataTableApi()
.createEntryInDataTable(table, entityId, payload);
}
public Observable<GenericResponse> updateEntryInDataTable(
String table, int entityId, Map<String, Object> payload) {
return mBaseApiManager.getDataTableApi()
.updateEntryInDataTable(table, entityId, payload);
}
public Observable<GenericResponse> updateEntryInMultiRowDataTable(
String table, long entityId, long rowId, Map<String, Object> payload) {
return mBaseApiManager.getDataTableApi()
.updateEntryInMultiRowDataTable(table, entityId, rowId, payload);
}
public Observable<GenericResponse> deleteDataTableEntry(String table, int entity, int rowId) {
return mBaseApiManager.getDataTableApi().deleteEntryOfDataTableManyToMany(
table, entity, rowId);
}
/**
* This Method is adding the User Tracking Data in the data Table "user_tracking"
*
* @param userId UserId Id
* @param userLocation UserLocation
* @return GenericResponse
*/
public Observable<GenericResponse> addUserPathTracking(int userId,
UserLocation userLocation) {
return mBaseApiManager.getDataTableApi().addUserPathTracking(userId, userLocation);
}
/**
* This Method is fetching the User Path Tracking from the DataTable "user_tracking"
*
* @param userId UserId Id
* @return List<UserLocation>
*/
public Observable<List<UserLocation>> getUserPathTracking(int userId) {
return mBaseApiManager.getDataTableApi().getUserPathTracking(userId);
}
}