public void load(final Supplier<Reader> readerSupplier) throws OperationException, IOException {
final SuppliedIterable<CSVRecord> csvIterable = new SuppliedIterable<>(() -> {
try {
return new CSVParser(readerSupplier.get(), CSVFormat.DEFAULT.withFirstRecordAsHeader());
} catch (final IOException e) {
throw new RuntimeException("Unable to load csv data", e);
}
});
try {
final OperationChain<Void> populateChain = new OperationChain.Builder()
.first(new GenerateElements.Builder<CSVRecord>()
.input(csvIterable)
.generator(new RoadTrafficCsvElementGenerator())
.build())
.then(new AddElements.Builder()
.skipInvalidElements(false)
.build())
.build();
this.graph.execute(populateChain, this.user);
} finally {
CloseableUtil.close(csvIterable);
}
}