use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException in project timbuctoo by HuygensING.
the class StoreUpdater method commit.
@Override
public void commit() throws RdfProcessingFailedException {
try {
String msg = "processing " + count + " triples took " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds";
LOG.info(msg);
importStatus.setStatus(msg);
stopwatch.reset();
stopwatch.start();
updateListeners();
msg = "post-processing took " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds";
LOG.info(msg);
importStatus.setStatus(msg);
stopwatch.reset();
stopwatch.start();
versionStore.setVersion(currentversion);
commitChanges();
dbFactory.commitTransaction();
msg = "committing took " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds";
LOG.info(msg);
importStatus.setStatus(msg);
} catch (DatabaseWriteException | JsonProcessingException e) {
throw new RdfProcessingFailedException(e);
}
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException in project timbuctoo by HuygensING.
the class Rdf4jRdfParser method importRdf.
@Override
public void importRdf(CachedLog input, String baseUri, String defaultGraph, RdfProcessor rdfProcessor) throws RdfProcessingFailedException {
try {
RDFFormat format = Rio.getParserFormatForMIMEType(input.getMimeType().toString()).orElseThrow(() -> new UnsupportedRDFormatException(input.getMimeType() + " is not a supported rdf type."));
RDFParser rdfParser = Rio.createParser(format);
rdfParser.setPreserveBNodeIDs(true);
rdfParser.setRDFHandler(new TimRdfHandler(rdfProcessor, defaultGraph, input.getFile().getName()));
rdfParser.parse(input.getReader(), baseUri);
} catch (IOException | RDFParseException | UnsupportedRDFormatException e) {
throw new RdfProcessingFailedException(e);
} catch (RDFHandlerException e) {
if (e.getCause() instanceof RdfProcessingFailedException) {
throw (RdfProcessingFailedException) e.getCause();
} else {
throw new RdfProcessingFailedException(e);
}
}
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException in project timbuctoo by HuygensING.
the class TimRdfHandler method handleStatement.
@Override
public void handleStatement(Statement st) throws RDFHandlerException {
try {
if (Thread.currentThread().isInterrupted()) {
rdfProcessor.commit();
throw new RDFHandlerException("Interrupted");
}
String graph = st.getContext() == null ? defaultGraph : st.getContext().stringValue();
rdfProcessor.onQuad(isAssertion(), handleNode(st.getSubject()), st.getPredicate().stringValue(), handleNode(st.getObject()), (st.getObject() instanceof Literal) ? ((Literal) st.getObject()).getDatatype().toString() : null, (st.getObject() instanceof Literal) ? ((Literal) st.getObject()).getLanguage().orElse(null) : null, graph);
} catch (RdfProcessingFailedException e) {
throw new RDFHandlerException(e);
}
}
Aggregations