Search in sources :

Example 1 with PullFilters

use of org.eyeseetea.malariacare.domain.usecase.pull.PullFilters in project pictureapp by EyeSeeTea.

the class ProgressActivity method launchPull.

private void launchPull(boolean isDemo) {
    PullFilters pullFilters = new PullFilters();
    pullFilters.setStartDate(PreferencesState.getInstance().getDateStarDateLimitFilter());
    pullFilters.setDownloadDataRequired(PreferencesState.getInstance().downloadDataFilter());
    pullFilters.setPullDataAfterMetadata(PreferencesState.getInstance().getPullDataAfterMetadata());
    pullFilters.setPullMetaData(PreferencesState.getInstance().downloadMetaData());
    if (PreferencesState.getInstance().getDataFilteredByOrgUnit()) {
        pullFilters.setDataByOrgUnit(PreferencesState.getInstance().getOrgUnit());
    }
    pullFilters.setDemo(isDemo);
    mPullUseCase.execute(pullFilters, new PullUseCase.Callback() {

        @Override
        public void onComplete() {
            showAndMoveOn();
        }

        @Override
        public void onStep(PullStep pullStep) {
            switch(pullStep) {
                case METADATA:
                    showProgressText(R.string.progress_pull_downloading);
                    break;
                case CONVERT_METADATA:
                    showProgressText(R.string.progress_pull_preparing_orgs);
                case CONVERT_DATA:
                    showProgressText(R.string.progress_pull_surveys);
                case BUILDING_SURVEYS:
                    showProgressText(R.string.progress_pull_building_survey);
                case BUILDING_VALUES:
                    showProgressText(R.string.progress_pull_building_value);
            }
        }

        @Override
        public void onError(String message) {
            showException(R.string.dialog_pull_error);
        }

        @Override
        public void onNetworkError() {
            showException(R.string.network_error);
        }

        @Override
        public void onPullConversionError() {
            showException(R.string.dialog_pull_error);
        }

        @Override
        public void onCancel() {
            executeLogout();
        }
    });
}
Also used : PullUseCase(org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase) PullFilters(org.eyeseetea.malariacare.domain.usecase.pull.PullFilters) PullStep(org.eyeseetea.malariacare.domain.usecase.pull.PullStep)

Example 2 with PullFilters

use of org.eyeseetea.malariacare.domain.usecase.pull.PullFilters in project pictureapp by EyeSeeTea.

the class SplashScreenActivity method init.

private void init() {
    LocationMemory.getInstance().init(getApplicationContext());
    D2.init(this);
    SdkQueries.createDBIndexes();
    // Added to execute a query in DB, because DBFLow doesn't do any migration until a query
    // is executed
    PopulateDB.initDBQuery();
    try {
        PostMigration.launchPostMigration();
    } catch (PostMigrationException e) {
        new AlertDialog.Builder(this).setTitle(getApplicationContext().getString(R.string.error_message)).setCancelable(false).setMessage(getApplicationContext().getString(R.string.db_migration_error)).setNeutralButton(android.R.string.ok, null).create().show();
    }
    if (!BuildConfig.multiuser) {
        Log.i(TAG, "Pull on SplashScreen ...");
        PullController pullController = new PullController(getApplication().getApplicationContext());
        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() {
                Log.d(this.getClass().getSimpleName(), "pull complete");
                try {
                    NavigationBuilder.getInstance().buildController(Tab.getFirstTab());
                } catch (LoadingNavigationControllerException ex) {
                    onError(ex.getMessage());
                }
            }

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

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

            @Override
            public void onNetworkError() {
                Log.e(this.getClass().getSimpleName(), "Network Error");
            }

            @Override
            public void onPullConversionError() {
                Log.e(this.getClass().getSimpleName(), "Pull Conversion Error");
            }

            @Override
            public void onCancel() {
                Log.e(this.getClass().getSimpleName(), "Pull oncancel");
            }
        });
    }
}
Also used : AlertDialog(android.app.AlertDialog) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) PullStep(org.eyeseetea.malariacare.domain.usecase.pull.PullStep) PullController(org.eyeseetea.malariacare.data.sync.importer.PullController) IMainExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor) LoadingNavigationControllerException(org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException) PullUseCase(org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase) PostMigrationException(org.eyeseetea.malariacare.domain.exception.PostMigrationException) UIThreadExecutor(org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor) PullFilters(org.eyeseetea.malariacare.domain.usecase.pull.PullFilters) AsyncExecutor(org.eyeseetea.malariacare.presentation.executors.AsyncExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)

Example 3 with PullFilters

use of org.eyeseetea.malariacare.domain.usecase.pull.PullFilters in project pictureapp by EyeSeeTea.

the class LoginActivityStrategy method launchPull.

private void launchPull(boolean isDemo) {
    PullFilters pullFilters = new PullFilters();
    pullFilters.setStartDate(PreferencesState.getInstance().getDateStarDateLimitFilter());
    pullFilters.setDownloadDataRequired(PreferencesState.getInstance().downloadDataFilter());
    pullFilters.setPullDataAfterMetadata(PreferencesState.getInstance().getPullDataAfterMetadata());
    pullFilters.setPullMetaData(PreferencesState.getInstance().downloadMetaData());
    if (PreferencesState.getInstance().getDataFilteredByOrgUnit()) {
        pullFilters.setDataByOrgUnit(PreferencesState.getInstance().getOrgUnit());
    }
    pullFilters.setDemo(isDemo);
    mPullUseCase.execute(pullFilters, new PullUseCase.Callback() {

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

        @Override
        public void onStep(PullStep pullStep) {
        }

        @Override
        public void onError(String message) {
            loginActivity.onFinishLoading(null);
            loginActivity.showError(R.string.dialog_pull_error);
        }

        @Override
        public void onNetworkError() {
            loginActivity.onFinishLoading(null);
            loginActivity.showError(R.string.network_error);
        }

        @Override
        public void onPullConversionError() {
            loginActivity.onFinishLoading(null);
            loginActivity.showError(R.string.dialog_pull_error);
        }

        @Override
        public void onCancel() {
        }
    });
}
Also used : PullUseCase(org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase) DashboardActivity(org.eyeseetea.malariacare.DashboardActivity) PullFilters(org.eyeseetea.malariacare.domain.usecase.pull.PullFilters) PullStep(org.eyeseetea.malariacare.domain.usecase.pull.PullStep)

Example 4 with PullFilters

use of org.eyeseetea.malariacare.domain.usecase.pull.PullFilters 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)

Aggregations

PullFilters (org.eyeseetea.malariacare.domain.usecase.pull.PullFilters)4 PullStep (org.eyeseetea.malariacare.domain.usecase.pull.PullStep)4 PullUseCase (org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase)4 DashboardActivity (org.eyeseetea.malariacare.DashboardActivity)2 PullController (org.eyeseetea.malariacare.data.sync.importer.PullController)2 IAsyncExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)2 IMainExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)2 AsyncExecutor (org.eyeseetea.malariacare.presentation.executors.AsyncExecutor)2 UIThreadExecutor (org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor)2 AlertDialog (android.app.AlertDialog)1 LoadingNavigationControllerException (org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException)1 PostMigrationException (org.eyeseetea.malariacare.domain.exception.PostMigrationException)1