org.openrdf.query.BooleanQuery类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.openrdf.query.BooleanQuery类的一些代码示例,展示了BooleanQuery类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BooleanQuery类的具体详情如下:
包路径:org.openrdf.query.BooleanQuery
类名称:BooleanQuery

BooleanQuery介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

BooleanQuery booleanQuery = con.prepareBoleanQuery(QueryLanguage.SPARQL, queryString);
boolean result = booleanQuery.evaluate();

代码示例来源:origin: blazegraph/database

@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);
  assertThat(query.evaluate(), is(equalTo(true)));
}

代码示例来源:origin: org.openrdf.elmo/elmo-repository

public boolean evaluate() throws QueryEvaluationException {
  try {
    RepositoryConnection con = getConnection();
    QueryLanguage ql = getQueryLanguage();
    String query = getQuery();
    String baseURI = getBaseURI();
    BooleanQuery qry = con.prepareBooleanQuery(ql, query, baseURI);
    qry.setDataset(getDataset());
    qry.setIncludeInferred(getIncludeInferred());
    BindingSet bindings = getBindings();
    for (String name : bindings.getBindingNames()) {
      qry.setBinding(name, bindings.getValue(name));
    }
    return qry.evaluate();
  } catch (MalformedQueryException e) {
    throw new QueryEvaluationException(e);
  } catch (RepositoryException e) {
    throw new QueryEvaluationException(e);
  }
}

代码示例来源:origin: blazegraph/database

queryBuilder.append("{ ?p foaf:name ?name }");
BooleanQuery query = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString());
query.setBinding(NAME, nameBob);
assertThat(query.evaluate(), is(equalTo(true)));
DatasetImpl dataset = new DatasetImpl();
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(true)));
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(true)));
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(false)));
queryBuilder.setLength(0);
queryBuilder.append(PREFIX_FOAF + FOAF_NS + "> ");
queryBuilder.append("{ GRAPH ?g { ?p foaf:name ?name } }");
query = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString());
query.setBinding(NAME, nameBob);
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(false)));
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(false)));
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(true)));

代码示例来源:origin: niclashoyer/neo4j-sparql-extension

BooleanQueryResultWriter writer = factory.getWriter(out);
conn.begin();
boolean result = query.evaluate();
Response res = Response
    .status(Response.Status.SERVICE_UNAVAILABLE)
    .header("X-Max-Response-Time", query.getMaxQueryTime())
    .header("Access-Control-Allow-Origin", "*")
    .build();

代码示例来源:origin: com.mysema.rdf/rdfbean-sesame3

@Override
public void setBinding(String variable, NODE node) {
  booleanQuery.setBinding(variable, dialect.getNode(node));
}

代码示例来源:origin: org.openrdf.sesame/sesame-repository-sail

@Override
public BooleanQuery prepare(ParsedBooleanQuery askQuery) {
  BooleanQuery query = new SailBooleanQuery(askQuery, con);
  query.setIncludeInferred(includeInferred);
  return query;
}

代码示例来源:origin: org.openrdf.sesame/sesame-repository-compliance-base

query.setBinding("name", nameBob);
assertTrue(query.evaluate());
query.setDataset(dataset);
assertTrue(query.evaluate());
query.setDataset(dataset);
assertTrue(query.evaluate());
query.setDataset(dataset);
assertFalse(query.evaluate());
query.setBinding("name", nameBob);
query.setDataset(dataset);
assertFalse(query.evaluate());
query.setDataset(dataset);
assertFalse(query.evaluate());
query.setDataset(dataset);
assertTrue(query.evaluate());

代码示例来源:origin: com.mysema.rdf/rdfbean-sesame2

@Override
public void setBinding(String variable, NODE node) {
  booleanQuery.setBinding(variable, dialect.getNode(node));
}

代码示例来源:origin: org.openrdf.sesame/sesame-sail-spin

@Override
public BooleanQuery prepare(ParsedBooleanQuery askQuery) {
  BooleanQuery query = new SailConnectionBooleanQuery(askQuery, con);
  query.setIncludeInferred(includeInferred);
  return query;
}

代码示例来源:origin: org.apache.marmotta/marmotta-sesame-matchers

@Override
protected boolean matchesSPARQL(RepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException {
  final BooleanQuery booleanQuery = con.prepareBooleanQuery(QueryLanguage.SPARQL, query, baseUri);
  return booleanQuery.evaluate();
}

代码示例来源:origin: org.openrdf.sesame/sesame-repository-compliance-base

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: blazegraph/database

queryBuilder.append("{ ?p foaf:name ?name }");
BooleanQuery query = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString());
query.setBinding(NAME, nameBob);
assertThat(query.evaluate(), is(equalTo(true)));
DatasetImpl dataset = new DatasetImpl();
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(true)));
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(true)));
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(false)));
queryBuilder.setLength(0);
queryBuilder.append(PREFIX_FOAF + FOAF_NS + "> ");
queryBuilder.append("{ GRAPH ?g { ?p foaf:name ?name } }");
query = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString());
query.setBinding(NAME, nameBob);
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(false)));
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(false)));
query.setDataset(dataset);
assertThat(query.evaluate(), is(equalTo(true)));

代码示例来源:origin: com.mysema.rdf/rdfbean-sesame

@Override
public void setBinding(String variable, NODE node) {
  booleanQuery.setBinding(variable, dialect.getNode(node));
}

代码示例来源:origin: com.mysema.rdf/rdfbean-sesame

public static BooleanQuery getQuery(RepositoryConnection connection, BooleanQueryModel booleanQueryModel,
    boolean includeInferred) {
  try {
    QUERY_HOLDER.set(booleanQueryModel);
    BooleanQuery booleanQuery = connection.prepareBooleanQuery(DirectQuery.DIRECTQUERY, "");
    booleanQuery.setIncludeInferred(includeInferred);
    return booleanQuery;
  } catch (StoreException e) {
    throw new RepositoryException(e);
  } catch (MalformedQueryException e) {
    throw new RepositoryException(e);
  }
}

代码示例来源:origin: com.mysema.rdf/rdfbean-sesame2

@Override
public boolean getBoolean() {
  try {
    return booleanQuery.evaluate();
  } catch (QueryEvaluationException e) {
    throw new RepositoryException(e);
  }
}

代码示例来源:origin: org.openrdf.sesame/sesame-queryalgebra-evaluation

/**
 * 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: com.mysema.rdf/rdfbean-sesame3

public static BooleanQuery getQuery(RepositoryConnection connection, BooleanQueryModel booleanQueryModel,
    boolean includeInferred) {
  try {
    QUERY_HOLDER.set(booleanQueryModel);
    BooleanQuery booleanQuery = connection.prepareBooleanQuery(DirectQuery.DIRECTQUERY, "");
    booleanQuery.setIncludeInferred(includeInferred);
    return booleanQuery;
  } catch (StoreException e) {
    throw new RepositoryException(e);
  } catch (MalformedQueryException e) {
    throw new RepositoryException(e);
  }
}

代码示例来源:origin: apache/marmotta

@Override
protected boolean matchesSPARQL(RepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException {
  final BooleanQuery booleanQuery = con.prepareBooleanQuery(QueryLanguage.SPARQL, query, baseUri);
  return booleanQuery.evaluate();
}

代码示例来源:origin: blazegraph/database

@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);
  assertThat(query.evaluate(), is(equalTo(true)));
}

相关文章