Dick,

I'm not completely sure what you're trying to do - a complete minimal example showing how they bits and pieces fit together would be good. It seems to be querying the dataset without the inference graph. I don't see where you query the dataset (and which one)

> if (graphNode.getURI().equals(types.getURI())) {

if (graphNode.equals(types.asNode())  {


On 18/06/13 14:22, Dick Murray wrote:
Hi.

Is it possible to get at the graph i.e. the ?g (specifically the returned
nodes) when the following query is executed?

Yes - getGraph / getNamedModel depending on which level your working at.

SELECT  *
WHERE
   { { ?g <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <
http://www.unit4.com/daas/graph#Graph> }
     GRAPH ?g
       { ?s ?p ?o }
   }

When the result is instantiated I want to return the ?g as an RDFS
infmodel. Ideally I want to decide what to return based on the ?g. I've
traced the execSelect() and the ResultSetMem() but drew a blank as to where
I can get at the ?g's!

ResultSet.next().getResource("g") ;
   or
ResultSet.nextBinding().get(Var.alloc("g")) ;



The following allows me to wrap the returned graph but this is static i.e.
I need to know the ?g's to generate the dgm to pass to the
QueryExecutionFactory.

dataset.begin(ReadWrite.READ);
DatasetGraphMap dgm = new DatasetGraphMap(dataset.asDatasetGraph()) {

@Override
public Graph getGraph(Node graphNode) {
Graph g = super.getGraph(graphNode);
if (graphNode.getURI().equals(types.getURI())) {
g = asRDFS(g);
}
return g;
}
  public Graph asRDFS(Graph g) {
return
ModelFactory.createRDFSModel(ModelFactory.createModelForGraph(g)).getGraph();
}
  };
Graph g = dgm.getGraph(types.asNode());
info(g.size());
dataset.end();

For the following triples loaded in the default graph;

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.

@prefix graph: <http://www.unit4.com/daas/graph#>.

@prefix graphs: <http://www.unit4.com/daas/graphs/>.

graph:Graph
rdf:type rdfs:Class.
graphs:g1
rdf:type graph:Graph.

and these loaded in a named graph <http://www.unit4.com/daas/graphs/g1>;

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.

@prefix graph: <http://www.unit4.com/daas/graph#>.

@prefix graphs: <http://www.unit4.com/daas/graphs/>.

graphs:g1
rdfs:label "Graph 1".

A select returns;

select * where {{ ?g a <http://www.unit4.com/daas/graph#Graph> }. graph ?g
{?s ?p ?o}}
--------------------------------------------------------------------------------------------------------------------------------------------
| g                                     | s
     | p                                            | o         |
============================================================================================================================================
| <http://www.unit4.com/daas/graphs/g1> | <
http://www.unit4.com/daas/graphs/g1> | <
http://www.w3.org/2000/01/rdf-schema#label> | "Graph 1" |
--------------------------------------------------------------------------------------------------------------------------------------------

What I want is for it to return about 40 more... :-)


Reply via email to