use of org.apache.jena.sparql.resultset.ResultsFormat in project jena by apache.
the class QueryCommandAssembler method open.
@Override
public Object open(Assembler a, Resource root, Mode mode) {
// Query
Resource queryDesc = getUniqueResource(root, AssemblerVocab.pQuery);
Query query = (Query) a.open(a, queryDesc, mode);
// Dataset
Resource datasetDesc = getUniqueResource(root, AssemblerVocab.pDataset);
Dataset dataset = (Dataset) a.open(a, datasetDesc, mode);
// Output format
String s = GraphUtils.getStringValue(root, AssemblerVocab.pOutputFormat);
if (s == null)
s = "text";
ResultsFormat format = ResultsFormat.lookup(s);
QueryExecution qExec = QueryExecutionFactory.create(query, dataset);
return new QExec(query, qExec, format);
}
use of org.apache.jena.sparql.resultset.ResultsFormat in project jena by apache.
the class TestItem method getResults.
/**
* Load results as a SPARQLResult. If the results are a model, no conversion
* to a result set is attempted here.
*/
public SPARQLResult getResults() {
if (resultFile == null)
return null;
ResultsFormat format = ResultsFormat.guessSyntax(resultFile);
if (ResultsFormat.isRDFGraphSyntax(format)) {
Model m = FileManager.get().loadModel(resultFile);
return new SPARQLResult(m);
}
if (ResultsFormat.isDatasetSyntax(format)) {
Dataset d = RDFDataMgr.loadDataset(resultFile);
return new SPARQLResult(d);
}
// Attempt to handle as a resulset or boolean result.s
SPARQLResult x = ResultSetFactory.result(resultFile);
return x;
}
Aggregations