Skip to content
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

AC-608: rename data source to repositories #589

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Sun Feb 24 23:38:58 IST 2019
#Tue May 28 17:27:49 MSK 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dist
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.openmrs.mobile.activities.BasePresenter;
import org.openmrs.mobile.api.RestApi;
import org.openmrs.mobile.api.RestServiceBuilder;
import org.openmrs.mobile.api.retrofit.PatientApi;
import org.openmrs.mobile.api.repository.PatientRepository;
import org.openmrs.mobile.dao.PatientDAO;
import org.openmrs.mobile.listeners.retrofit.DefaultResponseCallbackListener;
import org.openmrs.mobile.models.Module;
Expand All @@ -44,7 +44,7 @@ public class AddEditPatientPresenter extends BasePresenter implements AddEditPat

private final AddEditPatientContract.View mPatientInfoView;

private PatientApi patientApi;
private PatientRepository patientRepository;
private RestApi restApi;
private Patient mPatient;
private String patientToUpdateId;
Expand All @@ -58,15 +58,15 @@ public AddEditPatientPresenter(AddEditPatientContract.View mPatientInfoView,
this.mPatientInfoView.setPresenter(this);
this.mCountries = countries;
this.patientToUpdateId = patientToUpdateId;
this.patientApi = new PatientApi();
this.patientRepository = new PatientRepository();
this.restApi = RestServiceBuilder.createService(RestApi.class);
}

public AddEditPatientPresenter(AddEditPatientContract.View mPatientInfoView, PatientApi patientApi,
public AddEditPatientPresenter(AddEditPatientContract.View mPatientInfoView, PatientRepository patientRepository,
Patient mPatient, String patientToUpdateId,
List<String> mCountries, RestApi restApi) {
this.mPatientInfoView = mPatientInfoView;
this.patientApi = patientApi;
this.patientRepository = patientRepository;
this.mPatient = mPatient;
this.patientToUpdateId = patientToUpdateId;
this.mCountries = mCountries;
Expand Down Expand Up @@ -195,7 +195,7 @@ private boolean validate(Patient patient) {

@Override
public void registerPatient() {
patientApi.registerPatient(mPatient, new DefaultResponseCallbackListener() {
patientRepository.registerPatient(mPatient, new DefaultResponseCallbackListener() {
@Override
public void onResponse() {
mPatientInfoView.startPatientDashbordActivity(mPatient);
Expand All @@ -212,7 +212,7 @@ public void onErrorResponse(String errorMessage) {

@Override
public void updatePatient(Patient patient) {
patientApi.updatePatient(patient, new DefaultResponseCallbackListener() {
patientRepository.updatePatient(patient, new DefaultResponseCallbackListener() {
@Override
public void onResponse() {
mPatientInfoView.finishPatientInfoActivity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import org.openmrs.mobile.R;
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardActivity;
import org.openmrs.mobile.api.retrofit.VisitApi;
import org.openmrs.mobile.api.repository.VisitRepository;
import org.openmrs.mobile.dao.PatientDAO;
import org.openmrs.mobile.models.Patient;
import org.openmrs.mobile.utilities.ApplicationConstants;
Expand Down Expand Up @@ -124,8 +124,8 @@ private void downloadPatient(Patient patient) {
new PatientDAO().savePatient(patient)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(id -> {
new VisitApi().syncVisitsData(patient);
new VisitApi().syncLastVitals(patient.getUuid());
new VisitRepository().syncVisitsData(patient);
new VisitRepository().syncLastVitals(patient.getUuid());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import android.widget.TextView;

import org.openmrs.mobile.R;
import org.openmrs.mobile.api.retrofit.PatientApi;
import org.openmrs.mobile.api.retrofit.VisitApi;
import org.openmrs.mobile.api.repository.PatientRepository;
import org.openmrs.mobile.api.repository.VisitRepository;
import org.openmrs.mobile.dao.PatientDAO;
import org.openmrs.mobile.listeners.retrofit.DownloadPatientCallbackListener;
import org.openmrs.mobile.models.Patient;
Expand Down Expand Up @@ -345,14 +345,14 @@ public void setUpCheckBoxLogic(final PatientViewHolder holder, final Patient pat
}

private void downloadPatient(final Patient patient, final Boolean showSnackBar) {
new PatientApi().downloadPatientByUuid(patient.getUuid(), new DownloadPatientCallbackListener() {
new PatientRepository().downloadPatientByUuid(patient.getUuid(), new DownloadPatientCallbackListener() {
@Override
public void onPatientDownloaded(Patient newPatient) {
new PatientDAO().savePatient(newPatient)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(id -> {
new VisitApi().syncVisitsData(newPatient);
new VisitApi().syncLastVitals(newPatient.getUuid());
new VisitRepository().syncVisitsData(newPatient);
new VisitRepository().syncLastVitals(newPatient.getUuid());
patients.remove(patient);
notifyDataSetChanged();
if (showSnackBar) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.openmrs.mobile.api.RestApi;
import org.openmrs.mobile.api.RestServiceBuilder;
import org.openmrs.mobile.api.UserService;
import org.openmrs.mobile.api.retrofit.VisitApi;
import org.openmrs.mobile.api.repository.VisitRepository;
import org.openmrs.mobile.application.OpenMRS;
import org.openmrs.mobile.application.OpenMRSLogger;
import org.openmrs.mobile.dao.LocationDAO;
Expand Down Expand Up @@ -49,7 +49,7 @@
public class LoginPresenter extends BasePresenter implements LoginContract.Presenter {

private RestApi restApi;
private VisitApi visitApi;
private VisitRepository visitRepository;
private UserService userService;
private LoginContract.View loginView;
private OpenMRS mOpenMRS;
Expand All @@ -66,15 +66,15 @@ public LoginPresenter(LoginContract.View loginView, OpenMRS openMRS) {
this.authorizationManager = new AuthorizationManager();
this.locationDAO = new LocationDAO();
this.restApi = RestServiceBuilder.createService(RestApi.class);
this.visitApi = new VisitApi();
this.visitRepository = new VisitRepository();
this.userService = new UserService();
}

public LoginPresenter(RestApi restApi, VisitApi visitApi, LocationDAO locationDAO,
public LoginPresenter(RestApi restApi, VisitRepository visitRepository, LocationDAO locationDAO,
UserService userService, LoginContract.View loginView, OpenMRS mOpenMRS,
OpenMRSLogger mLogger, AuthorizationManager authorizationManager) {
this.restApi = restApi;
this.visitApi = visitApi;
this.visitRepository = visitRepository;
this.locationDAO = locationDAO;
this.userService = userService;
this.loginView = loginView;
Expand Down Expand Up @@ -139,7 +139,7 @@ public void onResponse(@NonNull Call<Session> call, @NonNull Response<Session> r
mOpenMRS.setPasswordAndHashedPassword(password);
}

visitApi.getVisitType(new GetVisitTypeCallbackListener() {
visitRepository.getVisitType(new GetVisitTypeCallbackListener() {
@Override
public void onGetVisitTypeResponse(VisitType visitType) {
OpenMRS.getInstance().setVisitTypeUUID(visitType.getUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.openmrs.mobile.activities.BasePresenter;
import org.openmrs.mobile.api.RestApi;
import org.openmrs.mobile.api.RestServiceBuilder;
import org.openmrs.mobile.api.retrofit.PatientApi;
import org.openmrs.mobile.api.repository.PatientRepository;
import org.openmrs.mobile.dao.PatientDAO;
import org.openmrs.mobile.models.Patient;
import org.openmrs.mobile.models.PatientDto;
Expand All @@ -39,7 +39,7 @@ public class MatchingPatientsPresenter extends BasePresenter implements Matching

private RestApi restApi;
private PatientDAO patientDAO;
private PatientApi patientApi;
private PatientRepository patientRepository;
private MatchingPatientsContract.View view;
private Queue<PatientAndMatchingPatients> matchingPatientsList;
private Patient selectedPatient;
Expand All @@ -49,17 +49,17 @@ public MatchingPatientsPresenter(MatchingPatientsContract.View view, Queue<Patie
this.matchingPatientsList = matchingPatientsList;
this.restApi = RestServiceBuilder.createService(RestApi.class);
this.patientDAO = new PatientDAO();
this.patientApi = new PatientApi();
this.patientRepository = new PatientRepository();
this.view.setPresenter(this);
}

public MatchingPatientsPresenter(MatchingPatientsContract.View view, Queue<PatientAndMatchingPatients> matchingPatientsList,
RestApi restApi, PatientDAO patientDAO, PatientApi patientApi) {
RestApi restApi, PatientDAO patientDAO, PatientRepository patientRepository) {
this.view = view;
this.matchingPatientsList = matchingPatientsList;
this.restApi = restApi;
this.patientDAO = patientDAO;
this.patientApi = patientApi;
this.patientRepository = patientRepository;
this.view.setPresenter(this);
}

Expand Down Expand Up @@ -126,7 +126,7 @@ public void onFailure(@NonNull Call<PatientDto> call, @NonNull Throwable t) {
@Override
public void registerNewPatient() {
final Patient patient = matchingPatientsList.poll().getPatient();
patientApi.syncPatient(patient);
patientRepository.syncPatient(patient);
removeSelectedPatient();
if (matchingPatientsList.peek() != null) {
subscribe();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import org.openmrs.mobile.R;
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardContract;
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardMainPresenterImpl;
import org.openmrs.mobile.api.retrofit.PatientApi;
import org.openmrs.mobile.api.retrofit.VisitApi;
import org.openmrs.mobile.api.repository.PatientRepository;
import org.openmrs.mobile.api.repository.VisitRepository;
import org.openmrs.mobile.dao.PatientDAO;
import org.openmrs.mobile.listeners.retrofit.DefaultResponseCallbackListener;
import org.openmrs.mobile.listeners.retrofit.DownloadPatientCallbackListener;
Expand All @@ -28,26 +28,26 @@
public class PatientDashboardDetailsPresenter extends PatientDashboardMainPresenterImpl implements PatientDashboardContract.PatientDetailsPresenter {

private PatientDashboardContract.ViewPatientDetails mPatientDetailsView;
private VisitApi visitApi;
private PatientApi patientApi;
private VisitRepository visitRepository;
private PatientRepository patientRepository;
private PatientDAO patientDAO;

public PatientDashboardDetailsPresenter(String id,
PatientDashboardContract.ViewPatientDetails mPatientDetailsView) {
this.mPatientDetailsView = mPatientDetailsView;
this.visitApi = new VisitApi();
this.patientApi = new PatientApi();
this.visitRepository = new VisitRepository();
this.patientRepository = new PatientRepository();
this.patientDAO = new PatientDAO();
this.mPatient = patientDAO.findPatientByID(id);
this.mPatientDetailsView.setPresenter(this);
}

public PatientDashboardDetailsPresenter(Patient mPatient, PatientDAO patientDAO,
PatientDashboardContract.ViewPatientDetails mPatientDetailsView,
VisitApi visitApi, PatientApi patientApi) {
VisitRepository visitRepository, PatientRepository patientRepository) {
this.mPatientDetailsView = mPatientDetailsView;
this.visitApi = visitApi;
this.patientApi = patientApi;
this.visitRepository = visitRepository;
this.patientRepository = patientRepository;
this.patientDAO = patientDAO;
this.mPatient = mPatient;
this.mPatientDetailsView.setPresenter(this);
Expand Down Expand Up @@ -105,14 +105,14 @@ public void subscribe() {
* Sync Vitals
*/
private void syncVitalsData() {
visitApi.syncLastVitals(mPatient.getUuid());
visitRepository.syncLastVitals(mPatient.getUuid());
}

/*
* Sync Visits
*/
private void syncVisitsData() {
visitApi.syncVisitsData(mPatient, new DefaultResponseCallbackListener() {
visitRepository.syncVisitsData(mPatient, new DefaultResponseCallbackListener() {
@Override
public void onResponse() {
mPatientDetailsView.showToast(R.string.synchronize_patient_successful, false);
Expand All @@ -131,7 +131,7 @@ public void onErrorResponse(String errorMessage) {
* Download Patient
*/
private void syncDetailsData() {
patientApi.downloadPatientByUuid(mPatient.getUuid(), new DownloadPatientCallbackListener() {
patientRepository.downloadPatientByUuid(mPatient.getUuid(), new DownloadPatientCallbackListener() {
@Override
public void onPatientDownloaded(Patient patient) {
updatePatientData(patient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import org.openmrs.mobile.activities.patientdashboard.PatientDashboardContract;
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardMainPresenterImpl;
import org.openmrs.mobile.api.retrofit.VisitApi;
import org.openmrs.mobile.api.repository.VisitRepository;
import org.openmrs.mobile.dao.PatientDAO;
import org.openmrs.mobile.dao.VisitDAO;
import org.openmrs.mobile.listeners.retrofit.DefaultResponseCallbackListener;
Expand All @@ -30,23 +30,23 @@ public class PatientDashboardVisitsPresenter extends PatientDashboardMainPresent

private PatientDashboardContract.ViewPatientVisits mPatientVisitsView;
private VisitDAO visitDAO;
private VisitApi visitApi;
private VisitRepository visitRepository;

public PatientDashboardVisitsPresenter(String id, PatientDashboardContract.ViewPatientVisits mPatientVisitsView) {
this.mPatient = new PatientDAO().findPatientByID(id);
this.mPatientVisitsView = mPatientVisitsView;
this.mPatientVisitsView.setPresenter(this);
this.visitDAO = new VisitDAO();
this.visitApi = new VisitApi();
this.visitRepository = new VisitRepository();
}

public PatientDashboardVisitsPresenter(Patient patient,
PatientDashboardContract.ViewPatientVisits mPatientVisitsView,
VisitDAO visitDAO,
VisitApi visitApi) {
VisitRepository visitRepository) {
this.mPatient = patient;
this.mPatientVisitsView = mPatientVisitsView;
this.visitApi = visitApi;
this.visitRepository = visitRepository;
this.visitDAO = visitDAO;
this.mPatientVisitsView.setPresenter(this);
}
Expand Down Expand Up @@ -85,7 +85,7 @@ public void getVisitFromDB(){

public void getVisitFromServer(){
if (NetworkUtils.isOnline()) {
new VisitApi().syncVisitsData(mPatient, new DefaultResponseCallbackListener() {
new VisitRepository().syncVisitsData(mPatient, new DefaultResponseCallbackListener() {
@Override
public void onResponse() {
getVisitFromDB();
Expand Down Expand Up @@ -119,7 +119,7 @@ public void showStartVisitDialog() {
@Override
public void syncVisits() {
mPatientVisitsView.showStartVisitProgressDialog();
visitApi.syncVisitsData(mPatient, new DefaultResponseCallbackListener() {
visitRepository.syncVisitsData(mPatient, new DefaultResponseCallbackListener() {
@Override
public void onResponse() {
addSubscription(visitDAO.getVisitsByPatientID(mPatient.getId())
Expand All @@ -141,7 +141,7 @@ public void onErrorResponse(String errorMessage) {
@Override
public void startVisit() {
mPatientVisitsView.showStartVisitProgressDialog();
visitApi.startVisit(mPatient, new StartVisitResponseListenerCallback() {
visitRepository.startVisit(mPatient, new StartVisitResponseListenerCallback() {
@Override
public void onStartVisitResponse(long id) {
mPatientVisitsView.goToVisitDashboard(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import org.openmrs.mobile.activities.patientdashboard.PatientDashboardContract;
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardMainPresenterImpl;
import org.openmrs.mobile.api.retrofit.VisitApi;
import org.openmrs.mobile.api.repository.VisitRepository;
import org.openmrs.mobile.dao.EncounterDAO;
import org.openmrs.mobile.dao.PatientDAO;
import org.openmrs.mobile.listeners.retrofit.DefaultResponseCallbackListener;
Expand All @@ -28,24 +28,24 @@
public class PatientDashboardVitalsPresenter extends PatientDashboardMainPresenterImpl implements PatientDashboardContract.PatientVitalsPresenter {

private EncounterDAO encounterDAO;
private VisitApi visitApi;
private VisitRepository visitRepository;
private PatientDashboardContract.ViewPatientVitals mPatientVitalsView;

public PatientDashboardVitalsPresenter(String id, PatientDashboardContract.ViewPatientVitals mPatientVitalsView) {
this.mPatient = new PatientDAO().findPatientByID(id);
this.mPatientVitalsView = mPatientVitalsView;
this.mPatientVitalsView.setPresenter(this);
this.encounterDAO = new EncounterDAO();
this.visitApi = new VisitApi();
this.visitRepository = new VisitRepository();
}

public PatientDashboardVitalsPresenter(Patient patient, PatientDashboardContract.ViewPatientVitals mPatientVitalsView,
EncounterDAO encounterDAO, VisitApi visitApi) {
EncounterDAO encounterDAO, VisitRepository visitRepository) {
this.mPatient = patient;
this.mPatientVitalsView = mPatientVitalsView;
this.mPatientVitalsView.setPresenter(this);
this.encounterDAO = encounterDAO;
this.visitApi = visitApi;
this.visitRepository = visitRepository;
}

@Override
Expand All @@ -56,7 +56,7 @@ public void subscribe() {

private void loadVitalsFromServer() {
if (NetworkUtils.isOnline()) {
visitApi.syncLastVitals(mPatient.getUuid(), new DefaultResponseCallbackListener() {
visitRepository.syncLastVitals(mPatient.getUuid(), new DefaultResponseCallbackListener() {
@Override
public void onResponse() {
loadVitalsFromDB();
Expand Down
Loading