• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BooleanQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.rdf4j.query.BooleanQuery的典型用法代码示例。如果您正苦于以下问题:Java BooleanQuery类的具体用法?Java BooleanQuery怎么用?Java BooleanQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BooleanQuery类属于org.eclipse.rdf4j.query包,在下文中一共展示了BooleanQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testUpdateQueryWithPerms

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void testUpdateQueryWithPerms()
        throws Exception {

    GraphManager gmgr = adminClient.newGraphManager();
    Resource context = conn.getValueFactory().createIRI("http://marklogic.com/test/graph/permstest");

    String defGraphQuery = "INSERT DATA { GRAPH <http://marklogic.com/test/graph/permstest> { <http://marklogic.com/test> <pp1> <oo1> } }";
    String checkQuery = "ASK WHERE {  GRAPH <http://marklogic.com/test/graph/permstest> {<http://marklogic.com/test> <pp1> <oo1> }}";
    MarkLogicUpdateQuery updateQuery = conn.prepareUpdate(QueryLanguage.SPARQL, defGraphQuery);
    GraphPermissions gp = gmgr.permission("view-admin", Capability.READ).permission("cpf-restart", Capability.EXECUTE);
    Assert.assertEquals("should have 2 perms defined",2,gp.size());
    updateQuery.setGraphPerms(gp);
    updateQuery.execute();

    BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, checkQuery);
    boolean results = booleanQuery.evaluate();
    Assert.assertEquals(true, results);

    conn.clear(context);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:22,代码来源:MarkLogicGraphPermsTest.java


示例2: testUpdateQueryWithPermsFromConnectionDefaults

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void testUpdateQueryWithPermsFromConnectionDefaults()
        throws Exception {

    GraphPermissions gp = conn.getDefaultGraphPerms();
    Assert.assertEquals(0,gp.size());
    GraphManager gmgr = adminClient.newGraphManager();
    conn.setDefaultGraphPerms(gmgr.permission("app-user", Capability.READ));


    Resource context = conn.getValueFactory().createIRI("http://marklogic.com/test/graph/permstest");

    String defGraphQuery = "INSERT DATA { GRAPH <http://marklogic.com/test/graph/permstest> { <http://marklogic.com/test> <pp1> <oo1> } }";
    String checkQuery = "ASK WHERE {  GRAPH <http://marklogic.com/test/graph/permstest> {<http://marklogic.com/test> <pp1> <oo1> }}";
    MarkLogicUpdateQuery updateQuery = conn.prepareUpdate(QueryLanguage.SPARQL, defGraphQuery);
    updateQuery.execute();

    BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, checkQuery);
    boolean results = booleanQuery.evaluate();
    Assert.assertEquals(true, results);

    conn.clear(context);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:24,代码来源:MarkLogicGraphPermsTest.java


示例3: ask

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Override
public boolean ask(Service service, BindingSet bindings, String baseUri) throws QueryEvaluationException {
	RepositoryConnection conn = endpoint.getConn();
	try {
		BooleanQuery query = conn.prepareBooleanQuery(QueryLanguage.SPARQL, service.getAskQueryString(), 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(Throwable e) {
		throw new QueryEvaluationException(e);
	} finally {
		conn.close();
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:19,代码来源:SAILFederatedService.java


示例4: evaluate_ThrowsException_WithUnsupportedQuery

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void evaluate_ThrowsException_WithUnsupportedQuery() {
  // Arrange
  BooleanQuery query = mock(BooleanQuery.class);
  when(repositoryConnection.prepareQuery(QueryLanguage.SPARQL, BOOLEAN_QUERY)).thenReturn(query);

  // Assert
  thrown.expect(BackendException.class);
  thrown.expectMessage(String.format("Query type '%s' not supported.", query.getClass()));

  // Act
  queryEvaluator.evaluate(repositoryConnection, BOOLEAN_QUERY, ImmutableMap.of());
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:14,代码来源:QueryEvaluatorTest.java


示例5: testUpdateQuery

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void testUpdateQuery()
        throws Exception {
    String defGraphQuery = "INSERT DATA { GRAPH <http://marklogic.com/test/g27> { <http://marklogic.com/test> <pp1> <oo1> } }";
    String checkQuery = "ASK WHERE { <http://marklogic.com/test> <pp1> <oo1> }";
    Update updateQuery = conn.prepareUpdate(QueryLanguage.SPARQL, defGraphQuery);
    updateQuery.execute();
    BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, checkQuery);
    boolean results = booleanQuery.evaluate();
    Assert.assertEquals(true, results);
    conn.clear(conn.getValueFactory().createIRI("http://marklogic.com/test/g27"));
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:13,代码来源:MarkLogicUpdateQueryTest.java


示例6: testUpdateQueryWithBaseURI

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void testUpdateQueryWithBaseURI()
        throws Exception {
    String defGraphQuery = "INSERT DATA { GRAPH <http://marklogic.com/example/context1> {  <http://marklogic.com/test/subject> <relative1> <relative2> } }";
    String checkQuery = "ASK WHERE { <http://marklogic.com/test/subject> <relative1> <relative2> }";
    Update updateQuery = conn.prepareUpdate(QueryLanguage.SPARQL, defGraphQuery,"http://marklogic.com/test/baseuri");
    updateQuery.execute();
    BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, checkQuery,"http://marklogic.com/test/baseuri");
    boolean results = booleanQuery.evaluate();
    Assert.assertEquals(true, results);
    conn.clear(conn.getValueFactory().createIRI("http://marklogic.com/example/context1"));
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:13,代码来源:MarkLogicUpdateQueryTest.java


示例7: testUpdateQueryWithExistingBaseURI

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void testUpdateQueryWithExistingBaseURI()
        throws Exception {
    String defGraphQuery = "BASE <http://marklogic.com/test/baseuri> INSERT DATA { GRAPH <http://marklogic.com/test/context10> {  <http://marklogic.com/test/subject> <pp1> <oo1> } }";
    String checkQuery = "BASE <http://marklogic.com/test/baseuri> ASK WHERE { <http://marklogic.com/test/subject> <pp1> <oo1> }";
    MarkLogicUpdateQuery updateQuery = conn.prepareUpdate(QueryLanguage.SPARQL, defGraphQuery,"http://marklogic.com/test/baseuri");
    updateQuery.execute();
    BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, checkQuery);
    boolean results = booleanQuery.evaluate();
    Assert.assertEquals(true, results);
    conn.clear(conn.getValueFactory().createIRI("http://marklogic.com/test/context10"));
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:13,代码来源:MarkLogicUpdateQueryTest.java


示例8: testBooleanQuery

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void testBooleanQuery()
        throws Exception {
    String queryString = "ASK {GRAPH <http://example.org/test/g27> {<http://semanticbible.org/ns/2006/NTNames#Shelah1> ?p ?o}}";
    BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, queryString);
    boolean results = booleanQuery.evaluate();
    Assert.assertEquals(false, results);
    queryString = "ASK {GRAPH <http://example.org/test/g27> {<http://semanticbible.org/ns/2006/NTNames#Shelah> ?p ?o}}";
    booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, queryString);
    results = booleanQuery.evaluate();
    Assert.assertEquals(true, results);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:13,代码来源:MarkLogicBooleanQueryTest.java


示例9: testBooleanQueryWithOverloadedMethods

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void testBooleanQueryWithOverloadedMethods()
        throws Exception {
    String queryString = "ASK { <http://semanticbible.org/ns/2006/NTNames#Shelah1> ?p ?o}";
    BooleanQuery booleanQuery = conn.prepareBooleanQuery(queryString);
    booleanQuery = conn.prepareBooleanQuery(queryString,"http://marklogic.com/test/baseuri");
    boolean results = booleanQuery.evaluate();
    Assert.assertEquals(false, results);
    queryString = "ASK { <http://semanticbible.org/ns/2006/NTNames#Shelah> ?p ?o}";
    booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, queryString);
    results = booleanQuery.evaluate();
    Assert.assertEquals(true, results);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:14,代码来源:MarkLogicBooleanQueryTest.java


示例10: testBooleanQueryQueryEvaluationException

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test(expected=org.eclipse.rdf4j.query.QueryEvaluationException.class)
public void testBooleanQueryQueryEvaluationException()
        throws Exception {
    String queryString = "ASK GRAPH <http://example.org/test/g27> {<http://semanticbible.org/ns/2006/NTNames#Shelah1> ?p ?o}}";
    BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, queryString);
    boolean results = booleanQuery.evaluate();
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:8,代码来源:MarkLogicBooleanQueryTest.java


示例11: testBooleanQueryMalformedException

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test(expected=org.eclipse.rdf4j.query.QueryEvaluationException.class)
public void testBooleanQueryMalformedException()
        throws Exception {
    String queryString = "ASK1 GRAPH <http://example.org/test/g27> {<http://semanticbible.org/ns/2006/NTNames#Shelah1> ?p ?o}}";
    BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, queryString);
    boolean results = booleanQuery.evaluate();
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:8,代码来源:MarkLogicBooleanQueryTest.java


示例12: testPrepareBooleanQuery3

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void testPrepareBooleanQuery3() throws Exception {

	URL url = MarkLogicRepositoryConnectionTest.class.getResource(TEST_DIR_PREFIX + "tigers.ttl");

	testAdminCon.add(url, "", RDFFormat.TURTLE, graph1);

	Assert.assertEquals(107L, testAdminCon.size());

	String query1 = "PREFIX  bb: <http://marklogic.com/baseball/players#>" + "ASK " + "WHERE" + "{"
			+ " ?s bb:position ?o." + "}";

	BooleanQuery bq = testAdminCon.prepareBooleanQuery(query1);
	bq.setBinding("o", vf.createLiteral("coach"));
	boolean result1 = bq.evaluate();
	Assert.assertTrue(result1);
	bq.clearBindings();

	bq.setBinding("o", vf.createLiteral("pitcher"));
	boolean result2 = bq.evaluate();
	Assert.assertTrue(result2);
	bq.clearBindings();

	bq.setBinding("o", vf.createLiteral("abcd"));
	boolean result3 = bq.evaluate();
	Assert.assertFalse(result3);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:28,代码来源:MarkLogicRepositoryConnectionTest.java


示例13: testPrepareQuery4

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void testPrepareQuery4() throws Exception {

	URL url = MarkLogicRepositoryConnectionTest.class.getResource(TEST_DIR_PREFIX + "tigers.ttl");
	testAdminCon.add(url, "", RDFFormat.TURTLE);
	Assert.assertEquals(107L, testAdminCon.size());

	String query1 = "ASK " + "WHERE" + "{" + " ?s <#position> ?o." + "}";

	Query bq = testAdminCon.prepareQuery(query1, "http://marklogic.com/baseball/players");
	bq.setBinding("o", vf.createLiteral("pitcher"));
	boolean result1 = ((BooleanQuery) bq).evaluate();
	Assert.assertTrue(result1);

}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:16,代码来源:MarkLogicRepositoryConnectionTest.java


示例14: prepareQuery

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Override
public SailQuery prepareQuery(QueryLanguage ql, String queryString,
		String baseURI)
{
	SailQuery q = super.prepareQuery(ql, queryString, baseURI);
	if (q instanceof TupleQuery)
		insertOriginalQueryString(q, queryString, QueryType.SELECT);
	else if (q instanceof GraphQuery)
		insertOriginalQueryString(q, queryString, QueryType.CONSTRUCT);
	else if (q instanceof BooleanQuery)
		insertOriginalQueryString(q, queryString, QueryType.ASK);
	return q;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:14,代码来源:FedXSailRepositoryConnection.java


示例15: getStatements

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> getStatements(
		String preparedQuery, RepositoryConnection conn, QueryType queryType)
		throws RepositoryException, MalformedQueryException,
		QueryEvaluationException
{
	switch (queryType)
	{
	case SELECT:
		monitorRemoteRequest();
		TupleQuery tQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, preparedQuery);
		disableInference(tQuery);
		return tQuery.evaluate();
	case CONSTRUCT:
		monitorRemoteRequest();
		GraphQuery gQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, preparedQuery);
		disableInference(gQuery);
		return new GraphToBindingSetConversionIteration(gQuery.evaluate());
	case ASK:
		monitorRemoteRequest();
		BooleanQuery bQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, preparedQuery);
		disableInference(bQuery);
		return booleanToBindingSetIteration(bQuery.evaluate());
	default:
		throw new UnsupportedOperationException(
				"Operation not supported for query type " + queryType);
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:29,代码来源:TripleSourceBase.java


示例16: executeBooleanRunsOnTransactionalConnectionWhenTransactionIsActive

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Test
public void executeBooleanRunsOnTransactionalConnectionWhenTransactionIsActive() throws Exception {
    final String query = "ASK some query";
    final RepositoryConnection conn = mock(RepositoryConnection.class);
    final BooleanQuery bq = mock(BooleanQuery.class);
    when(conn.prepareBooleanQuery(QueryLanguage.SPARQL, query)).thenReturn(bq);
    when(centralMock.acquireConnection()).thenReturn(conn);
    connector.begin();
    connector.executeBooleanQuery(query);

    verify(conn).prepareBooleanQuery(QueryLanguage.SPARQL, query);
    verify(bq).evaluate();
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:14,代码来源:PoolingStorageConnectorTest.java


示例17: renderInternal

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
protected void renderInternal(Map model, HttpServletRequest request, HttpServletResponse response) throws IOException {
    BooleanQueryResultWriterFactory brWriterFactory = (BooleanQueryResultWriterFactory)model.get("factory");
    BooleanQueryResultFormat brFormat = brWriterFactory.getBooleanQueryResultFormat();
    response.setStatus(200);
    this.setContentType(response, brFormat);
    this.setContentDisposition(model, response, brFormat);
    boolean headersOnly = ((Boolean)model.get("headersOnly")).booleanValue();
    if(!headersOnly) {
        ServletOutputStream out = response.getOutputStream();

        try {
            BooleanQueryResultWriter e = brWriterFactory.getWriter(out);
            BooleanQuery query = ((BooleanQuery)model.get("queryResult"));
            boolean value = query.evaluate();
            e.handleBoolean(value);
        } catch (QueryResultHandlerException var13) {
            if(var13.getCause() != null && var13.getCause() instanceof IOException) {
                throw (IOException)var13.getCause();
            }

            throw new IOException(var13);
        } finally {
            out.close();
        }
    }

    this.logEndOfRequest(request);
}
 
开发者ID:semagrow,项目名称:semagrow,代码行数:29,代码来源:BooleanQueryResultView.java


示例18: sparqlAsk

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Override
public boolean sparqlAsk(String query) throws ModelRuntimeException {
	assertModel();
	try {
		BooleanQuery prepared = this.connection.prepareBooleanQuery(QueryLanguage.SPARQL, query);
		return prepared.evaluate();
	} catch (MalformedQueryException | RepositoryException |
			UnsupportedQueryLanguageException | QueryEvaluationException e) {
		throw new ModelRuntimeException(e);
	}
}
 
开发者ID:semweb4j,项目名称:semweb4j,代码行数:12,代码来源:RepositoryModel.java


示例19: sparqlAsk

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
@Override
public boolean sparqlAsk(String queryString) throws ModelRuntimeException {
	this.assertModel();
	BooleanQuery booleanQuery;
	try {
		booleanQuery = this.connection.prepareBooleanQuery(QueryLanguage.SPARQL, queryString);
		boolean result = booleanQuery.evaluate();
		return result;
	} catch(RDF4JException e) {
		throw new ModelRuntimeException(e);
	}
}
 
开发者ID:semweb4j,项目名称:semweb4j,代码行数:13,代码来源:RepositoryModelSet.java


示例20: prepareBooleanQuery

import org.eclipse.rdf4j.query.BooleanQuery; //导入依赖的package包/类
/**
 * Prepare a boolean query which uses the underlying federation to evaluate the query.<p>
 * 
 * The queryString is modified to use the declared PREFIX declarations, see 
 * {@link Config#getPrefixDeclarations()} for details.
 * 
 * @param queryString
 * @return
 * @throws MalformedQueryException
 */
public BooleanQuery prepareBooleanQuery(String queryString) {
	Query q = prepareQuery(queryString);
	if (!(q instanceof BooleanQuery))
		throw new FedXRuntimeException("Unexpected query type: " + q.getClass());
	return (BooleanQuery)q;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:17,代码来源:QueryManager.java



注:本文中的org.eclipse.rdf4j.query.BooleanQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SendMessage类代码示例发布时间:2022-05-23
下一篇:
Java TDoubleDoubleMap类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap