use of org.opendatakit.briefcase.operations.ExportException 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