Search in sources :

Example 6 with FatalException

use of org.wikidata.query.rdf.tool.exception.FatalException in project wikidata-query-rdf by wikimedia.

the class RdfRepository method verifyStatements.

/**
 * Verify that the database matches the statement data for these IDs.
 * @param entityIds List of IDs
 * @param statements List of statements for these IDs
 * @throws QueryEvaluationException if there is a problem retrieving result.
 */
@SuppressFBWarnings(value = "SLF4J_SIGN_ONLY_FORMAT", justification = "We rely on that format.")
private void verifyStatements(Set<String> entityIds, List<Statement> statements) throws QueryEvaluationException {
    log.debug("Verifying the update");
    UpdateBuilder bv = new UpdateBuilder(verify);
    bv.bindUri("schema:about", SchemaDotOrg.ABOUT);
    bv.bind("uris.statement", uris.statement());
    bv.bindUris("entityList", entityIds, uris.entity());
    bv.bindValues("allStatements", statements);
    TupleQueryResult result = query(bv.toString());
    if (result.hasNext()) {
        log.error("Update failed, we have extra data!");
        while (result.hasNext()) {
            BindingSet bindings = result.next();
            Binding s = bindings.getBinding("s");
            Binding p = bindings.getBinding("p");
            Binding o = bindings.getBinding("o");
            log.error("{}\t{}\t{}", s.getValue().stringValue(), p.getValue().stringValue(), o.getValue().stringValue());
        }
        throw new FatalException("Update failed, bad old data in the store");
    }
    log.debug("Verification OK");
}
Also used : Binding(org.openrdf.query.Binding) BindingSet(org.openrdf.query.BindingSet) FatalException(org.wikidata.query.rdf.tool.exception.FatalException) TupleQueryResult(org.openrdf.query.TupleQueryResult) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

FatalException (org.wikidata.query.rdf.tool.exception.FatalException)6 Binding (org.openrdf.query.Binding)4 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)4 HashSet (java.util.HashSet)2 BindingSet (org.openrdf.query.BindingSet)2 TupleQueryResult (org.openrdf.query.TupleQueryResult)2 RetryException (com.github.rholder.retry.RetryException)1 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 GregorianCalendar (java.util.GregorianCalendar)1 ExecutionException (java.util.concurrent.ExecutionException)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)1 Literal (org.openrdf.model.Literal)1 Statement (org.openrdf.model.Statement)1 Change (org.wikidata.query.rdf.tool.change.Change)1 ContainedException (org.wikidata.query.rdf.tool.exception.ContainedException)1