本文整理汇总了Java中org.eclipse.rdf4j.query.GraphQuery.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java GraphQuery.evaluate方法的具体用法?Java GraphQuery.evaluate怎么用?Java GraphQuery.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.rdf4j.query.GraphQuery
的用法示例。
在下文中一共展示了GraphQuery.evaluate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGraphQueryWithBaseURIInline
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Test
public void testGraphQueryWithBaseURIInline()
throws Exception {
String queryString ="BASE <http://marklogic.com/test/baseuri>\n" +
"PREFIX nn: <http://semanticbible.org/ns/2006/NTNames#>\n" +
"PREFIX test: <http://marklogic.com#test>\n" +
"construct { ?s test:test <relative>} WHERE {?s nn:childOf nn:Eve . }";
GraphQuery graphQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
GraphQueryResult results = graphQuery.evaluate();
Statement st1 = results.next();
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Abel", st1.getSubject().stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Abel", st1.getSubject().stringValue());
Statement st2 = results.next();
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Cain", st2.getSubject().stringValue());
results.close();
}
示例2: testGraphQueryWithBaseURIWithEmptyBaseURI
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Ignore
@Test
public void testGraphQueryWithBaseURIWithEmptyBaseURI()
throws Exception {
String queryString =
"PREFIX nn: <http://semanticbible.org/ns/2006/NTNames#>\n" +
"PREFIX test: <http://marklogic.com#test>\n" +
"construct { ?s test:test <relative>} WHERE {?s nn:childOf nn:Eve . }";
GraphQuery graphQuery = conn.prepareGraphQuery(queryString, "");
exception.expect(QueryEvaluationException.class);
GraphQueryResult results = graphQuery.evaluate();
Statement st1 = results.next();
Assert.assertEquals("http://relative", st1.getObject().stringValue());
@SuppressWarnings("unused")
Statement st2 = results.next();
Assert.assertEquals("http://relative", st1.getObject().stringValue());
results.close();
}
示例3: testPrepareGraphQueryWithSingleResult
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Test
public void testPrepareGraphQueryWithSingleResult() throws Exception
{
Resource context1 = conn.getValueFactory().createIRI("http://marklogic.com/test/context1");
ValueFactory f= conn.getValueFactory();
IRI alice = f.createIRI("http://example.org/people/alice");
IRI name = f.createIRI("http://example.org/ontology/name");
Literal alicesName = f.createLiteral("Alice1");
Statement st1 = f.createStatement(alice, name, alicesName);
conn.add(st1,context1);
String query = " DESCRIBE <http://example.org/people/alice> ";
GraphQuery queryObj = conn.prepareGraphQuery(query);
GraphQueryResult result = queryObj.evaluate();
Assert.assertTrue(result != null);
Assert.assertTrue(result.hasNext());
@SuppressWarnings("unused")
Statement st = result.next();
Assert.assertFalse(result.hasNext());
result.close();
conn.clear(context1);
}
示例4: queryConstruct
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Override
public ClosableIterable<Statement> queryConstruct(String query, String querylanguage)
throws QueryLanguageNotSupportedException {
assertModel();
if (querylanguage.equalsIgnoreCase("SPARQL"))
return sparqlConstruct(query);
else {
QueryLanguage ql = QueryLanguage.valueOf(querylanguage);
if (ql == null) {
throw new QueryLanguageNotSupportedException("Unsupported query language: '"
+ querylanguage + "'");
}
try {
GraphQuery prepared = this.connection.prepareGraphQuery(ql, query);
GraphQueryResult graphQueryResult = prepared.evaluate();
return new GraphIterable(graphQueryResult, this);
} catch (MalformedQueryException | RepositoryException |
UnsupportedQueryLanguageException | QueryEvaluationException e) {
throw new ModelRuntimeException(e);
}
}
}
示例5: queryConstruct
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Override
public ClosableIterable<Statement> queryConstruct(String queryString, String queryLanguage)
throws QueryLanguageNotSupportedException, ModelRuntimeException {
this.assertModel();
// resolve the query language String to a QueryLanguage
QueryLanguage language = ConversionUtil.toRDF4JQueryLanguage(queryLanguage);
try {
// determine query result
GraphQuery query = this.connection.prepareGraphQuery(language, queryString);
GraphQueryResult queryResult = query.evaluate();
// wrap it in a GraphIterable
return new GraphIterable(queryResult, null);
} catch(RDF4JException e) {
throw new ModelRuntimeException(e);
}
}
示例6: testConstructQuery
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Test
public void testConstructQuery()
throws Exception {
String queryString = "PREFIX nn: <http://semanticbible.org/ns/2006/NTNames#>\n" +
"PREFIX test: <http://marklogic.com#test>\n" +
"\n" +
"construct { ?s test:test \"0\"} WHERE {?s nn:childOf nn:Eve . }";
GraphQuery graphQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
GraphQueryResult results = graphQuery.evaluate();
Statement st1 = results.next();
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Abel", st1.getSubject().stringValue());
Statement st2 = results.next();
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Cain", st2.getSubject().stringValue());
results.close();
}
示例7: testGraphQueryWithBaseURI
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Test
public void testGraphQueryWithBaseURI()
throws Exception {
String queryString =
"PREFIX nn: <http://semanticbible.org/ns/2006/NTNames#>\n" +
"PREFIX test: <http://marklogic.com#test>\n" +
"construct { ?s test:test <relative>} WHERE {?s nn:childOf nn:Eve . }";
GraphQuery graphQuery = conn.prepareGraphQuery(queryString, "http://marklogic.com/test/baseuri/");
GraphQueryResult results = graphQuery.evaluate();
Statement st1 = results.next();
Assert.assertEquals("http://marklogic.com/test/baseuri/relative", st1.getObject().stringValue());
Statement st2 = results.next();
Assert.assertEquals("http://marklogic.com/test/baseuri/relative", st2.getObject().stringValue());
results.close();
}
示例8: testDescribeQuery
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Test
public void testDescribeQuery()
throws Exception {
String queryString = "DESCRIBE <http://semanticbible.org/ns/2006/NTNames#Shelah>";
GraphQuery graphQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
GraphQueryResult results = graphQuery.evaluate();
Statement st1 = results.next();
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Shelah", st1.getSubject().stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#childOf", st1.getPredicate().stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#CainanSonOfArphaxad", st1.getObject().stringValue());
results.close();
}
示例9: testPrepareGraphQueryWithNoResult
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Test
public void testPrepareGraphQueryWithNoResult() throws Exception
{
String query = "DESCRIBE <http://example.org/nonexistant>";
GraphQuery queryObj = conn.prepareGraphQuery(query);
GraphQueryResult result = queryObj.evaluate();
Assert.assertTrue(result != null);
Assert.assertFalse(result.hasNext());
result.close();
}
示例10: testPrepareGraphQueryClose
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Test
public void testPrepareGraphQueryClose() throws Exception
{
String query = "DESCRIBE <http://example.org/ontology/name>";
GraphQuery queryObj = conn.prepareGraphQuery(query);
GraphQueryResult result = queryObj.evaluate();
result.close();
}
示例11: getStatements
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的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);
}
}
示例12: sparqlDescribe
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Override
public ClosableIterable<Statement> sparqlDescribe(String query) throws ModelRuntimeException {
assertModel();
try {
GraphQuery prepared = this.connection.prepareGraphQuery(QueryLanguage.SPARQL, query);
GraphQueryResult graphQueryResult = prepared.evaluate();
return new GraphIterable(graphQueryResult, this);
} catch (MalformedQueryException | RepositoryException |
UnsupportedQueryLanguageException | QueryEvaluationException e) {
throw new ModelRuntimeException(e);
}
}
示例13: sparqlConstruct
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Override
public ClosableIterable<Statement> sparqlConstruct(String query) throws ModelRuntimeException {
assertModel();
try {
GraphQuery prepared = this.connection.prepareGraphQuery(QueryLanguage.SPARQL, query);
GraphQueryResult graphQueryResult = prepared.evaluate();
return new GraphIterable(graphQueryResult, this);
} catch (MalformedQueryException | RepositoryException |
UnsupportedQueryLanguageException | QueryEvaluationException e) {
throw new ModelRuntimeException(e);
}
}
示例14: sparqlConstruct
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Override
public ClosableIterable<Statement> sparqlConstruct(String queryString)
throws ModelRuntimeException {
this.assertModel();
GraphQuery query;
try {
query = this.connection.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
GraphQueryResult graphQueryResult = query.evaluate();
return new StatementIterable(graphQueryResult, null);
} catch(RDF4JException e) {
throw new ModelRuntimeException(e);
}
}
示例15: sparqlDescribe
import org.eclipse.rdf4j.query.GraphQuery; //导入方法依赖的package包/类
@Override
public ClosableIterable<Statement> sparqlDescribe(String queryString)
throws ModelRuntimeException {
this.assertModel();
GraphQuery query;
try {
query = this.connection.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
GraphQueryResult graphQueryResult = query.evaluate();
return new StatementIterable(graphQueryResult, null);
} catch(RDF4JException e) {
throw new ModelRuntimeException(e);
}
}