本文整理汇总了Java中org.eclipse.rdf4j.query.GraphQueryResult类的典型用法代码示例。如果您正苦于以下问题:Java GraphQueryResult类的具体用法?Java GraphQueryResult怎么用?Java GraphQueryResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphQueryResult类属于org.eclipse.rdf4j.query包,在下文中一共展示了GraphQueryResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: apply
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的package包/类
@Override
public Response apply(ContainerRequestContext containerRequestContext) {
String path = containerRequestContext.getUriInfo().getPath();
LOG.debug("Handling GET request for path {}", path);
InformationProduct informationProduct = representation.getInformationProduct();
Map<String, String> parameterValues =
representationRequestParameterMapper.map(informationProduct, containerRequestContext);
representation.getParameterMappers().forEach(
parameterMapper -> parameterValues.putAll(parameterMapper.map(containerRequestContext)));
Object result = informationProduct.getResult(parameterValues);
if (ResultType.GRAPH.equals(informationProduct.getResultType())) {
return Response.ok(new GraphEntity((GraphQueryResult) result, representation)).build();
}
if (ResultType.TUPLE.equals(informationProduct.getResultType())) {
return Response.ok(new TupleEntity((TupleQueryResult) result, representation)).build();
}
throw new ConfigurationException(
String.format("Result type %s not supported for information product %s",
informationProduct.getResultType(), informationProduct.getIdentifier()));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:27,代码来源:RepresentationRequestHandler.java
示例2: apply_ReturnsServerErrorResponseWithoutEntityObject_ForGraphResult
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的package包/类
@Test
public void apply_ReturnsServerErrorResponseWithoutEntityObject_ForGraphResult() {
// Arrange
UriInfo uriInfo = mock(UriInfo.class);
when(containerRequestContextMock.getUriInfo()).thenReturn(uriInfo);
when(informationProductMock.getResultType()).thenReturn(ResultType.GRAPH);
GraphQueryResult result = mock(GraphQueryResult.class);
when(informationProductMock.getResult(ImmutableMap.of())).thenReturn(result);
// Act
Response response = getRequestHandler.apply(containerRequestContextMock);
// Assert
assertThat(response.getEntity(), instanceOf(GraphEntity.class));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:17,代码来源:GetRequestHandlerTest.java
示例3: apply_ReturnQueryRepresentation_WhenGraphQueryResult
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的package包/类
@Test
public void apply_ReturnQueryRepresentation_WhenGraphQueryResult() {
// Arrange
when(representation.getInformationProduct()).thenReturn(informationProduct);
GraphQueryResult queryResult = mock(GraphQueryResult.class);
when(informationProduct.getResult(ImmutableMap.of())).thenReturn(queryResult);
when(informationProduct.getResultType()).thenReturn(ResultType.GRAPH);
UriInfo uriInfo = mock(UriInfo.class);
when(containerRequestContext.getUriInfo()).thenReturn(uriInfo);
when(uriInfo.getPath()).thenReturn("/");
// Act
Response response = getRequestHandler.apply(containerRequestContext);
// Assert
assertThat(response.getStatus(), equalTo(200));
assertThat(response.getEntity(), instanceOf(GraphEntity.class));
GraphEntity entity = (GraphEntity) response.getEntity();
assertThat(entity.getQueryResult(), equalTo(queryResult));
assertThat(entity.getRepresentation(), equalTo(representation));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:23,代码来源:RepresentationRequestHandlerTest.java
示例4: evaluate_SetsBindings
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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
示例5: testGraphQueryWithBaseURIInline
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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
示例6: testGraphQueryWithBaseURIWithEmptyBaseURI
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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
示例7: testPrepareGraphQueryWithSingleResult
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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
示例8: writeGraphQueryResult
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的package包/类
@Override
public void writeGraphQueryResult(GraphQueryResult queryResult) throws ExportException {
try {
writer.startRDF();
for (Map.Entry<String, String> me : queryResult.getNamespaces().entrySet()) {
writer.handleNamespace(me.getKey(), me.getValue());
}
while (queryResult.hasNext()) {
writer.handleStatement(queryResult.next());
tick();
}
writer.endRDF();
} catch (QueryEvaluationException | RDFHandlerException e) {
throw new ExportException(e);
}
}
开发者ID:Merck,项目名称:Halyard,代码行数:17,代码来源:HalyardExport.java
示例9: queryConstruct
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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
示例10: queryConstruct
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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
示例11: loadFromConnection
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的package包/类
private long loadFromConnection(UriMappingIterableImpl uriMapping, RepositoryConnection connection)
throws QueryEvaluationException, RepositoryException, MalformedQueryException {
long loadedCount = 0;
for (IRI link : sameAsLinkTypes) {
String query = String.format("CONSTRUCT {?s <%1$s> ?o} WHERE {?s <%1$s> ?o}", link.stringValue());
GraphQueryResult sameAsTriples = connection.prepareGraphQuery(QueryLanguage.SPARQL, query).evaluate();
while (sameAsTriples.hasNext()) {
uriMapping.addLink(sameAsTriples.next());
loadedCount++;
if (loadedCount % LDFTConfigConstants.LOG_LOOP_SIZE == 0) {
LOG.info("... loaded {} sameAs links", loadedCount);
}
}
}
return loadedCount;
}
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:18,代码来源:DataUnitSameAsLinkLoader.java
示例12: evaluate_GivesGraphQueryResult_WithGraphQuery
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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
示例13: evaluate
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的package包/类
/**
* evaluate graph query with RDFHandler
*
* @param resultHandler
* @throws QueryEvaluationException
* @throws RDFHandlerException
*/
@Override
public void evaluate(RDFHandler resultHandler) throws QueryEvaluationException, RDFHandlerException {
GraphQueryResult queryResult = evaluate();
if(queryResult.hasNext())
{
QueryResults.report(queryResult, resultHandler);
}
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:16,代码来源:MarkLogicGraphQuery.java
示例14: testConstructQuery
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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
示例15: testGraphQueryWithBaseURI
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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
示例16: testDescribeQuery
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:13,代码来源:MarkLogicGraphQueryTest.java
示例17: testPrepareGraphQueryWithNoResult
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:12,代码来源:MarkLogicGraphQueryTest.java
示例18: testPrepareGraphQueryClose
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:9,代码来源:MarkLogicGraphQueryTest.java
示例19: sparqlDescribe
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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);
}
}
开发者ID:semweb4j,项目名称:semweb4j,代码行数:13,代码来源:RepositoryModel.java
示例20: sparqlConstruct
import org.eclipse.rdf4j.query.GraphQueryResult; //导入依赖的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);
}
}
开发者ID:semweb4j,项目名称:semweb4j,代码行数:13,代码来源:RepositoryModel.java
注:本文中的org.eclipse.rdf4j.query.GraphQueryResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论