Permalink
Browse files

AG4 Jena/Java Tutorials update.

#       deleted:    allegrographdiagram.jpg
#       new file:   allegrographdiagramJava.jpg
#       new file:   allegrographdiagramJena.jpg
#       new file:   createconnectionobjectJena.jpg
#       new file:   jena-tutorial-40.html
#       modified:   JenaTutorialExamples.java
#       modified:   java-tutorial-40.html

Created Jena tutorial; made small changes in the JenaTutorialExamples.java file;
removed old diagram from Java tutorial; added one new diagram to the Java tutorial;
added two new diagrams in the Jena tutorial; made miscellenious minor fixes to the
Java tutorial as I noticed typos in the Jena file, which was based on it.

BDC
  • Loading branch information...
1 parent 0a6c1bc commit 44f96c9530936cff8bcf6a1d4e55f5b13398234a @BruceDClayton BruceDClayton committed Dec 14, 2009
@@ -525,7 +525,6 @@ public static void example13() throws Exception {
public static void example19() throws Exception {
AGGraphMaker maker = example1(false);
AGModel model = new AGModel(maker.getGraph());
- // Examples of RDFS++ inference. Was originally example 2A.
Resource robert = model.createResource("http://example.org/people/robert");
Resource roberta = model.createResource("http://example.org/people/roberta");
Resource bob = model.createResource("http://example.org/people/bob");
@@ -539,8 +538,6 @@ public static void example19() throws Exception {
Literal bobbysName = model.createLiteral("Bobby");
Literal robertsName = model.createLiteral("Robert");
Literal robertasName = model.createLiteral("Roberta");
- // Bob is the same person as Robert
- model.add(bob, OWL.sameAs, robert);
// Robert, Bob, and children are people
model.add(robert, RDF.type, person);
model.add(roberta, RDF.type, person);
@@ -555,6 +552,8 @@ public static void example19() throws Exception {
model.add(robert, fatherOf, roberta);
// bob has a child
model.add(bob, fatherOf, bobby);
+ // Bob is the same person as Robert
+ model.add(bob, OWL.sameAs, robert);
// List the children of Robert, with inference OFF.
println("\nChildren of Robert, inference OFF");
Deleted file not rendered
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -60,7 +60,7 @@ <h2 id="Overview">Overview&nbsp;&nbsp;&nbsp;<a class="returnlink" href="#Content
<td width="286"><p>AllegroGraph 4.0 Server runs as a Windows service in this example. It contains the Java API, which is part of the AllegroGraph installation. </p>
<p>Java communicates with AllegroGraph through HTTP port 8080 in this example. Java and AllegroGraph may be installed on the same computer, but in practice one server is shared by multiple clients. </p>
<p>Load TutorialExamples.java into Java to view the tutorial examples. </p></td>
- <td width="668"><img src="allegrographdiagram.jpg" width="668" height="443"></td>
+ <td width="668"><img src="allegrographdiagramJava.jpg" width="668" height="443"></td>
</tr>
</table>
<p>Each lesson in <strong>TutorialExamples.java</strong> is encapsulated in a Java method, named exampleN(), where N ranges from 0 to 21 (or more). The function names are referenced in the title of each section to make it easier to compare the tutorial text and the living code of the examples file. </p>
@@ -191,7 +191,7 @@ <h2 id="Creating a Repository">Creating a Repository (example1()) &nbsp;&nbsp;&n
<p>In the examples, we are careful to delete previous state before continuing. You probably would not do this in your actual application:</p>
<pre class="input"> catalog.deleteRepository(REPOSITORY_ID); </pre>
<p>The next step is to create a client-side repository object representing the respository we wish to open, by calling the
- <strong>getRepository()</strong> method of the catalog object. We have to provide the name of the desired repository (REPOSITORY_ID in this case, which is bound to the string &quot;javatutorial&quot;). </p>
+ <strong>createRepository()</strong> method of the catalog object. We have to provide the name of the desired repository (REPOSITORY_ID in this case, which is bound to the string &quot;javatutorial&quot;). </p>
<pre class="input"> AGRepository myRepository = catalog.createRepository(REPOSITORY_ID);<br> println(&quot;Got a repository.&quot;);<br> myRepository.initialize();<br> println(&quot;Initialized repository.&quot;);<br> println(&quot;Repository is writable? &quot; + myRepository.isWritable());</pre>
<p>A new or renewed repository must be initialized, using the <strong>initialize()</strong> method of the repository object. If you try to initialize a respository twice you get a warning message in the Java window but no exception. Finally we check to see that the repository is writable.</p>
<pre class="output"> Got a repository.
@@ -216,7 +216,7 @@ <h2 id="Asserting and Retracting Triples">Asserting and Retracting Triples (exam
<p>
-In example example2(), we show how
+In example2(), we show how
to create resources describing two
people, Bob and Alice, by asserting individual triples into the respository. The example also retracts and replaces a triple. Assertions and retractions to the triple store
are executed by 'add' and 'remove' methods belonging to the connection object, which we obtain by calling the example1() function (described above).
@@ -290,8 +290,7 @@ <h2 id="Statement Matching">Statement Matching (example4()) &nbsp;&nbsp;&nbsp;<a
<p>
The getStatements() method of the connection object provides a simple way to perform unsophisticated queries. This method lets you enter a mix of required values and wildcards, and retrieve all matching triples. (If you need to perform sophisticated tests and comparisons you should use the SPARQL query instead.)</p>
<p>
-Below, we illustrate two kinds of getStatement calls. The first mimics
-traditional Sesame syntax, and returns a Statement object at each iteration. This is the <strong>example4()</strong> function of TutorialExamples.java. It begins by calling example2() to create a connection object and populate the agraph_test repository with four triples describing Bob and Alice. </p>
+This is the <strong>example4()</strong> function of TutorialExamples.java. It begins by calling example2() to create a connection object and populate the javarepository with four triples describing Bob and Alice. </p>
<pre class="input"> public static void example4() throws RepositoryException {<br> RepositoryConnection conn = example2(false);
closeBeforeExit(conn);</pre>
<p>We're going to search for triples that mention Alice, so we have to create an &quot;Alice&quot; URI to use in the search pattern. This requires us to build the bridge from the connection back to the valueFactory:</p>
@@ -747,7 +746,7 @@ <h2 id="RDFS++ Inference">RDFS++ Inference (example19())&nbsp;&nbsp;&nbsp;<a cla
<p><img src="inferenceSetup.jpg" width="448" height="101"></p>
<p>First we have to set up the data. We begin by generating four URIs for the new resources. </p>
<pre class="input"> public static void example19() throws Exception {<br> AGRepositoryConnection conn = example1(false);<br> ValueFactory f = conn.getValueFactory();<br> URI robert = f.createURI(&quot;http://example.org/people/robert&quot;);<br> URI roberta = f.createURI(&quot;http://example.org/people/roberta&quot;);<br> URI bob = f.createURI(&quot;http://example.org/people/bob&quot;);<br> URI bobby = f.createURI(&quot;http://example.org/people/bobby&quot;);</pre>
-The next step is to create URIs for the predicates we'll need (<em>name</em> and <em>child</em>), plus one for the Person class. <br>
+The next step is to create URIs for the predicates we'll need (<em>name</em> and <em>fatherOf</em>), plus one for the Person class. <br>
<pre class="input"> URI name = f.createURI(&quot;http://example.org/ontology/name&quot;);<br> URI fatherOf = f.createURI(&quot;http://example.org/ontology/fatherOf&quot;);<br> URI person = f.createURI(&quot;http://example.org/ontology/Person&quot;);</pre>
The names of the four people will be literal values. <br>
<pre class="input"> Literal bobsName = f.createLiteral(&quot;Bob&quot;);<br> Literal bobbysName = f.createLiteral(&quot;Bobby&quot;);<br> Literal robertsName = f.createLiteral(&quot;Robert&quot;);<br> Literal robertasName = f.createLiteral(&quot;Roberta&quot;);</pre>
@@ -772,7 +771,7 @@ <h2 id="RDFS++ Inference">RDFS++ Inference (example19())&nbsp;&nbsp;&nbsp;<a cla
<p>This is a getStatements() search with inference turned ON.&nbsp; This time we added the fifth parameter, True, to getStatements(). This turns on the inference engine. </p>
<pre class="input"> println(&quot;\nChildren of Robert, inference ON&quot;);<br> printRows( conn.getStatements(robert, fatherOf, null, true) );</pre>
<pre class="output">Children of Robert, inference ON<br>(http://example.org/people/robert, http://example.org/ontology/fatherOf, http://example.org/people/roberta) [null]<br>(http://example.org/people/robert, http://example.org/ontology/fatherOf, http://example.org/people/bobby) [null]</pre>
-<p>Note that with inference ON, Robert suddenly has two children because Bob's child has been included.&nbsp; Also note that the final triple (robert hasChild bobby) has been inferred.&nbsp; The inference engine has determined that this triple logically must be true, even though it does not appear in the repository. </p>
+<p>Note that with inference ON, Robert suddenly has two children because Bob's child has been included.&nbsp; Also note that the final triple (robert fatherOf bobby) has been inferred.&nbsp; The inference engine has determined that this triple logically must be true, even though it does not appear in the repository. </p>
<h3>InverseOf</h3>
<p>We can reuse the Robert family tree to see how the inference engine can deduce the presence of inverse relationships. </p>
<p>Up to this point in this tutorial, we have created new predicates simply by creating a URI and using it in the predicate position of a triple.&nbsp; This time we need to create a predicate<em> resource</em> so we can set an attribute of that resource.&nbsp; We're going to declare that the <strong>hasFather</strong> predicate is the <strong>owl:inverseOf</strong> the existing fatherOf predicate. </p>
@@ -1200,6 +1199,6 @@ <h2 id="Transaction">Transaction (example22())</h2>
Number of results: 1</pre>
<p>The Les Miserables triples are visible in both sessions. So too are the Kennedy triples. </p>
<p>&nbsp;</p>
-<p><font color="#CCCCCC">December 05, 2009 4.0 M2 release</font></p>
+<p><font color="#CCCCCC">December 14, 2009 4.0 m2 release</font></p>
</body>
</html>
Oops, something went wrong.

0 comments on commit 44f96c9

Please sign in to comment.