use of org.activityinfo.server.endpoint.rest.CsvWriter in project activityinfo by bedatadriven.
the class ExportAuditLogExecutor method execute.
@Override
public ExportResult execute(ExportAuditLog descriptor) throws IOException {
UserDatabaseDTO db = dispatcher.execute(new GetSchema()).getDatabaseById(descriptor.getDatabaseId());
GeneratedResource export = storageProvider.create("text/csv;charset=UTF-8", String.format("AuditLog_%d_%s.csv", db.getId(), Filenames.timestamp()));
try (CsvWriter writer = new CsvWriter(new OutputStreamWriter(export.openOutputStream(), Charsets.UTF_8))) {
AuditLogWriter logWriter = new AuditLogWriter(entityManager.get(), db, writer);
for (ActivityDTO activityDTO : db.getActivities()) {
logWriter.writeForm(catalog, activityDTO.getFormId());
}
}
return new ExportResult(export.getDownloadUri());
}
Aggregations