本文整理了Java中org.eclipse.rdf4j.query.BooleanQuery.evaluate()
方法的一些代码示例,展示了BooleanQuery.evaluate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BooleanQuery.evaluate()
方法的具体详情如下:
包路径:org.eclipse.rdf4j.query.BooleanQuery
类名称:BooleanQuery
方法名:evaluate
暂无
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-repository-dataset
public boolean evaluate()
throws QueryEvaluationException
{
con.loadDataset(sailQuery.getActiveDataset());
return ((BooleanQuery)sailQuery).evaluate();
}
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-repository-dataset
public boolean evaluate()
throws QueryEvaluationException
{
con.loadDataset(sailQuery.getActiveDataset());
return ((BooleanQuery)sailQuery).evaluate();
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-http-server-spring
/**
* Evaluate a {@link BooleanQuery} in this transaction and return the result.
*
* @param bQuery
* a {@link BooleanQuery} prepared on this transaction.
* @return the query result as a boolean
* @throws InterruptedException
* if the transaction thread is interrupted
* @throws ExecutionException
* if an error occurs while executing the operation.
*/
boolean evaluate(BooleanQuery bQuery)
throws InterruptedException, ExecutionException
{
Future<Boolean> result = submit(() -> bQuery.evaluate());
return getFromFuture(result);
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred,
Resource... contexts)
throws RepositoryException
{
try {
BooleanQuery query = prepareBooleanQuery(SPARQL, SOMETHING, "");
setBindings(query, subj, pred, obj, contexts);
return query.evaluate();
}
catch (MalformedQueryException e) {
throw new RepositoryException(e);
}
catch (QueryEvaluationException e) {
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-repository-sparql
public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred,
Resource... contexts)
throws RepositoryException
{
try {
BooleanQuery query = prepareBooleanQuery(SPARQL, SOMETHING, "");
setBindings(query, subj, pred, obj, contexts);
return query.evaluate();
}
catch (MalformedQueryException e) {
throw new RepositoryException(e);
}
catch (QueryEvaluationException e) {
throw new RepositoryException(e);
}
}
代码示例来源:origin: eclipse/rdf4j
@Override
public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred,
Resource... contexts)
throws RepositoryException
{
try {
BooleanQuery query = prepareBooleanQuery(SPARQL, SOMETHING, "");
setBindings(query, subj, pred, obj, contexts);
return query.evaluate();
}
catch (MalformedQueryException e) {
throw new RepositoryException(e);
}
catch (QueryEvaluationException e) {
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
public boolean isEmpty()
throws RepositoryException
{
try {
BooleanQuery query;
if (isQuadMode()) {
query = prepareBooleanQuery(SPARQL, SOMETHING_WITH_GRAPH);
}
else {
query = prepareBooleanQuery(SPARQL, SOMETHING);
}
return !query.evaluate();
}
catch (MalformedQueryException e) {
throw new RepositoryException(e);
}
catch (QueryEvaluationException e) {
throw new RepositoryException(e);
}
}
代码示例来源:origin: eclipse/rdf4j
@Override
public boolean isEmpty()
throws RepositoryException
{
try {
BooleanQuery query;
if (isQuadMode()) {
query = prepareBooleanQuery(SPARQL, SOMETHING_WITH_GRAPH);
}
else {
query = prepareBooleanQuery(SPARQL, SOMETHING);
}
return !query.evaluate();
}
catch (MalformedQueryException e) {
throw new RepositoryException(e);
}
catch (QueryEvaluationException e) {
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-repository-sparql
public boolean isEmpty()
throws RepositoryException
{
try {
BooleanQuery query;
if (isQuadMode()) {
query = prepareBooleanQuery(SPARQL, SOMETHING_WITH_GRAPH);
}
else {
query = prepareBooleanQuery(SPARQL, SOMETHING);
}
return !query.evaluate();
}
catch (MalformedQueryException e) {
throw new RepositoryException(e);
}
catch (QueryEvaluationException e) {
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-repository-sparql
/**
* Evaluate the provided sparqlQueryString at the initialized {@link Repository} of this
* {@link FederatedService}. Insert bindings, send ask query and return final result
*/
@Override
public boolean ask(Service service, BindingSet bindings, String baseUri)
throws QueryEvaluationException
{
try {
String sparqlQueryString = service.getAskQueryString();
BooleanQuery query = getConnection().prepareBooleanQuery(QueryLanguage.SPARQL, sparqlQueryString,
baseUri);
Iterator<Binding> bIter = bindings.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
if (service.getServiceVars().contains(b.getName()))
query.setBinding(b.getName(), b.getValue());
}
return query.evaluate();
}
catch (MalformedQueryException e) {
throw new QueryEvaluationException(e);
}
catch (RepositoryException e) {
throw new QueryEvaluationException(
"Repository for endpoint " + rep.toString() + " could not be initialized.", e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
/**
* Evaluate the provided sparqlQueryString at the initialized {@link Repository} of this
* {@link FederatedService}. Insert bindings, send ask query and return final result
*/
@Override
public boolean ask(Service service, BindingSet bindings, String baseUri)
throws QueryEvaluationException
{
try {
String sparqlQueryString = service.getAskQueryString();
BooleanQuery query = getConnection().prepareBooleanQuery(QueryLanguage.SPARQL, sparqlQueryString,
baseUri);
Iterator<Binding> bIter = bindings.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
if (service.getServiceVars().contains(b.getName()))
query.setBinding(b.getName(), b.getValue());
}
return query.evaluate();
}
catch (MalformedQueryException e) {
throw new QueryEvaluationException(e);
}
catch (RepositoryException e) {
throw new QueryEvaluationException(
"Repository for endpoint " + rep.toString() + " could not be initialized.", e);
}
}
代码示例来源:origin: eclipse/rdf4j
/**
* Evaluate the provided sparqlQueryString at the initialized {@link Repository} of this
* {@link FederatedService}. Insert bindings, send ask query and return final result
*/
@Override
public boolean ask(Service service, BindingSet bindings, String baseUri)
throws QueryEvaluationException
{
try {
String sparqlQueryString = service.getAskQueryString();
BooleanQuery query = getConnection().prepareBooleanQuery(QueryLanguage.SPARQL, sparqlQueryString,
baseUri);
Iterator<Binding> bIter = bindings.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
if (service.getServiceVars().contains(b.getName()))
query.setBinding(b.getName(), b.getValue());
}
return query.evaluate();
}
catch (MalformedQueryException e) {
throw new QueryEvaluationException(e);
}
catch (RepositoryException e) {
throw new QueryEvaluationException(
"Repository for endpoint " + rep.toString() + " could not be initialized.", e);
}
}
代码示例来源:origin: franzinc/agraph-java-client
@Test
public void testSimpleBooleanQuery()
throws Exception {
testCon.add(alice, name, nameAlice, context2);
testCon.add(alice, mbox, mboxAlice, context2);
testCon.add(context2, publisher, nameAlice);
testCon.add(bob, name, nameBob, context1);
testCon.add(bob, mbox, mboxBob, context1);
testCon.add(context1, publisher, nameBob);
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("PREFIX foaf: <" + FOAF_NS + "> ");
queryBuilder.append("ASK ");
queryBuilder.append("{ ?p foaf:name ?name }");
boolean exists = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString()).evaluate();
assertTrue(exists);
}
代码示例来源:origin: joshsh/sesametools
private Boolean executeAskQuery(final URI endpoint, final String query) {
final SPARQLRepository repo = new SPARQLRepository(endpoint.toString());
try {
repo.initialize();
try (RepositoryConnection con = repo.getConnection()) {
return con.prepareBooleanQuery(QueryLanguage.SPARQL, query).evaluate();
} catch (Exception e) {
Assert.fail(e.getMessage());
}
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
repo.shutDown();
}
return null;
}
代码示例来源:origin: franzinc/agraph-java-client
@Test
public void testPreparedBooleanQuery()
throws Exception {
testCon.add(alice, name, nameAlice, context2);
testCon.add(alice, mbox, mboxAlice, context2);
testCon.add(context2, publisher, nameAlice);
testCon.add(bob, name, nameBob, context1);
testCon.add(bob, mbox, mboxBob, context1);
testCon.add(context1, publisher, nameBob);
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("PREFIX foaf: <" + FOAF_NS + "> ");
queryBuilder.append("ASK ");
queryBuilder.append("{ ?p foaf:name ?name }");
BooleanQuery query = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString());
query.setBinding("name", nameBob);
assertTrue(query.evaluate());
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin
BooleanQuery queryOp = qp.prepare(askQuery);
addBindings(queryOp, arguments, args);
Value result = BooleanLiteral.valueOf(queryOp.evaluate());
iter = new SingletonIteration<List<Value>, QueryEvaluationException>(
Collections.singletonList(result));
代码示例来源:origin: ontop/ontop
boolean queryResult = ((BooleanQuery)query).evaluate();
boolean expectedResult = readExpectedBooleanQueryResult();
assertEquals(expectedResult, queryResult);
代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin
@Override
public Value evaluate(ValueFactory valueFactory, Value... args)
throws ValueExprEvaluationException
{
QueryPreparer qp = getCurrentQueryPreparer();
if (args.length == 0 || !(args[0] instanceof Resource)) {
throw new ValueExprEvaluationException("First argument must be a resource");
}
if ((args.length % 2) == 0) {
throw new ValueExprEvaluationException("Old number of arguments required");
}
try {
ParsedBooleanQuery askQuery = parser.parseAskQuery((Resource)args[0], qp.getTripleSource());
BooleanQuery queryOp = qp.prepare(askQuery);
addBindings(queryOp, args);
return BooleanLiteral.valueOf(queryOp.evaluate());
}
catch (ValueExprEvaluationException e) {
throw e;
}
catch (RDF4JException e) {
throw new ValueExprEvaluationException(e);
}
}
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-sail-spin
BooleanQuery queryOp = queryPreparer.prepare(askQuery);
addBindings(subj, constraint, askQuery, queryOp, tripleSource, parser);
if (queryOp.evaluate()) {
violation = parser.parseConstraintViolation(constraint, tripleSource);
代码示例来源:origin: franzinc/agraph-java-client
@Test
@Category(TestSuites.Prepush.class)
public void updateViaBooleanQuery() throws Exception {
IRI s = f.createIRI("http://example/book1");
IRI p = f.createIRI("http://purl.org/dc/elements/1.1/title");
Literal o_wrong = f.createLiteral("Fundamentals of Compiler Desing");
Literal o_right = f.createLiteral("Fundamentals of Compiler Design");
IRI g = f.createIRI("http://example/bookStore");
con.add(s, p, o_wrong, g);
// Perform a sequence of SPARQL UPDATE queries in one request to correct the title
String queryString = "PREFIX dc: <http://purl.org/dc/elements/1.1/> \n"
+ "DELETE DATA { GRAPH <http://example/bookStore> { <http://example/book1> dc:title \"Fundamentals of Compiler Desing\" } } ; \n"
+ "\n"
+ "PREFIX dc: <http://purl.org/dc/elements/1.1/> \n"
+ "INSERT DATA { GRAPH <http://example/bookStore> { <http://example/book1> dc:title \"Fundamentals of Compiler Design\" } }";
// SPARQL Update queries can also be executed using a BooleanQuery (for side effect)
// Useful for older versions of Sesame that don't have a prepareUpdate method.
con.prepareBooleanQuery(QueryLanguage.SPARQL, queryString).evaluate();
Assert.assertTrue("Title should be correct", con.hasStatement(s, p, o_right, false, g));
Assert.assertFalse("Incorrect title should be gone", con.hasStatement(s, p, o_wrong, false, g));
}
内容来源于网络,如有侵权,请联系作者删除!