Search in sources :

Example 6 with TerminationFuture

use of org.opendatakit.briefcase.model.TerminationFuture in project briefcase by opendatakit.

the class TransferFromServer method pull.

public static void pull(ServerConnectionInfo transferSettings, FormStatus... forms) {
    List<FormStatus> formList = Arrays.asList(forms);
    TransferFromServer action = new TransferFromServer(transferSettings, new TerminationFuture(), formList);
    try {
        boolean allSuccessful = action.doAction();
        if (allSuccessful)
            EventBus.publish(new TransferSucceededEvent(false, formList, transferSettings));
        if (!allSuccessful)
            throw new PullFromServerException(formList);
    } catch (Exception e) {
        EventBus.publish(new TransferFailedEvent(false, formList));
        throw new PullFromServerException(formList);
    }
}
Also used : TransferFailedEvent(org.opendatakit.briefcase.model.TransferFailedEvent) FormStatus(org.opendatakit.briefcase.model.FormStatus) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) TransferSucceededEvent(org.opendatakit.briefcase.model.TransferSucceededEvent)

Example 7 with TerminationFuture

use of org.opendatakit.briefcase.model.TerminationFuture in project briefcase by opendatakit.

the class TransferToServer method push.

public static void push(ServerConnectionInfo transferSettings, FormStatus... forms) {
    List<FormStatus> formList = Arrays.asList(forms);
    TransferToServer action = new TransferToServer(transferSettings, new TerminationFuture(), formList);
    try {
        boolean allSuccessful = action.doAction();
        if (allSuccessful)
            EventBus.publish(new TransferSucceededEvent(false, formList, transferSettings));
        if (!allSuccessful)
            throw new PushFromServerException(formList);
    } catch (Exception e) {
        EventBus.publish(new TransferFailedEvent(false, formList));
        throw new PushFromServerException(formList);
    }
}
Also used : TransferFailedEvent(org.opendatakit.briefcase.model.TransferFailedEvent) FormStatus(org.opendatakit.briefcase.model.FormStatus) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) TransferSucceededEvent(org.opendatakit.briefcase.model.TransferSucceededEvent)

Example 8 with TerminationFuture

use of org.opendatakit.briefcase.model.TerminationFuture in project briefcase by opendatakit.

the class ExportPanelPageObject method setUp.

static ExportPanelPageObject setUp(Robot robot) {
    ExportPanel exportPanel = GuiActionRunner.execute(() -> {
        ExportPanel ep = ExportPanel.from(new TerminationFuture(), new BriefcasePreferences(InMemoryPreferences.empty()), new BriefcasePreferences(InMemoryPreferences.empty()), Runnable::run, new NoOpAnalytics());
        ep.updateForms();
        return ep;
    });
    JFrame testFrame = GuiActionRunner.execute(() -> {
        JFrame f = new JFrame();
        f.add(exportPanel.getForm().getContainer());
        return f;
    });
    FrameFixture window = new FrameFixture(robot, testFrame);
    return new ExportPanelPageObject(exportPanel, window);
}
Also used : NoOpAnalytics(org.opendatakit.briefcase.ui.reused.NoOpAnalytics) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) JFrame(javax.swing.JFrame) FrameFixture(org.assertj.swing.fixture.FrameFixture) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture)

Example 9 with TerminationFuture

use of org.opendatakit.briefcase.model.TerminationFuture in project briefcase by opendatakit.

the class ExportPanelUnitTest method saves_to_user_preferences_the_last_successful_export_date_for_a_form.

@Test
public void saves_to_user_preferences_the_last_successful_export_date_for_a_form() {
    BriefcasePreferences exportPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
    BriefcasePreferences appPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
    List<FormStatus> formsList = FormStatusBuilder.buildFormStatusList(10);
    initialDefaultConf = ExportConfiguration.empty();
    ExportForms forms = load(initialDefaultConf, formsList, exportPreferences, appPreferences);
    ConfigurationPanel confPanel = ConfigurationPanel.defaultPanel(initialDefaultConf, true, true);
    new ExportPanel(new TerminationFuture(), forms, ExportPanelForm.from(forms, confPanel), exportPreferences, Runnable::run, new NoOpAnalytics());
    FormStatus form = formsList.get(0);
    String formId = form.getFormDefinition().getFormId();
    assertThat(exportPreferences.nullSafeGet(buildExportDateTimePrefix(formId)), isEmpty());
    forms.appendStatus(form.getFormDefinition(), "some status update", true);
    assertThat(exportPreferences.nullSafeGet(buildExportDateTimePrefix(formId)), isPresent());
}
Also used : ExportForms(org.opendatakit.briefcase.export.ExportForms) NoOpAnalytics(org.opendatakit.briefcase.ui.reused.NoOpAnalytics) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) FormStatus(org.opendatakit.briefcase.model.FormStatus) ConfigurationPanel(org.opendatakit.briefcase.ui.export.components.ConfigurationPanel) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) Test(org.junit.Test)

Example 10 with TerminationFuture

use of org.opendatakit.briefcase.model.TerminationFuture in project briefcase by opendatakit.

the class ExportPanelUnitTest method saves_to_user_preferences_changes_on_a_custom_configuration.

@Test
public void saves_to_user_preferences_changes_on_a_custom_configuration() throws IOException {
    BriefcasePreferences exportPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
    BriefcasePreferences appPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
    List<FormStatus> formsList = FormStatusBuilder.buildFormStatusList(10);
    initialDefaultConf = ExportConfiguration.empty();
    ExportForms forms = load(initialDefaultConf, formsList, exportPreferences, appPreferences);
    ConfigurationPanel confPanel = ConfigurationPanel.defaultPanel(initialDefaultConf, true, true);
    ExportPanelForm exportPanelForm = ExportPanelForm.from(forms, confPanel);
    new ExportPanel(new TerminationFuture(), forms, exportPanelForm, exportPreferences, Runnable::run, new NoOpAnalytics());
    FormStatus form = formsList.get(0);
    String formId = form.getFormDefinition().getFormId();
    ExportConfiguration conf = ExportConfiguration.empty();
    conf.setExportDir(Paths.get(Files.createTempDirectory("briefcase_test").toUri()));
    assertThat(ExportConfiguration.load(exportPreferences, buildCustomConfPrefix(formId)).getExportDir(), isEmpty());
    forms.putConfiguration(form, conf);
    exportPanelForm.getFormsTable().getViewModel().triggerChange();
    assertThat(ExportConfiguration.load(exportPreferences, buildCustomConfPrefix(formId)).getExportDir(), isPresent());
}
Also used : ExportForms(org.opendatakit.briefcase.export.ExportForms) NoOpAnalytics(org.opendatakit.briefcase.ui.reused.NoOpAnalytics) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) FormStatus(org.opendatakit.briefcase.model.FormStatus) ExportConfiguration(org.opendatakit.briefcase.export.ExportConfiguration) ConfigurationPanel(org.opendatakit.briefcase.ui.export.components.ConfigurationPanel) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) Test(org.junit.Test)

Aggregations

TerminationFuture (org.opendatakit.briefcase.model.TerminationFuture)10 BriefcasePreferences (org.opendatakit.briefcase.model.BriefcasePreferences)5 FormStatus (org.opendatakit.briefcase.model.FormStatus)5 ExportForms (org.opendatakit.briefcase.export.ExportForms)4 ConfigurationPanel (org.opendatakit.briefcase.ui.export.components.ConfigurationPanel)4 NoOpAnalytics (org.opendatakit.briefcase.ui.reused.NoOpAnalytics)4 Test (org.junit.Test)3 TransferSucceededEvent (org.opendatakit.briefcase.model.TransferSucceededEvent)3 ExportConfiguration (org.opendatakit.briefcase.export.ExportConfiguration)2 ExportSucceededEvent (org.opendatakit.briefcase.model.ExportSucceededEvent)2 ExportSucceededWithErrorsEvent (org.opendatakit.briefcase.model.ExportSucceededWithErrorsEvent)2 TransferFailedEvent (org.opendatakit.briefcase.model.TransferFailedEvent)2 ServerConnectionTestException (org.opendatakit.briefcase.operations.ServerConnectionTestException)2 LocalDateTime (java.time.LocalDateTime)1 ISO_DATE_TIME (java.time.format.DateTimeFormatter.ISO_DATE_TIME)1 Collections (java.util.Collections)1 List (java.util.List)1 Executor (java.util.concurrent.Executor)1 Collectors.joining (java.util.stream.Collectors.joining)1 Collectors.toList (java.util.stream.Collectors.toList)1