Sync practitioners of a role to device#769
Sync practitioners of a role to device#769allan-on wants to merge 23 commits intoadd-reconfigurable-registers-and-profilesfrom
Conversation
- Add PractitionerRole and Practitioner models - Fetch practitioners and practitioner roles to map the current user practitioner-role - Save the current user practitioner-role-code in preferences Fixes tasks in opensrp/opensrp-client-goldsmith#80
…m:OpenSRP/opensrp-client-core into add-practitioner-role-in-preference
…oners-of-a-role-to-device
Refactored Toolbar configs to be merged in NavigationOptions
| public String getUserPractitionerRole() { | ||
| return preferences.getString(USER_PRACTITIONER_ROLE, null); | ||
| } | ||
|
|
||
| @Nullable | ||
| public String getUserPractitionerIdentifier() { | ||
| return preferences.getString(USER_PRACTITIONER_IDENTIFIER, null); | ||
| } | ||
|
|
||
| public void setUserPractitionerRole(String practitionerRole) { | ||
| preferences.edit().putString(USER_PRACTITIONER_ROLE, practitionerRole).commit(); | ||
| } | ||
|
|
||
| public void setUserPractitionerIdentifier(String identifier) { | ||
| preferences.edit().putString(USER_PRACTITIONER_IDENTIFIER, identifier).commit(); |
There was a problem hiding this comment.
OpenSRP supports multi tenancy on the same device where two user accounts can be active without requiring a data clearing or a fresh installation. Should then the preference keys here have the +username suffix like other user-dependent preference keys?
| public String getFormattedBaseUrl() { | ||
| String baseUrl = CoreLibrary.getInstance().context().configuration().dristhiBaseURL(); | ||
| String endString = "/"; | ||
| if (baseUrl.endsWith(endString)) { | ||
| baseUrl = baseUrl.substring(0, baseUrl.lastIndexOf(endString)); | ||
| } | ||
| return baseUrl; | ||
| } |
There was a problem hiding this comment.
Does this method exist anywhere else? Should it be refactored placed in a Utility class for shared use?
| private void initializeAdapter(Set<? extends IView> iviews) { | ||
| Set<IView> mySet = new HashSet<>(); | ||
|
|
||
| initializeAdapter(mySet); | ||
| } |
There was a problem hiding this comment.
Does this private method belong here?
|
|
||
| Practitioner loggedInPractitioner = null; | ||
| for (Practitioner practitioner : practitioners) { | ||
| if (practitioner != null && mUsername.equals(practitioner.getUsername())) { |
There was a problem hiding this comment.
Once this condition is satisfied, is it OK to break out of the loop for efficiency ?
|
|
||
| PractitionerRole loggedInPractitionerRole = null; | ||
| for (PractitionerRole practitionerRole : practitionerRoles) { | ||
| if (loggedInPractitioner.getIdentifier().equals(practitionerRole.getPractitionerIdentifier())) { |
There was a problem hiding this comment.
Once this condition is satisfied, is it OK to break out of the loop for efficiency ?
| } | ||
|
|
||
| // Save the registered ANM | ||
| getOpenSRPContext().allSharedPreferences().updateANMUserName(mUsername); |
There was a problem hiding this comment.
Is this call required here (maybe it is)?
It is also invoked at a later time once the authentication is successful, afterLoginCheck listener fires and this line is executed
Add syncing of (CHW) practitioners from the server as part of opensrp/opensrp-client-goldsmith#81