use of org.apache.jena.sparql.core.DatasetDescription in project jena by apache.
the class DatasetDescriptionAssembler method open.
@Override
public Object open(Assembler a, Resource root, Mode mode) {
DatasetDescription ds = new DatasetDescription();
// -------- Default graph
// Can use ja:graph or ja:defaultGraph
List<String> dftGraphs1 = GraphUtils.multiValueString(root, DatasetAssemblerVocab.pDefaultGraph);
List<String> dftGraphs2 = GraphUtils.multiValueString(root, DatasetAssemblerVocab.pGraph);
ds.getDefaultGraphURIs().addAll(dftGraphs1);
ds.getDefaultGraphURIs().addAll(dftGraphs2);
// -------- Named graphs
List<String> namedGraphURIs = GraphUtils.multiValueString(root, DatasetAssemblerVocab.pNamedGraph);
ds.getNamedGraphURIs().addAll(namedGraphURIs);
return ds;
}
use of org.apache.jena.sparql.core.DatasetDescription in project jena by apache.
the class SPARQL_QueryDataset method decideDataset.
/** Decide the dataset - this modifies the query
* If the query has a dataset description.
*/
@Override
protected Dataset decideDataset(HttpAction action, Query query, String queryStringLog) {
DatasetGraph dsg = action.getActiveDSG();
DatasetDescription dsDesc = getDatasetDescription(action, query);
if (dsDesc != null) {
dsg = DynamicDatasets.dynamicDataset(dsDesc, dsg, false);
if (query.hasDatasetDescription()) {
query.getGraphURIs().clear();
query.getNamedGraphURIs().clear();
}
}
return DatasetFactory.wrap(dsg);
}
use of org.apache.jena.sparql.core.DatasetDescription in project jena by apache.
the class QueryEngineBase method prepareDataset.
private DatasetGraph prepareDataset(DatasetGraph originalDataset, Query query) {
DatasetDescription dsDesc = DatasetDescription.create(query, context);
DatasetGraph dsg = originalDataset;
if (dsg != null) {
if (dsDesc != null) {
if (query.hasDatasetDescription())
dsg = dynamicDataset(dsDesc, dsg, false);
}
return dsg;
}
// No DatasetGraph
if (!query.hasDatasetDescription())
throw new QueryExecException("No dataset and no dataset description for query");
// DatasetDescription : Build it.
String baseURI = query.getBaseURI();
if (baseURI == null)
baseURI = IRIs.getSystemBase().str();
dsg = DatasetUtils.createDatasetGraph(dsDesc, baseURI);
return dsg;
}
use of org.apache.jena.sparql.core.DatasetDescription in project jena by apache.
the class SPARQL_QueryDataset method decideDatasetDynamic.
/**
* Function to return the {@code Pair<DatasetGraph, Query>} based on processing any dataset description as {@link DynamicDatasets a dynamic dataset}.
* The query is modified to remove any dataset description.
*
* @param action
* @param query
* @param queryStringLog
* @return Pair<DatasetGraph, Query>
*/
public Pair<DatasetGraph, Query> decideDatasetDynamic(HttpAction action, Query query, String queryStringLog) {
DatasetGraph dsg = getDataset(action);
DatasetDescription dsDesc = SPARQLProtocol.getDatasetDescription(action, query);
if (dsDesc != null) {
dsg = DynamicDatasets.dynamicDataset(dsDesc, dsg, false);
if (query.hasDatasetDescription()) {
query.getGraphURIs().clear();
query.getNamedGraphURIs().clear();
}
}
return Pair.create(dsg, query);
}
Aggregations