Search in sources :

Example 1 with ResultReporter

use of nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.ResultReporter 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);
    }
}
Also used : CachedFile(nl.knaw.huygens.timbuctoo.v5.filestorage.dto.CachedFile) LogStorageFailedException(nl.knaw.huygens.timbuctoo.v5.filestorage.exceptions.LogStorageFailedException) StateMachine(nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.StateMachine) ResultReporter(nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.ResultReporter) LogStorageFailedException(nl.knaw.huygens.timbuctoo.v5.filestorage.exceptions.LogStorageFailedException) Importer(nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.Importer)

Example 2 with ResultReporter

use of nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.ResultReporter 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;
        }
    }
}
Also used : StateMachine(nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.StateMachine) InvalidFileException(nl.knaw.huygens.timbuctoo.bulkupload.InvalidFileException) TinkerpopSaver(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver) IOException(java.io.IOException) ResultReporter(nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.ResultReporter) Importer(nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.Importer)

Aggregations

Importer (nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.Importer)2 ResultReporter (nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.ResultReporter)2 StateMachine (nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.StateMachine)2 IOException (java.io.IOException)1 InvalidFileException (nl.knaw.huygens.timbuctoo.bulkupload.InvalidFileException)1 TinkerpopSaver (nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver)1 CachedFile (nl.knaw.huygens.timbuctoo.v5.filestorage.dto.CachedFile)1 LogStorageFailedException (nl.knaw.huygens.timbuctoo.v5.filestorage.exceptions.LogStorageFailedException)1