}
@Override
protected void writeExtraction() throws AsyncApiException, ExtractException, DataAccessObjectException {
if (this.batch.getState() == BatchStateEnum.Failed)
throw new ExtractException("Batch failed: " + this.batch.getStateMessage());
final QueryResultList results = getController().getBulkClient().getClient()
.getQueryResultList(this.batch.getJobId(), this.batch.getId());
for (final String resultId : results.getResult()) {
if (getProgressMonitor().isCanceled()) return;
try {
final InputStream resultStream = getController().getBulkClient().getClient()
.getQueryResultStream(this.batch.getJobId(), this.batch.getId(), resultId);
try {
final CSVReader rdr = new CSVReader(resultStream, Config.BULK_API_ENCODING);
rdr.setMaxCharsInFile(Integer.MAX_VALUE);
rdr.setMaxRowsInFile(Integer.MAX_VALUE);
List<String> headers;
headers = rdr.nextRecord();
List<String> csvRow;
while ((csvRow = rdr.nextRecord()) != null) {
final StringBuilder id = new StringBuilder();
final Row daoRow = getDaoRow(headers, csvRow, id);
addResultRow(daoRow, id.toString());
}
} finally {
resultStream.close();
}
} catch (final IOException e) {
throw new ExtractException(e);
}
}
}