本文整理汇总了Java中org.eclipse.rdf4j.query.BooleanQuery.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java BooleanQuery.evaluate方法的具体用法?Java BooleanQuery.evaluate怎么用?Java BooleanQuery.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.rdf4j.query.BooleanQuery
的用法示例。
在下文中一共展示了BooleanQuery.evaluate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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();
}
}
示例4: 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"));
}
示例5: 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"));
}
示例6: 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"));
}
示例7: 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);
}
示例8: 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);
}
示例9: 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();
}
示例10: 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();
}
示例11: 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);
}
示例12: 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);
}
示例13: 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);
}
}
示例14: 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);
}
}