-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync practitioners of a role to device #769
base: add-reconfigurable-registers-and-profiles
Are you sure you want to change the base?
Sync practitioners of a role to device #769
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once this condition is satisfied, is it OK to break out of the loop for efficiency ?
@@ -140,6 +142,11 @@ protected LoginResponse doInBackground(Void... params) { | |||
} | |||
|
|||
} | |||
|
|||
// Save the registered ANM | |||
getOpenSRPContext().allSharedPreferences().updateANMUserName(mUsername); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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