use of org.opendatakit.briefcase.model.ExportSucceededEvent in project briefcase by opendatakit.
the class FormsTableUnitTest method appends_to_a_forms_status_history_when_export_events_are_sent.
@Test
@Ignore
public void appends_to_a_forms_status_history_when_export_events_are_sent() {
FormStatus theForm = buildFormStatus(1);
ExportForms forms = new ExportForms(Collections.singletonList(theForm), ExportConfiguration.empty(), new HashMap<>(), new HashMap<>(), new HashMap<>());
TestFormsTableViewModel viewModel = new TestFormsTableViewModel(forms);
new FormsTable(forms, new TestFormsTableView(viewModel), viewModel);
// TODO Event publishing happens asynchronously. We have to work this test a little more to stop ignoring it
EventBus.publish(new ExportProgressEvent("some progress", (BriefcaseFormDefinition) theForm.getFormDefinition()));
EventBus.publish(new ExportFailedEvent((BriefcaseFormDefinition) theForm.getFormDefinition()));
EventBus.publish(new ExportSucceededEvent((BriefcaseFormDefinition) theForm.getFormDefinition()));
EventBus.publish(new ExportSucceededWithErrorsEvent((BriefcaseFormDefinition) theForm.getFormDefinition()));
assertThat(theForm.getStatusHistory(), Matchers.containsString("some progress"));
assertThat(theForm.getStatusHistory(), Matchers.containsString("Failed."));
assertThat(theForm.getStatusHistory(), Matchers.containsString("Succeeded."));
assertThat(theForm.getStatusHistory(), Matchers.containsString("Succeeded, but with errors."));
}
use of org.opendatakit.briefcase.model.ExportSucceededEvent 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);
}
}
Aggregations