Search in sources :

Example 6 with RdfProcessingFailedException

use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException in project timbuctoo by HuygensING.

the class RdfDescriptionSaver method addValue.

@Override
public void addValue(String subject, String predicate, String value, String dataType, String graph) throws RdfProcessingFailedException {
    try {
        if (Objects.equals(subject, baseUri) && isDescriptionPredicate(predicate)) {
            ValueFactory vf = SimpleValueFactory.getInstance();
            model.add(vf.createIRI(subject), vf.createIRI(predicate), vf.createLiteral(value));
        }
    } catch (Exception e) {
        throw new RdfProcessingFailedException(e);
    }
}
Also used : ValueFactory(org.eclipse.rdf4j.model.ValueFactory) SimpleValueFactory(org.eclipse.rdf4j.model.impl.SimpleValueFactory) RdfProcessingFailedException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException) RdfProcessingFailedException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 7 with RdfProcessingFailedException

use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException in project timbuctoo by HuygensING.

the class RdfDescriptionSaver method commit.

@Override
public void commit() throws RdfProcessingFailedException {
    try {
        inputStream.close();
        // false for overwrite file (true=concat)
        FileWriter newFileWriter = new FileWriter(descriptionFile, false);
        Rio.write(model, newFileWriter, RDFFormat.RDFXML);
        newFileWriter.flush();
        newFileWriter.close();
        importStatus.setStatus("Description saved");
    } catch (IOException e) {
        throw new RdfProcessingFailedException(e);
    }
}
Also used : FileWriter(java.io.FileWriter) IOException(java.io.IOException) RdfProcessingFailedException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException)

Example 8 with RdfProcessingFailedException

use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException in project timbuctoo by HuygensING.

the class StoreUpdater method updateListeners.

private void updateListeners() throws RdfProcessingFailedException {
    logString = "Processed {} subjects ({} subjects/s)";
    for (OptimizedPatchListener listener : listeners) {
        listener.start();
    }
    count = 0;
    prevCount = 0;
    prevTime = stopwatch.elapsed(TimeUnit.SECONDS);
    try (Stream<String> subjects = updatedPerPatchStore.ofVersion(currentversion)) {
        final ChangeFetcher getQuads = new ChangeFetcherImpl(truePatchStore, tripleStore, currentversion);
        final Iterator<String> iterator = subjects.iterator();
        while (iterator.hasNext()) {
            final boolean needUpdate = notifyUpdate();
            final String subject = iterator.next();
            for (OptimizedPatchListener listener : listeners) {
                if (needUpdate) {
                    listener.notifyUpdate();
                }
                listener.onChangedSubject(subject, getQuads);
            }
        }
    }
    for (OptimizedPatchListener listener : listeners) {
        listener.finish();
    }
}
Also used : OptimizedPatchListener(nl.knaw.huygens.timbuctoo.v5.dataset.OptimizedPatchListener) ChangeFetcher(nl.knaw.huygens.timbuctoo.v5.dataset.ChangeFetcher)

Example 9 with RdfProcessingFailedException

use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException in project timbuctoo by HuygensING.

the class StoreUpdater method deleteQuad.

private void deleteQuad(String subject, String predicate, Direction direction, String object, String valueType, String language) throws RdfProcessingFailedException {
    try {
        final boolean wasChanged = tripleStore.deleteQuad(subject, predicate, direction, object, valueType, language);
        if (wasChanged && currentversion >= 0) {
            truePatchStore.put(subject, currentversion, predicate, direction, false, object, valueType, language);
            updatedPerPatchStore.put(currentversion, subject);
        }
    } catch (DatabaseWriteException e) {
        throw new RdfProcessingFailedException(e);
    }
}
Also used : DatabaseWriteException(nl.knaw.huygens.timbuctoo.v5.berkeleydb.exceptions.DatabaseWriteException) RdfProcessingFailedException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException)

Example 10 with RdfProcessingFailedException

use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException in project timbuctoo by HuygensING.

the class StoreUpdater method putQuad.

private void putQuad(String subject, String predicate, Direction direction, String object, String valueType, String language) throws RdfProcessingFailedException {
    try {
        final boolean wasChanged = tripleStore.putQuad(subject, predicate, direction, object, valueType, language);
        if (wasChanged && currentversion >= 0) {
            truePatchStore.put(subject, currentversion, predicate, direction, true, object, valueType, language);
            updatedPerPatchStore.put(currentversion, subject);
        }
    } catch (DatabaseWriteException e) {
        throw new RdfProcessingFailedException(e);
    }
}
Also used : DatabaseWriteException(nl.knaw.huygens.timbuctoo.v5.berkeleydb.exceptions.DatabaseWriteException) RdfProcessingFailedException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException)

Aggregations

RdfProcessingFailedException (nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException)11 IOException (java.io.IOException)7 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 DatabaseWriteException (nl.knaw.huygens.timbuctoo.v5.berkeleydb.exceptions.DatabaseWriteException)4 ValueFactory (org.eclipse.rdf4j.model.ValueFactory)4 SimpleValueFactory (org.eclipse.rdf4j.model.impl.SimpleValueFactory)4 SAXException (org.xml.sax.SAXException)4 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Stopwatch (com.google.common.base.Stopwatch)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Charset (java.nio.charset.Charset)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 MediaType (javax.ws.rs.core.MediaType)1