it.unibz.inf.ontop.rdf4j.query.impl.OntopBooleanQuery Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontop-rdf4j Show documentation
Show all versions of ontop-rdf4j Show documentation
This is the rdf4j API implementation based on Ontop
The newest version!
package it.unibz.inf.ontop.rdf4j.query.impl;
import com.google.common.collect.ImmutableMultimap;
import it.unibz.inf.ontop.query.AskQuery;
import it.unibz.inf.ontop.query.RDF4JQueryFactory;
import it.unibz.inf.ontop.exception.OntopConnectionException;
import it.unibz.inf.ontop.exception.OntopQueryAnsweringException;
import it.unibz.inf.ontop.query.resultset.BooleanResultSet;
import it.unibz.inf.ontop.answering.connection.OntopConnection;
import it.unibz.inf.ontop.answering.connection.OntopStatement;
import it.unibz.inf.ontop.injection.OntopSystemSettings;
import org.eclipse.rdf4j.query.BooleanQuery;
import org.eclipse.rdf4j.query.QueryEvaluationException;
import org.eclipse.rdf4j.query.parser.ParsedBooleanQuery;
public class OntopBooleanQuery extends AbstractOntopQuery implements BooleanQuery {
private final RDF4JQueryFactory factory;
public OntopBooleanQuery(String queryString, ParsedBooleanQuery q, String baseIRI, OntopConnection ontopConnection,
ImmutableMultimap httpHeaders,
RDF4JQueryFactory inputQueryFactory, OntopSystemSettings settings) {
super(queryString, baseIRI, q, ontopConnection, httpHeaders, settings);
this.factory = inputQueryFactory;
}
@Override
public boolean evaluate() throws QueryEvaluationException {
AskQuery query = factory.createAskQuery(getQueryString(), getParsedQuery(), bindings);
try (OntopStatement stm = conn.createStatement()) {
if (queryTimeout > 0)
stm.setQueryTimeout(queryTimeout);
try (BooleanResultSet rs = stm.execute(query, getHttpHeaders())) {
return rs.getValue();
}
} catch (OntopConnectionException | OntopQueryAnsweringException e) {
throw new QueryEvaluationException(e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy