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");
}
Aggregations