Java Code Examples for org.apache.jena.sparql.core.DatasetGraph#getGraph()
The following examples show how to use
org.apache.jena.sparql.core.DatasetGraph#getGraph() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatasetDeclarationPlan.java From sparql-generate with Apache License 2.0 | 6 votes |
private void addNamedGraph(Binding binding, Context context, DatasetGraph dsg, Expr sourceExpr) { String sourceURI = evalSourceURI(binding, context, sourceExpr); final String absURI = baseURI(sourceURI, baseURI); Dataset dataset = ContextUtils.getDataset(context); Node n = NodeFactory.createURI(absURI); Graph g = dsg.getGraph(n); if (g == null) { g = GraphFactory.createJenaDefaultGraph(); dsg.addGraph(n, g); } // default: check the dataset if (dataset.containsNamedModel(absURI)) { Graph dg = dataset.getNamedModel(absURI).getGraph(); GraphUtil.addInto(g, dg); return; } // fallback: load as RDF graph StreamRDF dest = StreamRDFLib.graph(g); ContextUtils.loadGraph(context, sourceURI, absURI, dest); }
Example 2
Source File: TestRDFChangesGraph.java From rdf-delta with Apache License 2.0 | 5 votes |
private static Graph txnGraph(String graphName) { DatasetGraph dsg = DatasetGraphFactory.createTxnMem(); Node gn = NodeFactory.createURI(graphName); Graph g = dsg.getGraph(gn); // Jena 3.5.0 and earlier. // g = new GraphWrapper(g) { // @Override public TransactionHandler getTransactionHandler() { return new TransactionHandlerView(dsg); } // }; return g; }
Example 3
Source File: DeltaLinkEvents.java From rdf-delta with Apache License 2.0 | 5 votes |
/** * Enable graph events from applying patches to this dataset. * Depends on the DatasetGraph returning the same (or at least "right") * graph java object each time which is */ public static void enableGraphEvents(DeltaLink dLink, Id dsRef, DatasetGraph dsg) { DatasetGraph dsg2 = DSG.stableViewGraphs(dsg); Function<Node, Graph> router = gn-> (gn==null) ? dsg2.getDefaultGraph() : dsg2.getGraph(gn); enableGraphEvents(dLink, dsRef, router); }
Example 4
Source File: DatasetDeclarationPlan.java From sparql-generate with Apache License 2.0 | 5 votes |
private void addNamedGraph(Binding binding, Context context, DatasetGraph dsg, SPARQLExtQuery generate, Expr name) { String sourceURI = evalSourceURI(binding, context, name); final String absURI = baseURI(sourceURI, baseURI); Node n = NodeFactory.createURI(absURI); Graph g = dsg.getGraph(n); if (g == null) { g = GraphFactory.createJenaDefaultGraph(); dsg.addGraph(n, g); } loadGraph(binding, context, generate, g); }