Hi There
This may be a crazy example but I'm wondering if anyone could suggest where
I'm going wrong (both in code and/or approach.)
Basically I want to use a list of QuerySolutonmaps to create a number of
resultsets from a ParameterizedSparqlString.
I want to combine the resultsets together. For this I've used a model (
perhaps incorrectly).
And in the end create a single result set that will be consumed by
something else.
The code below is where I've got to.
It works up to the last line where it throws the error shown.
If anyone could point out my error or offer another way to acomplish the
same thing it would greatly appreciated.
Many Thanks
Phil
// select query previously defined in variable selectquery
//the model to run the query across previously defined as model
//get the passed querysolutionmap list
final java.util.List<com.hp.hpl.jena.query.QuerySolutionMap>
inputQryList = (java.util.ArrayList)globalMap.get(inputBindings); // don't
worry aboout globalmap
//create an iterator for the solution maps
java.util.Iterator<com.hp.hpl.jena.query.QuerySolutionMap>
inputQryListIter = inputQryList.iterator();
//create a model to compile all the results sets in.
final com.hp.hpl.jena.rdf.model.Model resultModel =
com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel();
//loop over all the QuerySolution maps
while (inputQryListIter.hasNext())
{
final com.hp.hpl.jena.query.QuerySolutionMap soln_map =
inputQryListIter.next();
//set parameterizsed sparql string
final com.hp.hpl.jena.query.ParameterizedSparqlString pss = new
com.hp.hpl.jena.query.ParameterizedSparqlString(selectquery,soln_map);
final com.hp.hpl.jena.query.QueryExecution qexec =
com.hp.hpl.jena.query.QueryExecutionFactory.create(pss.toString(), model) ;
final com.hp.hpl.jena.query.ResultSet tempresults =
qexec.execSelect() ; // get the resultset.
// bring all the resultsets together in a new model.... may be a
better way to do this?
final com.hp.hpl.jena.rdf.model.Model tempModel =
com.hp.hpl.jena.query.ResultSetFormatter.toModel(tempresults);
resultModel.add(tempModel);
qexec_<%=cid %>.close();
}
resultModel.write(System.out) //This show that all the code above has
worked and I see resultset syntax in the model for the select queries with
correctly bound varaibles
// now I want to create a resultset from the model
final com.hp.hpl.jena.sparql.resultset.SPARQLResult finalresults = new
com.hp.hpl.jena.sparql.resultset.SPARQLResult(resultModel);
//Everything works fine up to here.
final com.hp.hpl.jena.query.ResultSet results =
finalresults.getResultSet();
The last line throws the error.
com.hp.hpl.jena.sparql.resultset.ResultSetException: Not an ResultSet
result
at com.hp.hpl.jena.sparql.resultset.SPARQLResult.getResultSet