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