From d81a3d5a81d584cb615962ecd5a86ad24d9eebdc Mon Sep 17 00:00:00 2001 From: Nolan Nichols Date: Thu, 16 Oct 2014 00:39:16 -0700 Subject: [PATCH] add: virtuoso named graph support --- niquery/app.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/niquery/app.py b/niquery/app.py index 727f40d..3a47dc0 100644 --- a/niquery/app.py +++ b/niquery/app.py @@ -174,11 +174,19 @@ def get(self, task_id): if async.ready(): prov = async.get(timeout=1.0) graph = json.loads(prov['prov']) - result.update({'@graph': graph}) - select = SelectQuery(config=app.config) - ctx = select.get_graph() - g = rdflib.Graph(store=ctx.store, identifier=NS.iri[async.id]) - g.parse(data=result, format='json-ld') + + # connect to the configured store + store = SelectQuery(config=app.config).get_graph().store + sparql_store = rdflib.ConjunctiveGraph(store=store, + identifier=NS.iri[async.id]) + + # handle lack of support for bnodes + g = rdflib.Graph() + g.parse(data=json.dumps(result['@graph']), format='json-ld') + g.skolemize(new_graph=sparql_store) + + result.update({'graph_id': NS.iri[async.id], + '@graph': graph}) # send a json-ld graph return result # Endpoints @@ -195,4 +203,4 @@ def get(self, task_id): # TODO: 'Validate' NIDM API (Dataset Descriptor) # TODO: Infer NIDM from XNAT + EXCEL (Experiment) -# TODO: Compute from NIDM (Workflow + Results) \ No newline at end of file +# TODO: Compute from NIDM (Workflow + Results)