Search in sources :

Example 6 with IAsyncExecutor

use of org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor in project pictureapp by EyeSeeTea.

the class LoginActivityStrategy method checkEnableLogin.

private void checkEnableLogin() {
    IInvalidLoginAttemptsRepository invalidLoginAttemptsLocalDataSource = new InvalidLoginAttemptsRepositoryLocalDataSource();
    IMainExecutor mainExecutor = new UIThreadExecutor();
    IAsyncExecutor asyncExecutor = new AsyncExecutor();
    mIsLoginEnableUseCase = new IsLoginEnableUseCase(invalidLoginAttemptsLocalDataSource, mainExecutor, asyncExecutor);
    mIsLoginEnableUseCase.execute(new IsLoginEnableUseCase.Callback() {

        @Override
        public void onLoginEnable() {
            loginActivity.enableLogin(true);
        }

        @Override
        public void onLoginDisable() {
            loginDisable();
        }
    });
}
Also used : IsLoginEnableUseCase(org.eyeseetea.malariacare.domain.usecase.IsLoginEnableUseCase) InvalidLoginAttemptsRepositoryLocalDataSource(org.eyeseetea.malariacare.data.database.InvalidLoginAttemptsRepositoryLocalDataSource) UIThreadExecutor(org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) IInvalidLoginAttemptsRepository(org.eyeseetea.malariacare.domain.boundary.repositories.IInvalidLoginAttemptsRepository) IMainExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) AsyncExecutor(org.eyeseetea.malariacare.presentation.executors.AsyncExecutor)

Example 7 with IAsyncExecutor

use of org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor in project pictureapp by EyeSeeTea.

the class LoginActivityStrategy method executePullDemo.

private void executePullDemo() {
    PullController pullController = new PullController(loginActivity);
    IAsyncExecutor asyncExecutor = new AsyncExecutor();
    IMainExecutor mainExecutor = new UIThreadExecutor();
    PullUseCase pullUseCase = new PullUseCase(pullController, asyncExecutor, mainExecutor);
    PullFilters pullFilters = new PullFilters();
    pullFilters.setDemo(true);
    pullUseCase.execute(pullFilters, new PullUseCase.Callback() {

        @Override
        public void onComplete() {
            loginActivity.hideProgressBar();
            finishAndGo(DashboardActivity.class);
        }

        @Override
        public void onStep(PullStep step) {
            Log.d(this.getClass().getSimpleName(), step.toString());
        }

        @Override
        public void onError(String message) {
            loginActivity.hideProgressBar();
            Log.e(this.getClass().getSimpleName(), message);
        }

        @Override
        public void onPullConversionError() {
            loginActivity.hideProgressBar();
            Log.e(this.getClass().getSimpleName(), "Pull conversion error");
        }

        @Override
        public void onCancel() {
            loginActivity.hideProgressBar();
            Log.e(this.getClass().getSimpleName(), "Pull cancel");
        }

        @Override
        public void onNetworkError() {
            loginActivity.hideProgressBar();
            Log.e(this.getClass().getSimpleName(), "Network Error");
        }
    });
}
Also used : PullUseCase(org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase) UIThreadExecutor(org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) DashboardActivity(org.eyeseetea.malariacare.DashboardActivity) PullFilters(org.eyeseetea.malariacare.domain.usecase.pull.PullFilters) PullStep(org.eyeseetea.malariacare.domain.usecase.pull.PullStep) PullController(org.eyeseetea.malariacare.data.sync.importer.PullController) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) AsyncExecutor(org.eyeseetea.malariacare.presentation.executors.AsyncExecutor) IMainExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)

Example 8 with IAsyncExecutor

use of org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor in project pictureapp by EyeSeeTea.

the class SurveyService method getProgramUID.

private void getProgramUID(final Callback callback) {
    if (mProgramUID != null) {
        callback.onSuccess(mProgramUID);
    } else {
        IProgramRepository programLocalDataSource = new ProgramLocalDataSource();
        IMainExecutor mainExecutor = new UIThreadExecutor();
        IAsyncExecutor asyncExecutor = new AsyncExecutor();
        GetUserProgramUIDUseCase getUserProgramUIDUseCase = new GetUserProgramUIDUseCase(programLocalDataSource, mainExecutor, asyncExecutor);
        getUserProgramUIDUseCase.execute(new GetUserProgramUIDUseCase.Callback() {

            @Override
            public void onSuccess(String uid) {
                mProgramUID = uid;
                callback.onSuccess(uid);
            }

            @Override
            public void onError() {
                Log.e(TAG, "error getting user program");
            }
        });
    }
}
Also used : IProgramRepository(org.eyeseetea.malariacare.domain.boundary.repositories.IProgramRepository) GetUserProgramUIDUseCase(org.eyeseetea.malariacare.domain.usecase.GetUserProgramUIDUseCase) ProgramLocalDataSource(org.eyeseetea.malariacare.data.database.datasources.ProgramLocalDataSource) UIThreadExecutor(org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) IMainExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor) AsyncExecutor(org.eyeseetea.malariacare.presentation.executors.AsyncExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)

Example 9 with IAsyncExecutor

use of org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor in project pictureapp by EyeSeeTea.

the class APushServiceStrategy method executePush.

protected void executePush() {
    PushController pushController = new PushController(mPushService);
    IAsyncExecutor asyncExecutor = new AsyncExecutor();
    IMainExecutor mainExecutor = new UIThreadExecutor();
    ISurveyRepository surveyRepository = new SurveyLocalDataSource();
    IOrganisationUnitRepository orgUnitRepository = new OrganisationUnitRepository();
    SurveysThresholds surveysThresholds = new SurveysThresholds(BuildConfig.LimitSurveysCount, BuildConfig.LimitSurveysTimeHours);
    PushUseCase pushUseCase = new PushUseCase(pushController, asyncExecutor, mainExecutor, surveysThresholds, surveyRepository, orgUnitRepository);
    SurveyChecker.launchQuarantineChecker();
    pushUseCase.execute(new PushUseCase.Callback() {

        @Override
        public void onComplete() {
            Log.d(TAG, "PUSHUSECASE WITHOUT ERROR push complete");
            mPushService.onPushFinished();
        }

        @Override
        public void onPushInProgressError() {
            Log.d(TAG, "PUSHUSECASE ERROR Push stopped, There is already a push in progress");
        }

        @Override
        public void onPushError() {
            onError("PUSHUSECASE ERROR Unexpected error has occurred in push process");
        }

        @Override
        public void onSurveysNotFoundError() {
            onError("PUSHUSECASE ERROR Pending surveys not found");
        }

        @Override
        public void onConversionError() {
            onError("PUSHUSECASE ERROR An error has occurred to the conversion in push process");
        }

        @Override
        public void onNetworkError() {
            onError("PUSHUSECASE ERROR Network not available");
        }

        @Override
        public void onInformativeError(String message) {
            showInDialog(PreferencesState.getInstance().getContext().getString(R.string.error_conflict_title), "PUSHUSECASE ERROR " + message + PreferencesState.getInstance().isPushInProgress());
        }

        @Override
        public void onBannedOrgUnit() {
            showInDialog("", PreferencesState.getInstance().getContext().getString(R.string.exception_org_unit_banned));
        }

        @Override
        public void onReOpenOrgUnit() {
            showInDialog("", String.format(PreferencesState.getInstance().getContext().getString(R.string.dialog_reopen_org_unit), PreferencesState.getInstance().getOrgUnit()));
        }

        @Override
        public void onApiCallError(ApiCallException e) {
            onError("PUSHUSECASE ERROR " + e.getMessage());
        }

        @Override
        public void onClosedUser() {
            onError("PUSHUSECASE ERROR on closedUser " + PreferencesState.getInstance().isPushInProgress());
            closeUserLogout();
        }

        @Override
        public void onApiCallError() {
            onError("onApiCallError");
        }
    });
}
Also used : OrganisationUnitRepository(org.eyeseetea.malariacare.data.repositories.OrganisationUnitRepository) IOrganisationUnitRepository(org.eyeseetea.malariacare.domain.boundary.repositories.IOrganisationUnitRepository) PushController(org.eyeseetea.malariacare.data.sync.exporter.PushController) PushUseCase(org.eyeseetea.malariacare.domain.usecase.push.PushUseCase) ApiCallException(org.eyeseetea.malariacare.domain.exception.ApiCallException) SurveyLocalDataSource(org.eyeseetea.malariacare.data.database.datasources.SurveyLocalDataSource) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) IMainExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor) UIThreadExecutor(org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor) IOrganisationUnitRepository(org.eyeseetea.malariacare.domain.boundary.repositories.IOrganisationUnitRepository) ISurveyRepository(org.eyeseetea.malariacare.domain.boundary.repositories.ISurveyRepository) SurveysThresholds(org.eyeseetea.malariacare.domain.usecase.push.SurveysThresholds) AsyncExecutor(org.eyeseetea.malariacare.presentation.executors.AsyncExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)

Aggregations

IAsyncExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)9 IMainExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)9 AsyncExecutor (org.eyeseetea.malariacare.presentation.executors.AsyncExecutor)9 UIThreadExecutor (org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor)9 OrganisationUnitRepository (org.eyeseetea.malariacare.data.repositories.OrganisationUnitRepository)4 IOrganisationUnitRepository (org.eyeseetea.malariacare.domain.boundary.repositories.IOrganisationUnitRepository)4 InvalidLoginAttemptsRepositoryLocalDataSource (org.eyeseetea.malariacare.data.database.InvalidLoginAttemptsRepositoryLocalDataSource)3 PullController (org.eyeseetea.malariacare.data.sync.importer.PullController)3 IInvalidLoginAttemptsRepository (org.eyeseetea.malariacare.domain.boundary.repositories.IInvalidLoginAttemptsRepository)3 PullUseCase (org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase)3 AuthenticationManager (org.eyeseetea.malariacare.data.authentication.AuthenticationManager)2 CredentialsLocalDataSource (org.eyeseetea.malariacare.data.database.CredentialsLocalDataSource)2 SurveyLocalDataSource (org.eyeseetea.malariacare.data.database.datasources.SurveyLocalDataSource)2 ICredentialsRepository (org.eyeseetea.malariacare.domain.boundary.repositories.ICredentialsRepository)2 ISurveyRepository (org.eyeseetea.malariacare.domain.boundary.repositories.ISurveyRepository)2 ApiCallException (org.eyeseetea.malariacare.domain.exception.ApiCallException)2 LoginUseCase (org.eyeseetea.malariacare.domain.usecase.LoginUseCase)2 PullFilters (org.eyeseetea.malariacare.domain.usecase.pull.PullFilters)2 PullStep (org.eyeseetea.malariacare.domain.usecase.pull.PullStep)2 PushUseCase (org.eyeseetea.malariacare.domain.usecase.push.PushUseCase)2