Search in sources :

Example 1 with ProgressListener

use of org.openforis.concurrency.ProgressListener in project collect by openforis.

the class ReportingRepositoriesGeneratorJob method buildTasks.

@Override
protected void buildTasks() throws Throwable {
    addTask(new Task() {

        protected void execute() throws Throwable {
            reportingRepositories.createRepositories(survey.getName(), input.getLanguage(), new ProgressListener() {

                public void progressMade(Progress progress) {
                    setProcessedItems(progress.getProcessedItems());
                    setTotalItems(progress.getTotalItems());
                }
            });
        }
    });
}
Also used : Task(org.openforis.concurrency.Task) Progress(org.openforis.concurrency.Progress) ProgressListener(org.openforis.concurrency.ProgressListener)

Example 2 with ProgressListener

use of org.openforis.concurrency.ProgressListener in project collect by openforis.

the class RepositoryEventHandler method handleEvent.

private void handleEvent(SurveyEvent event, final KeepAlive keepAlive) {
    ProgressListener keepAliveListener = createProgressListener(keepAlive);
    String surveyName = event.getSurveyName();
    if (event instanceof RecordTransaction) {
        repositories.process((RecordTransaction) event);
    } else if (event instanceof SurveyCreatedEvent) {
        repositories.createRepositories(surveyName, null, keepAliveListener);
    } else if (event instanceof SurveyUpdatedEvent) {
        repositories.updateRepositories(surveyName, null, keepAliveListener);
    } else if (event instanceof SurveyDeletedEvent) {
        repositories.deleteRepositories(surveyName);
    } else if (event instanceof InitializeRDBEvent) {
        repositories.createRepository(surveyName, ((InitializeRDBEvent) event).getStep(), null, keepAliveListener);
    }
}
Also used : ProgressListener(org.openforis.concurrency.ProgressListener) InitializeRDBEvent(org.openforis.collect.relational.event.InitializeRDBEvent)

Example 3 with ProgressListener

use of org.openforis.concurrency.ProgressListener in project collect by openforis.

the class RepositoryEventHandler method handleFailingEvent.

private void handleFailingEvent(SurveyEvent event, KeepAlive keepAlive) {
    String surveyName = ((SurveyEvent) event).getSurveyName();
    if (event instanceof RecordTransaction) {
        try {
            ProgressListener keepAliveListener = createProgressListener(keepAlive);
            repositories.deleteRepositories(surveyName);
            repositories.createRepositories(surveyName, null, keepAliveListener);
            handleEvent(event, keepAlive);
            considerSurveyEvents(surveyName);
        } catch (Exception e) {
            logEventProcessFailed(event, e);
            ignoreSurveyEvents(surveyName);
        }
    } else {
        logEventIgnored(surveyName);
        ignoreSurveyEvents(surveyName);
    }
}
Also used : ProgressListener(org.openforis.concurrency.ProgressListener)

Aggregations

ProgressListener (org.openforis.concurrency.ProgressListener)3 InitializeRDBEvent (org.openforis.collect.relational.event.InitializeRDBEvent)1 Progress (org.openforis.concurrency.Progress)1 Task (org.openforis.concurrency.Task)1