use of nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.StateMachine in project timbuctoo by HuygensING.
the class TabularRdfCreator method sendQuads.
@Override
public void sendQuads(RdfSerializer saver, DataSet dataSet, Consumer<String> statusConsumer) throws LogStorageFailedException {
try (CachedFile file = dataSet.getImportManager().getFile(fileToken)) {
final RawUploadRdfSaver rawUploadRdfSaver = new RawUploadRdfSaver(dataSet.getMetadata(), file.getFile().getName(), file.getMimeType(), saver, fileName, Clock.systemUTC());
loader.loadData(Lists.newArrayList(tuple(fileName, file.getFile())), new Importer(new StateMachine<>(rawUploadRdfSaver), new ResultReporter(statusConsumer)));
} catch (Exception e) {
throw new LogStorageFailedException(e);
}
}
use of nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.StateMachine in project timbuctoo by HuygensING.
the class BulkUploadService method saveToDb.
public void saveToDb(String vreName, Loader loader, List<Tuple<String, File>> tempFiles, String vreLabel, Consumer<String> statusUpdate) throws IOException, InvalidFileException {
String fileNamesDisplay;
if (tempFiles.size() == 1) {
fileNamesDisplay = tempFiles.get(0).getLeft();
} else {
fileNamesDisplay = "multiple files: " + tempFiles.stream().map(Tuple::getLeft).collect(joining(", "));
}
try (TinkerpopSaver saver = new TinkerpopSaver(vres, graphwrapper, vreName, vreLabel, maxVertices, fileNamesDisplay)) {
try {
loader.loadData(tempFiles, new Importer(new StateMachine(saver), new ResultReporter(statusUpdate)));
saver.setUploadFinished(vreName, Vre.PublishState.MAPPING_CREATION);
} catch (IOException | InvalidFileException e) {
saver.setUploadFinished(vreName, Vre.PublishState.UPLOAD_FAILED);
throw e;
}
}
}
Aggregations