You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Greg Albiston <an...@apache.org> on 2017/10/19 11:19:28 UTC
CMS diff: ARQ - Writing Property Functions
Clone URL (Committers only):
https://cms.apache.org/redirect?new=anonymous;action=diff;uri=http://jena.apache.org/documentation%2Fquery%2Fwriting_propfuncs.mdtext
Greg Albiston
Index: trunk/content/documentation/query/writing_propfuncs.mdtext
===================================================================
--- trunk/content/documentation/query/writing_propfuncs.mdtext (revision 1812597)
+++ trunk/content/documentation/query/writing_propfuncs.mdtext (working copy)
@@ -142,4 +142,28 @@
Note that it can make a lot of sense to generate the `Iterator<Binding>` for `QueryIterPlainWrapper` by means of
Jena's `ExtendedIterator`. This can allow domain-specific value to be easily mapped to `Binding` objects in
- a lazy fashion.
\ No newline at end of file
+ a lazy fashion.
+
+**Graph Operations**
+
+Additional operations on the current, or another, Graph can be achieved through the Execution Context.
+Once retrieved the Graph can be operated upon directly, queried or wrapped in a Model, if preferred.
+New Triples or Graphs can therefore be created as part of the Property Function.
+
+ //Retrieve current Graph.
+ Graph graph = execCxt.getActiveGraph();
+
+ //Wrap Graph in a Model.
+ Model model = ModelFactory.createModelForGraph(graph);
+
+ //Retrieve DatasetGraph of current Graph.
+ DatasetGraph datasetGraph = execCxt.getDataset();
+
+ //Retrieve a different Graph in the Dataset.
+ Node otherGraphNode = NodeFactory.createURI("http://example.org/otherGraph");
+ Graph otherGraph = datasetGraph.getNamedGraph(otherGraphNode);
+
+ //Create a new Graph in the Dataset, or overwrite an existing Named Graph.
+ Graph newGraph = ...
+ //Add data to the newGraph as retaining empty Graphs is implementation dependent.
+ datasetGraph.addGraph(otherGraphNode, newGraph);
\ No newline at end of file