Skip to content

Commit

Permalink
update error message when fetching structures
Browse files Browse the repository at this point in the history
  • Loading branch information
bennsimon committed Sep 14, 2021
1 parent f943a1f commit 3c31278
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 36 deletions.
2 changes: 1 addition & 1 deletion opensrp-eusm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ android {
minSdkVersion androidMinSdkVersion
targetSdkVersion androidTargetSdkVersion
versionCode 1
versionName "0.1.2"
versionName "0.1.3"
multiDexEnabled true
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,37 @@ public EusmTaskingMapInteractor(TaskingMapActivityContract.Presenter presenter)

@Override
public void fetchLocations(String plan, String operationalArea, String point, Boolean locationComponentActive) {
appExecutors.diskIO().execute(new Runnable() {
@Override
public void run() {
Set<Location> operationalAreaLocations = getOperationalAreaLocations(new HashSet<>(Arrays.asList(operationalArea.split(PreferencesUtil.OPERATIONAL_AREA_SEPARATOR))));
appExecutors.diskIO().execute(() -> {
Set<Location> operationalAreaLocations = getOperationalAreaLocations(new HashSet<>(Arrays.asList(operationalArea.split(PreferencesUtil.OPERATIONAL_AREA_SEPARATOR))));

JSONObject featureCollection = null;
try {
featureCollection = createFeatureCollection();
if (!operationalAreaLocations.isEmpty()) {
List<StructureDetail> structureDetails = appStructureRepository
.fetchStructureDetails(null, operationalAreaLocations.stream().filter(location -> location.getId() != null).map(location -> location.getId()).collect(Collectors.toSet()), null, true, plan);
JSONObject featureCollection = null;
try {
featureCollection = createFeatureCollection();
if (!operationalAreaLocations.isEmpty()) {
List<StructureDetail> structureDetails = appStructureRepository
.fetchStructureDetails(null, operationalAreaLocations.stream().filter(location -> location.getId() != null).map(location -> location.getId()).collect(Collectors.toSet()), null, true, plan);

if (structureDetails != null && !structureDetails.isEmpty()) {
String features = geoJsonUtils.getGeoJsonFromStructureDetail(structureDetails);
featureCollection.put(TaskingConstants.GeoJSON.FEATURES, new JSONArray(features));
}
if (structureDetails != null && !structureDetails.isEmpty()) {
String features = geoJsonUtils.getGeoJsonFromStructureDetail(structureDetails);
featureCollection.put(TaskingConstants.GeoJSON.FEATURES, new JSONArray(features));
}
} catch (Exception e) {
Timber.e(e);
}
JSONObject finalFeatureCollection = featureCollection;
appExecutors.mainThread().execute(new Runnable() {
@Override
public void run() {
if (!operationalAreaLocations.isEmpty()) {
Feature operationalAreaFeature = Feature.fromJson(gson.toJson(operationalAreaLocations.stream().findFirst().orElse(null)));
if (locationComponentActive != null) {
getPresenter().onStructuresFetched(finalFeatureCollection, operationalAreaFeature, null, point, locationComponentActive);
} else {
getPresenter().onStructuresFetched(finalFeatureCollection, operationalAreaFeature, null);
}
} else {
getPresenter().onStructuresFetched(finalFeatureCollection, null, null);
}
}
});
} catch (Exception e) {
Timber.e(e);
}
JSONObject finalFeatureCollection = featureCollection;
appExecutors.mainThread().execute(() -> {
if (!operationalAreaLocations.isEmpty()) {
Feature operationalAreaFeature = Feature.fromJson(gson.toJson(operationalAreaLocations.stream().findFirst().orElse(null)));
if (locationComponentActive != null) {
getPresenter().onStructuresFetched(finalFeatureCollection, operationalAreaFeature, null, point, locationComponentActive);
} else {
getPresenter().onStructuresFetched(finalFeatureCollection, operationalAreaFeature, null);
}
} else {
getPresenter().onStructuresFetched(finalFeatureCollection, null, null);
}
});
});
}

Expand Down
6 changes: 3 additions & 3 deletions opensrp-eusm/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

<string name="next_page"><![CDATA[NEXT >>]]></string>
<string name="previous_page"><![CDATA[<< Previous]]></string>
<string name="product_serial_n_quantity">%s &#183; %s %s</string>
<string name="product_serial_n_quantity" translatable="false">%s &#183; %s %s</string>
<string name="product_serial_text">Serial # </string>
<string name="product_quantity_text">Qty: </string>
<string name="product_serial">Serial # %s</string>
Expand Down Expand Up @@ -146,8 +146,8 @@
<string name="stock_type_id_key" translatable="false">identifier</string>
<string name="ok_text">OK</string>
<string name="new_assignment_dialog_title">New Mission Assigned</string>
<string name="no_structures_found">There are no structures mapped to this operational area. Please add a point to begin</string>
<string name="fetch_location_and_structures_failed">This operational area has not been defined in the system. Please try to sync your device. Please contact the system administrator if that doesn\'t solve the issue noting the operational area number %1$s.</string>
<string name="no_structures_found">There are no active service points in this district.</string>
<string name="fetch_location_and_structures_failed">There are no active service points in this district.</string>
<string name="account_disabled">Account Disabled</string>
<string name="fetching_structure_title">Fetching Structure Details</string>
<string name="fetching_structure_message">Fetching Structure Details. Please wait</string>
Expand Down

0 comments on commit 3c31278

Please sign in to comment.