Skip to content

Commit

Permalink
Merge pull request #827 from opensrp/update_resolve_settings_server_v…
Browse files Browse the repository at this point in the history
…ersion

Update resolve settings server version
  • Loading branch information
dubdabasoduba committed Sep 2, 2021
2 parents 1f422d0 + 28f066a commit 2dfd11d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=4.3.19-SNAPSHOT
VERSION_NAME=4.3.20-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Core Application
Expand Down
2 changes: 1 addition & 1 deletion opensrp-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ dependencies {
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'

implementation 'org.smartregister:opensrp-client-utils:0.0.2-SNAPSHOT'
implementation 'org.smartregister:opensrp-client-utils:0.0.4-SNAPSHOT'

implementation 'org.smartregister:opensrp-plan-evaluator:1.6.0-SNAPSHOT'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,20 @@ public boolean hasExtraSettingsSync() {

/**
* Allows the user to define extra settings sync parameters
* This returns the parameters as a string
*
* @return settingsParams {@link List<String>}
* @return
*/
public String getExtraStringSettingsParameters() {
return "";
}


/**
* Allows the user to define extra settings sync parameters
* This returns the parameters as a string
*
* @return
*/
public List<String> getExtraSettingsParameters() {
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.smartregister.domain.SyncStatus;
import org.smartregister.repository.AllSharedPreferences;
import org.smartregister.service.HTTPAgent;
import org.smartregister.sync.intent.BaseSyncIntentService;
import org.smartregister.sync.intent.SettingsSyncIntentService;
import org.smartregister.util.JsonFormUtils;
import org.smartregister.util.Utils;
Expand Down Expand Up @@ -89,24 +90,23 @@ protected CoreLibrary getInstance() {
}

// will automatically use the resolve check

private void getExtraSettings(JSONArray settings, String accessToken) throws JSONException {
JSONArray completeExtraSettings = new JSONArray();
if (getInstance().getSyncConfiguration().hasExtraSettingsSync()) {
List<String> syncParams = getInstance().getSyncConfiguration().getExtraSettingsParameters();
if (syncParams.size() > 0) {
for (String params : syncParams) {
String url = SettingsSyncIntentService.SETTINGS_URL + "?" + params + "&" + AllConstants.SERVER_VERSION + "=" + sharedPreferences.fetchLastSettingsSyncTimeStamp() + "&" + AllConstants.RESOLVE + "=" + getInstance().getSyncConfiguration().resolveSettings();
JSONArray extraSettings = pullSettings(url, accessToken);
if (extraSettings != null) {
aggregateSettings(completeExtraSettings, extraSettings);
}
}

aggregateSettings(settings, completeExtraSettings);
if (getInstance().getSyncConfiguration() != null && getInstance().getSyncConfiguration().hasExtraSettingsSync()) {
String syncParams = getInstance().getSyncConfiguration().getExtraStringSettingsParameters();
BaseSyncIntentService.RequestParamsBuilder builder = new BaseSyncIntentService.RequestParamsBuilder().addParam(AllConstants.SERVER_VERSION, "0").addParam(AllConstants.RESOLVE, getInstance().getSyncConfiguration().resolveSettings());
String url = SettingsSyncIntentService.SETTINGS_URL + "?" + syncParams + "&" + builder.toString();
JSONArray extraSettings = pullSettings(url, accessToken);
if (extraSettings != null) {
aggregateSettings(completeExtraSettings, extraSettings);
}
}

aggregateSettings(settings, completeExtraSettings);
}


private void getGlobalSettings(JSONArray settings, String accessToken) throws JSONException {
JSONArray globalSettings = new JSONArray();
if (getInstance().getSyncConfiguration().hasGlobalSettings()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ public void testProcessIntent() throws JSONException {
Mockito.doReturn(new ArrayList<Setting>()).when(settings).getUnsyncedSettings();
Mockito.doReturn(SyncFilter.TEAM).when(syncSettingsServiceHelper).getSettingsSyncFilterParam();

List<String> params = new ArrayList<>();
params.add("locationId=location-uuid");

Mockito.doReturn(params).when(syncConfiguration).getExtraSettingsParameters();
Mockito.doReturn("locationId=location-uuid").when(syncConfiguration).getExtraStringSettingsParameters();
Mockito.doReturn(new Response<>(ResponseStatus.success, settingsResponse)).when(syncSettingsServiceHelper).getResponse(ArgumentMatchers.anyString(), ArgumentMatchers.anyString());
Mockito.doReturn(SAMPLE_TEST_TOKEN).when(syncSettingsServiceHelper).getAccessToken();

Expand Down

0 comments on commit 2dfd11d

Please sign in to comment.