.
This commit is contained in:
@@ -2,4 +2,4 @@ pub mod proto {
|
||||
tonic::include_proto!("org.graphofliberty.inference");
|
||||
}
|
||||
|
||||
pub use tonic::transport::Channel;
|
||||
pub use tonic;
|
||||
+23
-11
@@ -110,8 +110,18 @@ impl Ontology for OntologyService {
|
||||
ONTOLOGY_GRAPH.into_owned()
|
||||
};
|
||||
|
||||
let mut query = SparqlEvaluator::new()
|
||||
.parse_query(&request.sparql_query)
|
||||
let mut evaluator = SparqlEvaluator::new();
|
||||
for (name, iri) in &request.prefixes {
|
||||
evaluator = evaluator.with_prefix(name, iri)
|
||||
.map_err(|err| Status::internal(err.to_string()))?;
|
||||
}
|
||||
|
||||
if let Some(base) = &request.base {
|
||||
evaluator = evaluator.with_base_iri(base)
|
||||
.map_err(|err| Status::internal(err.to_string()))?;
|
||||
}
|
||||
|
||||
let mut query = evaluator.parse_query(&request.sparql_query)
|
||||
.map_err(|err| Status::internal(err.to_string()))?;
|
||||
|
||||
query.dataset_mut().set_default_graph(vec![graph_name.clone()]);
|
||||
@@ -137,15 +147,17 @@ impl Ontology for OntologyService {
|
||||
output_buffer = writer.finish()?;
|
||||
}
|
||||
QueryResults::Graph(graph) => {
|
||||
let mut serializer = RdfSerializer::from_format(RdfFormat::Turtle)
|
||||
.with_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#").map_err(|err| Status::internal(err.to_string()))?
|
||||
.with_prefix("rdac", "http://rdaregistry.info/Elements/c/").map_err(|err| Status::internal(err.to_string()))?
|
||||
.with_prefix("ldp", "http://www.w3.org/ns/ldp#").map_err(|err| Status::internal(err.to_string()))?
|
||||
.with_prefix("fedora", "http://fedora.info/definitions/v4/repository#").map_err(|err| Status::internal(err.to_string()))?
|
||||
.with_prefix("lrmer", "http://iflastandards.info/ns/lrm/lrmer/").map_err(|err| Status::internal(err.to_string()))?
|
||||
.with_prefix("owl", "http://www.w3.org/2002/07/owl#").map_err(|err| Status::internal(err.to_string()))?
|
||||
.with_base_iri("http://fedora.quill.lan/rest/").map_err(|err| Status::internal(err.to_string()))?
|
||||
.for_writer(output_buffer);
|
||||
let mut serializer = RdfSerializer::from_format(RdfFormat::Turtle);
|
||||
for (name, iri) in &request.prefixes {
|
||||
serializer = serializer.with_prefix(name, iri)
|
||||
.map_err(|err| Status::internal(err.to_string()))?;
|
||||
}
|
||||
if let Some(base) = &request.base {
|
||||
serializer = serializer.with_base_iri(base)
|
||||
.map_err(|err| Status::internal(err.to_string()))?;
|
||||
}
|
||||
|
||||
let mut serializer = serializer.for_writer(output_buffer);
|
||||
for triple in graph.filter_map(Result::ok) {
|
||||
serializer.serialize_triple(triple.as_ref())?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user