本文整理汇总了Java中org.eclipse.rdf4j.query.GraphQuery类的典型用法代码示例。如果您正苦于以下问题:Java GraphQuery类的具体用法?Java GraphQuery怎么用?Java GraphQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphQuery类属于org.eclipse.rdf4j.query包,在下文中一共展示了GraphQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: evaluate_SetsBindings
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Test
public void evaluate_SetsBindings() {
// Arrange
GraphQuery query = mock(GraphQuery.class);
GraphQueryResult queryResult = mock(GraphQueryResult.class);
when(repositoryConnection.prepareQuery(QueryLanguage.SPARQL, GRAPH_QUERY)).thenReturn(query);
when(query.evaluate()).thenReturn(queryResult);
ImmutableMap<String, Value> bindings = ImmutableMap.of("dateOfFoundation",
DBEERPEDIA.BROUWTOREN_DATE_OF_FOUNDATION, "fte", DBEERPEDIA.BROUWTOREN_FTE);
// Act
Object result = queryEvaluator.evaluate(repositoryConnection, GRAPH_QUERY, bindings);
// Assert
assertThat(result, instanceOf(GraphQueryResult.class));
verify(query).setBinding("dateOfFoundation", DBEERPEDIA.BROUWTOREN_DATE_OF_FOUNDATION);
verify(query).setBinding("fte", DBEERPEDIA.BROUWTOREN_FTE);
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:QueryEvaluatorTest.java
示例2: 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();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:17,代码来源:MarkLogicGraphQueryTest.java
示例3: 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();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:20,代码来源:MarkLogicGraphQueryTest.java
示例4: 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);
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:27,代码来源:MarkLogicGraphQueryTest.java
示例5: run
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
void run(Configuration configuration) throws ExportException {
try {
SailRepository rep = new SailRepository(new HBaseSail(configuration, htableName, false, 0, true, 0, elasticIndexURL, null));
rep.initialize();
try {
writer.initTimer();
log.logStatus("Query execution started");
Query q = rep.getConnection().prepareQuery(QueryLanguage.SPARQL, sparqlQuery);
if (q instanceof TupleQuery) {
writer.writeTupleQueryResult(((TupleQuery)q).evaluate());
} else if (q instanceof GraphQuery) {
writer.writeGraphQueryResult(((GraphQuery)q).evaluate());
} else {
throw new ExportException("Only SPARQL Tuple and Graph query types are supported.");
}
log.logStatus("Export finished");
} finally {
rep.shutDown();
}
} catch (RepositoryException | MalformedQueryException | QueryEvaluationException e) {
throw new ExportException(e);
} finally {
writer.close();
}
}
开发者ID:Merck,项目名称:Halyard,代码行数:26,代码来源:HalyardExport.java
示例6: 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);
}
}
}
开发者ID:semweb4j,项目名称:semweb4j,代码行数:23,代码来源:RepositoryModel.java
示例7: 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);
}
}
开发者ID:semweb4j,项目名称:semweb4j,代码行数:19,代码来源:RepositoryModelSet.java
示例8: getQueryForResources
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Override
protected GraphQuery getQueryForResources(RepositoryConnection conn) {
String query = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . ?s a ?type . }";
GraphQuery graphQuery = conn.prepareGraphQuery(query);
graphQuery.setBinding("type", ELMO.SITE);
return graphQuery;
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:9,代码来源:SiteResourceProvider.java
示例9: getQueryForResources
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Override
protected GraphQuery getQueryForResources(RepositoryConnection conn) {
String query = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . ?s a ?type . }";
GraphQuery graphQuery = conn.prepareGraphQuery(query);
graphQuery.setBinding("type", ELMO.STAGE);
return graphQuery;
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:9,代码来源:StageResourceProvider.java
示例10: getQueryForResources
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Override
protected GraphQuery getQueryForResources(RepositoryConnection conn) {
String query = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o. ?rep ?parametermapper ?s. }";
GraphQuery graphQuery = conn.prepareGraphQuery(query);
graphQuery.setBinding("parametermapper", ELMO.PARAMETER_MAPPER_PROP);
return graphQuery;
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:9,代码来源:ParameterMapperResourceProvider.java
示例11: getQueryForResources
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Override
protected GraphQuery getQueryForResources(RepositoryConnection conn) {
String query = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . ?s a ?type . }";
GraphQuery graphQuery = conn.prepareGraphQuery(query);
graphQuery.setBinding("type", ELMO.REDIRECTION);
return graphQuery;
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:8,代码来源:RedirectionResourceProvider.java
示例12: getQueryForResources
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Override
protected GraphQuery getQueryForResources(RepositoryConnection conn) {
final String query = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . ?s a ?type . }";
final GraphQuery graphQuery = conn.prepareGraphQuery(query);
graphQuery.setBinding("type", ELMO.REPRESENTATION);
return graphQuery;
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:10,代码来源:RepresentationResourceProvider.java
示例13: getQueryForResources
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Override
protected GraphQuery getQueryForResources(@NonNull RepositoryConnection conn) {
String query = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o. ?rep ?appearance ?s. }";
GraphQuery graphQuery = conn.prepareGraphQuery(query);
graphQuery.setBinding("appearance", ELMO.APPEARANCE_PROP);
return graphQuery;
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:9,代码来源:AppearanceResourceProvider.java
示例14: evaluate_GivesGraphQueryResult_WithGraphQuery
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Test
public void evaluate_GivesGraphQueryResult_WithGraphQuery() {
// Arrange
GraphQuery query = mock(GraphQuery.class);
GraphQueryResult queryResult = mock(GraphQueryResult.class);
when(repositoryConnection.prepareQuery(QueryLanguage.SPARQL, GRAPH_QUERY)).thenReturn(query);
when(query.evaluate()).thenReturn(queryResult);
// Act
Object result = queryEvaluator.evaluate(repositoryConnection, GRAPH_QUERY, ImmutableMap.of());
// Assert
assertThat(result, instanceOf(GraphQueryResult.class));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:15,代码来源:QueryEvaluatorTest.java
示例15: evaluate_ThrowsException_WithGraphEvalutationError
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Test
public void evaluate_ThrowsException_WithGraphEvalutationError() {
// Arrange
GraphQuery query = mock(GraphQuery.class);
when(repositoryConnection.prepareQuery(QueryLanguage.SPARQL, GRAPH_QUERY)).thenReturn(query);
when(query.evaluate()).thenThrow(QueryEvaluationException.class);
// Assert
thrown.expect(BackendException.class);
thrown.expectMessage(String.format("Query could not be evaluated: %s", GRAPH_QUERY));
// Act
queryEvaluator.evaluate(repositoryConnection, GRAPH_QUERY, ImmutableMap.of());
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:15,代码来源:QueryEvaluatorTest.java
示例16: getQueryForResources
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Override
protected GraphQuery getQueryForResources(@NonNull RepositoryConnection connection) {
String query = "PREFIX elmo: <http://dotwebstack.org/def/elmo#> "
+ "CONSTRUCT { ?s ?p ?o . ?o ?op ?oo . } "
+ "WHERE { ?s a ?type . ?type rdfs:subClassOf ?parameter . ?s ?p ?o . "
+ "OPTIONAL { ?o ?op ?oo } } ";
GraphQuery graphQuery = connection.prepareGraphQuery(query);
graphQuery.setBinding("parameter", ELMO.PARAMETER);
return graphQuery;
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:14,代码来源:ParameterDefinitionResourceProvider.java
示例17: getQueryForResources
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Override
protected GraphQuery getQueryForResources(RepositoryConnection conn) {
String query = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . ?s a ?type . }";
GraphQuery graphQuery = conn.prepareGraphQuery(query);
graphQuery.setBinding("type", ELMO.INFORMATION_PRODUCT);
return graphQuery;
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:9,代码来源:InformationProductResourceProvider.java
示例18: getQueryForResources
import org.eclipse.rdf4j.query.GraphQuery; //导入依赖的package包/类
@Override
protected GraphQuery getQueryForResources(RepositoryConnection conn) {
String query =
"CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . ?s a ?type . ?type rdfs:subClassOf ?backend }";
GraphQuery graphQuery = conn.prepareGraphQuery(query);
graphQuery.setBinding("backend", ELMO.BACKEND);
return graphQuery;
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:10,代码来源:BackendResourceProvider.java
示例19: 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();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:16,代码来源:MarkLogicGraphQueryTest.java
示例20: 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();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:16,代码来源:MarkLogicGraphQueryTest.java
注:本文中的org.eclipse.rdf4j.query.GraphQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论