Search in sources :

Example 1 with TerminationFuture

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

the class ExportToCsv method export.

public static void export(Path exportDir, BriefcaseFormDefinition formDefinition, String baseFilename, boolean exportMedia, boolean overwriteFiles, Optional<LocalDate> startDate, Optional<LocalDate> endDate) {
    log.info("exporting to : " + exportDir);
    ExportToCsv action = new ExportToCsv(new TerminationFuture(), exportDir.toFile(), formDefinition, baseFilename, exportMedia, overwriteFiles, startDate.map(ld -> Date.from(ld.atStartOfDay(systemDefault()).toInstant())).orElse(null), endDate.map(ld -> Date.from(ld.atStartOfDay(systemDefault()).toInstant())).orElse(null));
    try {
        boolean allSuccessful = action.doAction();
        if (allSuccessful && action.someSkipped())
            EventBus.publish(new ExportSucceededWithErrorsEvent(action.getFormDefinition()));
        if (allSuccessful && action.noneSkipped())
            EventBus.publish(new ExportSucceededEvent(action.getFormDefinition()));
        if (allSuccessful && action.allSkipped())
            throw new ExportException(formDefinition, "None of the instances where exported");
        if (!allSuccessful)
            throw new ExportException(formDefinition);
    } catch (Throwable t) {
        throw new ExportException(formDefinition);
    }
}
Also used : ExportSucceededWithErrorsEvent(org.opendatakit.briefcase.model.ExportSucceededWithErrorsEvent) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) ExportSucceededEvent(org.opendatakit.briefcase.model.ExportSucceededEvent) ExportException(org.opendatakit.briefcase.operations.ExportException)

Example 2 with TerminationFuture

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

the class ExportPanel method export.

private void export() {
    form.disableUI();
    terminationFuture.reset();
    forms.getSelectedForms().parallelStream().peek(FormStatus::clearStatusHistory).forEach(form -> {
        String formId = form.getFormDefinition().getFormId();
        ExportConfiguration configuration = forms.getConfiguration(formId);
        if (configuration.resolvePullBefore())
            forms.getTransferSettings(formId).ifPresent(sci -> NewTransferAction.transferServerToBriefcase(sci, terminationFuture, Collections.singletonList(form)));
        ExportAction.export((BriefcaseFormDefinition) form.getFormDefinition(), configuration, terminationFuture);
    });
    form.enableUI();
}
Also used : ConfigurationPanel(org.opendatakit.briefcase.ui.export.components.ConfigurationPanel) TransferSucceededEvent(org.opendatakit.briefcase.model.TransferSucceededEvent) ExportProgressEvent(org.opendatakit.briefcase.model.ExportProgressEvent) LocalDateTime(java.time.LocalDateTime) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) EXPORT(org.opendatakit.briefcase.model.FormStatus.TransferType.EXPORT) ExportFailedEvent(org.opendatakit.briefcase.model.ExportFailedEvent) BriefcaseFormDefinition(org.opendatakit.briefcase.model.BriefcaseFormDefinition) AnnotationProcessor(org.bushe.swing.event.annotation.AnnotationProcessor) ExportConfiguration(org.opendatakit.briefcase.export.ExportConfiguration) ISO_DATE_TIME(java.time.format.DateTimeFormatter.ISO_DATE_TIME) SavePasswordsConsentRevoked(org.opendatakit.briefcase.model.SavePasswordsConsentRevoked) ExportForms(org.opendatakit.briefcase.export.ExportForms) ExportSucceededWithErrorsEvent(org.opendatakit.briefcase.model.ExportSucceededWithErrorsEvent) FileSystemUtils(org.opendatakit.briefcase.util.FileSystemUtils) ExportSucceededEvent(org.opendatakit.briefcase.model.ExportSucceededEvent) ExportForms.buildCustomConfPrefix(org.opendatakit.briefcase.export.ExportForms.buildCustomConfPrefix) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusEvent(org.opendatakit.briefcase.model.FormStatusEvent) Executor(java.util.concurrent.Executor) ExportAction(org.opendatakit.briefcase.export.ExportAction) SavePasswordsConsentGiven(org.opendatakit.briefcase.model.SavePasswordsConsentGiven) Collectors.joining(java.util.stream.Collectors.joining) NewTransferAction(org.opendatakit.briefcase.transfer.NewTransferAction) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) Collectors.toList(java.util.stream.Collectors.toList) ODKOptionPane.showErrorDialog(org.opendatakit.briefcase.ui.ODKOptionPane.showErrorDialog) List(java.util.List) Stream(java.util.stream.Stream) EventSubscriber(org.bushe.swing.event.annotation.EventSubscriber) Analytics(org.opendatakit.briefcase.ui.reused.Analytics) Collections(java.util.Collections) ExportConfiguration(org.opendatakit.briefcase.export.ExportConfiguration)

Example 3 with TerminationFuture

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

the class ExportPanelUnitTest method saves_to_user_preferences_changes_on_the_default_configuration.

@Test
public void saves_to_user_preferences_changes_on_the_default_configuration() throws IOException {
    BriefcasePreferences exportPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
    BriefcasePreferences appPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
    initialDefaultConf = ExportConfiguration.empty();
    ExportForms forms = load(initialDefaultConf, new ArrayList<>(), exportPreferences, appPreferences);
    ConfigurationPanel confPanel = ConfigurationPanel.defaultPanel(initialDefaultConf, false, true);
    new ExportPanel(new TerminationFuture(), forms, ExportPanelForm.from(forms, confPanel), exportPreferences, Runnable::run, new NoOpAnalytics());
    assertThat(ExportConfiguration.load(exportPreferences).getExportDir(), isEmpty());
    confPanel.getForm().setExportDir(Paths.get(Files.createTempDirectory("briefcase_test").toUri()));
    assertThat(ExportConfiguration.load(exportPreferences).getExportDir(), isPresent());
}
Also used : ExportForms(org.opendatakit.briefcase.export.ExportForms) NoOpAnalytics(org.opendatakit.briefcase.ui.reused.NoOpAnalytics) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) ConfigurationPanel(org.opendatakit.briefcase.ui.export.components.ConfigurationPanel) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) Test(org.junit.Test)

Example 4 with TerminationFuture

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

the class ServerConnectionTest method testPush.

public static void testPush(ServerConnectionInfo transferSettings) {
    ServerConnectionTest test = new ServerConnectionTest(transferSettings, new TerminationFuture(), true);
    test.run();
    if (!test.isSuccessful())
        throw new ServerConnectionTestException();
}
Also used : ServerConnectionTestException(org.opendatakit.briefcase.operations.ServerConnectionTestException) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture)

Example 5 with TerminationFuture

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

the class ServerConnectionTest method testPull.

public static void testPull(ServerConnectionInfo transferSettings) {
    ServerConnectionTest test = new ServerConnectionTest(transferSettings, new TerminationFuture(), false);
    test.run();
    if (!test.isSuccessful())
        throw new ServerConnectionTestException();
}
Also used : ServerConnectionTestException(org.opendatakit.briefcase.operations.ServerConnectionTestException) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture)

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