diff --git a/gradle.properties b/gradle.properties index 16c6bd100..b34ce93e9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=4.3.23-SNAPSHOT +VERSION_NAME=4.3.24-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Core Application diff --git a/opensrp-app/src/main/java/org/smartregister/sync/helper/LocationServiceHelper.java b/opensrp-app/src/main/java/org/smartregister/sync/helper/LocationServiceHelper.java index cf15111c2..c618e0807 100644 --- a/opensrp-app/src/main/java/org/smartregister/sync/helper/LocationServiceHelper.java +++ b/opensrp-app/src/main/java/org/smartregister/sync/helper/LocationServiceHelper.java @@ -1,5 +1,27 @@ package org.smartregister.sync.helper; +import static org.smartregister.AllConstants.COUNT; +import static org.smartregister.AllConstants.JURISDICTION_IDS; +import static org.smartregister.AllConstants.LocationConstants.DISPLAY; +import static org.smartregister.AllConstants.LocationConstants.LOCATION; +import static org.smartregister.AllConstants.LocationConstants.LOCATIONS; +import static org.smartregister.AllConstants.LocationConstants.SPECIAL_TAG_FOR_OPENMRS_TEAM_MEMBERS; +import static org.smartregister.AllConstants.LocationConstants.TEAM; +import static org.smartregister.AllConstants.LocationConstants.UUID; +import static org.smartregister.AllConstants.OPERATIONAL_AREAS; +import static org.smartregister.AllConstants.PerformanceMonitoring.ACTION; +import static org.smartregister.AllConstants.PerformanceMonitoring.FETCH; +import static org.smartregister.AllConstants.PerformanceMonitoring.LOCATION_SYNC; +import static org.smartregister.AllConstants.PerformanceMonitoring.PUSH; +import static org.smartregister.AllConstants.PerformanceMonitoring.STRUCTURE; +import static org.smartregister.AllConstants.RETURN_COUNT; +import static org.smartregister.AllConstants.TYPE; +import static org.smartregister.util.PerformanceMonitoringUtils.addAttribute; +import static org.smartregister.util.PerformanceMonitoringUtils.clearTraceAttributes; +import static org.smartregister.util.PerformanceMonitoringUtils.initTrace; +import static org.smartregister.util.PerformanceMonitoringUtils.startTrace; +import static org.smartregister.util.PerformanceMonitoringUtils.stopTrace; + import android.content.Context; import android.text.TextUtils; @@ -45,28 +67,6 @@ import timber.log.Timber; -import static org.smartregister.AllConstants.COUNT; -import static org.smartregister.AllConstants.JURISDICTION_IDS; -import static org.smartregister.AllConstants.LocationConstants.DISPLAY; -import static org.smartregister.AllConstants.LocationConstants.LOCATION; -import static org.smartregister.AllConstants.LocationConstants.LOCATIONS; -import static org.smartregister.AllConstants.LocationConstants.SPECIAL_TAG_FOR_OPENMRS_TEAM_MEMBERS; -import static org.smartregister.AllConstants.LocationConstants.TEAM; -import static org.smartregister.AllConstants.LocationConstants.UUID; -import static org.smartregister.AllConstants.OPERATIONAL_AREAS; -import static org.smartregister.AllConstants.PerformanceMonitoring.ACTION; -import static org.smartregister.AllConstants.PerformanceMonitoring.FETCH; -import static org.smartregister.AllConstants.PerformanceMonitoring.LOCATION_SYNC; -import static org.smartregister.AllConstants.PerformanceMonitoring.PUSH; -import static org.smartregister.AllConstants.PerformanceMonitoring.STRUCTURE; -import static org.smartregister.AllConstants.RETURN_COUNT; -import static org.smartregister.AllConstants.TYPE; -import static org.smartregister.util.PerformanceMonitoringUtils.addAttribute; -import static org.smartregister.util.PerformanceMonitoringUtils.clearTraceAttributes; -import static org.smartregister.util.PerformanceMonitoringUtils.initTrace; -import static org.smartregister.util.PerformanceMonitoringUtils.startTrace; -import static org.smartregister.util.PerformanceMonitoringUtils.stopTrace; - public class LocationServiceHelper extends BaseHelper { public static final String LOCATION_STRUCTURE_URL = "/rest/location/sync"; @@ -467,22 +467,29 @@ public void fetchAllLocations(int recordCount) { }.getType() ); - for (Location location : locations) { - try { - location.setSyncStatus(BaseRepository.TYPE_Synced); - - locationRepository.addOrUpdate(location); - - for (LocationTag tag : location.getLocationTags()) { - LocationTag locationTag = new LocationTag(); - locationTag.setLocationId(location.getId()); - locationTag.setName(tag.getName()); + if (locations != null) { + for (Location location : locations) { + try { + location.setSyncStatus(BaseRepository.TYPE_Synced); - locationTagRepository.addOrUpdate(locationTag); + locationRepository.addOrUpdate(location); + if (location.getLocationTags() != null) { + for (LocationTag tag : location.getLocationTags()) { + LocationTag locationTag = new LocationTag(); + locationTag.setLocationId(location.getId()); + locationTag.setName(tag.getName()); + + locationTagRepository.addOrUpdate(locationTag); + } + } else { + Timber.e("Location tag is null"); + } + } catch (Exception e) { + Timber.e(e, "EXCEPTION %s", e.toString()); } - } catch (Exception e) { - Timber.e(e, "EXCEPTION %s", e.toString()); } + }else { + Timber.e("Locations are null"); } } catch (Exception e) { Timber.e(e, "EXCEPTION %s", e.toString()); diff --git a/opensrp-app/src/main/java/org/smartregister/sync/helper/ValidateAssignmentHelper.java b/opensrp-app/src/main/java/org/smartregister/sync/helper/ValidateAssignmentHelper.java index cb1e9dbd2..bb39a0046 100644 --- a/opensrp-app/src/main/java/org/smartregister/sync/helper/ValidateAssignmentHelper.java +++ b/opensrp-app/src/main/java/org/smartregister/sync/helper/ValidateAssignmentHelper.java @@ -181,8 +181,12 @@ protected void removeLocationsFromHierarchy(LocationTree locationTree, Set existingOrganizations, Set existingJurisdictions) { if (existingJurisdictions.isEmpty()) { LocationTree locationTree = gson.fromJson(settingsRepository.fetchANMLocation(), LocationTree.class); - for (String location : currentUserAssignment.getJurisdictions()) { - if (!locationTree.hasLocation(location)) return true; + if (locationTree != null) { + for (String location : currentUserAssignment.getJurisdictions()) { + if (!locationTree.hasLocation(location)) return true; + } + } else { + Timber.e("hasNewAssignments(): The location Tree is Null"); } return false; }