diff --git a/configs b/configs
index 551a1929c..940b8339b 160000
--- a/configs
+++ b/configs
@@ -1 +1 @@
-Subproject commit 551a1929c6d6a0092b8df3ee41beee9e5ce64d40
+Subproject commit 940b8339b74c296bb48992643e83be28f084d952
diff --git a/pom.xml b/pom.xml
index daa053742..35ced4390 100755
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
opensrp-server-web
war
- 2.8.5-SNAPSHOT
+ 2.8.6-SNAPSHOT
opensrp-server-web
OpenSRP Server Web Application
https://github.com/OpenSRP/opensrp-server-web
@@ -26,7 +26,7 @@
5.2.2.RELEASE
always
1.5.1
- 2.11.4-SNAPSHOT
+ 2.11.5-SNAPSHOT
2.3.0-SNAPSHOT
2.0.1-SNAPSHOT
2.0.3-SNAPSHOT
diff --git a/src/main/java/org/opensrp/web/rest/v2/SettingResource.java b/src/main/java/org/opensrp/web/rest/v2/SettingResource.java
old mode 100644
new mode 100755
index cb97ab45a..21269caef
--- a/src/main/java/org/opensrp/web/rest/v2/SettingResource.java
+++ b/src/main/java/org/opensrp/web/rest/v2/SettingResource.java
@@ -42,6 +42,8 @@
import javax.servlet.http.HttpServletRequest;
+import static org.opensrp.web.Constants.LIMIT;
+
@Controller("settingResourceV2")
@RequestMapping(value = Constants.RestEndpointUrls.SETTINGS_V2_URL)
public class SettingResource {
@@ -50,6 +52,8 @@ public class SettingResource {
public static final String SETTING_IDENTIFIER = "identifier";
+ public static final String METADATA_VERSION = "metadata_version";
+
public static Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter()).create();
@@ -110,25 +114,40 @@ public ResponseEntity getAllSettings(HttpServletRequest request) {
String teamId = RestUtils.getStringFilter(AllConstants.Event.TEAM_ID, request);
String identifier = RestUtils.getStringFilter(SETTING_IDENTIFIER, request);
boolean resolveSettings = RestUtils.getBooleanFilter(AllConstants.Event.RESOLVE_SETTINGS, request);
+ String metadataVersion = RestUtils.getStringFilter(METADATA_VERSION, request);
+ String limit = RestUtils.getStringFilter(LIMIT, request);
Map> treeNodeHashMap = null;
if (StringUtils.isBlank(team) && StringUtils.isBlank(providerId) && StringUtils.isBlank(locationId)
- && StringUtils.isBlank(teamId) && StringUtils.isBlank(team) && StringUtils.isBlank(serverVersion)) {
+ && StringUtils.isBlank(teamId) && StringUtils.isBlank(team) && StringUtils.isBlank(serverVersion)
+ && StringUtils.isBlank(metadataVersion)) {
return new ResponseEntity<>("All parameters cannot be null for this endpoint",
RestUtils.getJSONUTF8Headers(), HttpStatus.BAD_REQUEST);
}
long lastSyncedServerVersion = 0L;
+ long lastMetadataVersion = 0L;
+ int pageLimit = 0;
if (StringUtils.isNotBlank(serverVersion)) {
lastSyncedServerVersion = Long.parseLong(serverVersion) + 1;
}
+ if (StringUtils.isNotBlank(metadataVersion)) {
+ lastMetadataVersion = Long.parseLong(metadataVersion);
+ }
+
+ if (StringUtils.isNotBlank(limit)) {
+ pageLimit = Integer.parseInt(limit);
+ }
+
SettingSearchBean settingQueryBean = new SettingSearchBean();
settingQueryBean.setTeam(team);
settingQueryBean.setTeamId(teamId);
settingQueryBean.setProviderId(providerId);
settingQueryBean.setLocationId(locationId);
settingQueryBean.setServerVersion(lastSyncedServerVersion);
+ settingQueryBean.setMetadataVersion(lastMetadataVersion);
+ settingQueryBean.setLimit(pageLimit);
if (StringUtils.isNotBlank(identifier)) {
settingQueryBean.setIdentifier(identifier);
}
diff --git a/src/test/java/org/opensrp/web/rest/v2/SettingResourceTest.java b/src/test/java/org/opensrp/web/rest/v2/SettingResourceTest.java
old mode 100644
new mode 100755
index f8b833ee2..b087bac94
--- a/src/test/java/org/opensrp/web/rest/v2/SettingResourceTest.java
+++ b/src/test/java/org/opensrp/web/rest/v2/SettingResourceTest.java
@@ -41,6 +41,8 @@
import java.util.ArrayList;
import java.util.List;
+import static org.opensrp.web.Constants.LIMIT;
+
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = TestWebContextLoader.class, locations = { "classpath:test-webmvc-config.xml", })
@ActiveProfiles(profiles = { "jedis", "postgres", "basic_auth" })
@@ -69,6 +71,7 @@ public class SettingResourceTest {
private final String locationTreeString = "{\"locationsHierarchy\":{\"map\":{\"02ebbc84-5e29-4cd5-9b79-c594058923e9\":{\"id"
+ "\":\"02ebbc84-5e29-4cd5-9b79-c594058923e9\",\"label\":\"Uganda\",\"node\":{\"locationId\":\"02ebbc84-5e29-4cd5-9b79-c594058923e9\",\"name\":\"Uganda\",\"tags\":[\"Country\"],\"voided\":false},\"children\":{\"8340315f-48e4-4768-a1ce-414532b4c49b\":{\"id\":\"8340315f-48e4-4768-a1ce-414532b4c49b\",\"label\":\"Kampala\",\"node\":{\"locationId\":\"8340315f-48e4-4768-a1ce-414532b4c49b\",\"name\":\"Kampala\",\"parentLocation\":{\"locationId\":\"02ebbc84-5e29-4cd5-9b79-c594058923e9\",\"name\":\"Uganda\",\"voided\":false},\"tags\":[\"District\"],\"voided\":false},\"children\":{\"b1ef8a0b-275b-43fc-a580-1e21ceb34c78\":{\"id\":\"b1ef8a0b-275b-43fc-a580-1e21ceb34c78\",\"label\":\"KCCA\",\"node\":{\"locationId\":\"b1ef8a0b-275b-43fc-a580-1e21ceb34c78\",\"name\":\"KCCA\",\"parentLocation\":{\"locationId\":\"8340315f-48e4-4768-a1ce-414532b4c49b\",\"name\":\"Kampala\",\"parentLocation\":{\"locationId\":\"02ebbc84-5e29-4cd5-9b79-c594058923e9\",\"name\":\"Uganda\",\"voided\":false},\"voided\":false},\"tags\":[\"County\"],\"voided\":false},\"children\":{\"4e188e6d-2ffb-4b25-85f9-b9fbf5010d40\":{\"id\":\"4e188e6d-2ffb-4b25-85f9-b9fbf5010d40\",\"label\":\"Central Division\",\"node\":{\"locationId\":\"4e188e6d-2ffb-4b25-85f9-b9fbf5010d40\",\"name\":\"Central Division\",\"parentLocation\":{\"locationId\":\"b1ef8a0b-275b-43fc-a580-1e21ceb34c78\",\"name\":\"KCCA\",\"parentLocation\":{\"locationId\":\"8340315f-48e4-4768-a1ce-414532b4c49b\",\"name\":\"Kampala\",\"voided\":false},\"voided\":false},\"tags\":[\"Sub-county\"],\"voided\":false},\"children\":{\"44de66fb-e6c6-4bae-92bb-386dfe626eba\":{\"id\":\"44de66fb-e6c6-4bae-92bb-386dfe626eba\",\"label\":\"Bukesa Urban Health Centre\",\"node\":{\"locationId\":\"44de66fb-e6c6-4bae-92bb-386dfe626eba\",\"name\":\"Bukesa Urban Health Centre\",\"parentLocation\":{\"locationId\":\"4e188e6d-2ffb-4b25-85f9-b9fbf5010d40\",\"name\":\"Central Division\",\"parentLocation\":{\"locationId\":\"b1ef8a0b-275b-43fc-a580-1e21ceb34c78\",\"name\":\"KCCA\",\"voided\":false},\"voided\":false},\"tags\":[\"Health Facility\"],\"voided\":false},\"children\":{\"982eb3f3-b7e3-450f-a38e-d067f2345212\":{\"id\":\"982eb3f3-b7e3-450f-a38e-d067f2345212\",\"label\":\"Jambula Girls School\",\"node\":{\"locationId\":\"982eb3f3-b7e3-450f-a38e-d067f2345212\",\"name\":\"Jambula Girls School\",\"parentLocation\":{\"locationId\":\"44de66fb-e6c6-4bae-92bb-386dfe626eba\",\"name\":\"Bukesa Urban Health Centre\",\"parentLocation\":{\"locationId\":\"4e188e6d-2ffb-4b25-85f9-b9fbf5010d40\",\"name\":\"Central Division\",\"voided\":false},\"voided\":false},\"tags\":[\"School\"],\"voided\":false},\"parent\":\"44de66fb-e6c6-4bae-92bb-386dfe626eba\"}},\"parent\":\"4e188e6d-2ffb-4b25-85f9-b9fbf5010d40\"}},\"parent\":\"b1ef8a0b-275b-43fc-a580-1e21ceb34c78\"}},\"parent\":\"8340315f-48e4-4768-a1ce-414532b4c49b\"}},\"parent\":\"02ebbc84-5e29-4cd5-9b79-c594058923e9\"}}}},\"parentChildren\":{\"8340315f-48e4-4768-a1ce-414532b4c49b\":[\"b1ef8a0b-275b-43fc-a580-1e21ceb34c78\"],\"02ebbc84-5e29-4cd5-9b79-c594058923e9\":[\"8340315f-48e4-4768-a1ce-414532b4c49b\"],\"b1ef8a0b-275b-43fc-a580-1e21ceb34c78\":[\"4e188e6d-2ffb-4b25-85f9-b9fbf5010d40\"],\"44de66fb-e6c6-4bae-92bb-386dfe626eba\":[\"982eb3f3-b7e3-450f-a38e-d067f2345212\"],\"4e188e6d-2ffb-4b25-85f9-b9fbf5010d40\":[\"44de66fb-e6c6-4bae-92bb-386dfe626eba\"]}}}";
+ private final static String METADATA_VERSION = "metadata_version";
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -130,6 +133,8 @@ public void testGetAllSettings() throws Exception {
config.setTeamId("TEAM-ID-123");
config.setIdentifier("setting_123");
config.setSettings(createSettingsList());
+ config.setMetadataVersion(0L);
+ config.setLimit(1000);
settingConfig.add(config);
SettingSearchBean settingSearchBean = new SettingSearchBean();
@@ -146,7 +151,10 @@ public void testGetAllSettings() throws Exception {
MvcResult result = mockMvc
.perform(MockMvcRequestBuilders.get(BASE_URL + "/").param(AllConstants.Event.TEAM_ID, EXPECTED_TEAM_ID)
.param(AllConstants.BaseEntity.SERVER_VERSIOIN, "15421904649873")
- .param(AllConstants.Event.LOCATION_ID, "123232"))
+ .param(AllConstants.Event.LOCATION_ID, "123232")
+ .param(LIMIT,"1000")
+ .param(METADATA_VERSION, "100")
+ )
.andExpect(MockMvcResultMatchers.status().isOk()).andReturn();
Mockito.verify(settingService)