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);
}
}
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();
}
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());
}
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();
}
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();
}
Aggregations