Author: hasan
Date: Sat Nov 11 20:52:06 2017
New Revision: 1814972

URL: http://svn.apache.org/viewvc?rev=1814972&view=rev
Log:
CLEREZZA-1017: Add Tutorial 2

Added:
    clerezza/site/production/getting-started/tutorial/tutorial-02/
    clerezza/site/production/getting-started/tutorial/tutorial-02/index.html
Modified:
    clerezza/site/production/getting-started/tutorial/index.html

Modified: clerezza/site/production/getting-started/tutorial/index.html
URL: 
http://svn.apache.org/viewvc/clerezza/site/production/getting-started/tutorial/index.html?rev=1814972&r1=1814971&r2=1814972&view=diff
==============================================================================
--- clerezza/site/production/getting-started/tutorial/index.html (original)
+++ clerezza/site/production/getting-started/tutorial/index.html Sat Nov 11 
20:52:06 2017
@@ -83,6 +83,11 @@
                                     <a href="tutorial-01/">Tutorial 1</a> - 
Store Triples in a Simple Graph.
                                 </div>
                             </li>
+                            <li>
+                                <div>
+                                    <a href="tutorial-02/">Tutorial 2</a> - 
Import Triples from a File into a Simple Graph.
+                                </div>
+                            </li>
                         </ul>
                     </div>
                 </div>

Added: clerezza/site/production/getting-started/tutorial/tutorial-02/index.html
URL: 
http://svn.apache.org/viewvc/clerezza/site/production/getting-started/tutorial/tutorial-02/index.html?rev=1814972&view=auto
==============================================================================
--- clerezza/site/production/getting-started/tutorial/tutorial-02/index.html 
(added)
+++ clerezza/site/production/getting-started/tutorial/tutorial-02/index.html 
Sat Nov 11 20:52:06 2017
@@ -0,0 +1,345 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+    <head>
+        <link type="text/css" href="/style/style.css" rel="stylesheet"/>
+        <title>Tutorial 02 - Import Triples from a File into a Simple 
Graph</title>
+    </head>
+    <body>
+        <div class="zz-header">
+            <div class="bar"></div>
+            <div class="logo">
+                <a href="http://clerezza.apache.org/"; style="">
+                    <img src="/images/logo.png" alt="logo"/>
+                </a>
+            </div>
+        </div>
+        <div class="column nav">
+            <ul>
+                <li class="top-nav-entry">
+                    <div class="title">Documentation</div>
+                    <ul class="nav-entries">
+                        <li>
+                            <a href="/getting-started/" class="active">Getting 
Started</a>
+                        </li>
+                        <li>
+                            <a href="/architecture/">The Apache Clerezza 
Stack</a>
+                        </li>
+                        <li>
+                            <a href="http://clerezza.apache.org/apidocs/"; 
target="_blank">API docs</a>
+                        </li>
+                        <li>
+                            <a href="/faq/">FAQ</a>
+                        </li>
+                    </ul>
+                </li>
+                <li class="top-nav-entry">
+                    <div class="title">Project Infos</div>
+                    <ul class="nav-entries">
+                        <li>
+                            <a href="/downloads/">Downloads</a>
+                        </li>
+                        <li>
+                            <a href="/contributing/">Contributing</a>
+                        </li>
+                        <li>
+                            <a href="http://www.apache.org/licenses/"; 
target="_blank">License</a>
+                        </li>
+                        <li>
+                            <a href="/mailinglists/">Mailing lists</a>
+                        </li>
+                        <li>
+                            <a 
href="http://issues.apache.org/jira/browse/CLEREZZA"; target="_blank">Issue 
Tracker</a>
+                        </li>
+                        <li>
+                            <a 
href="https://git-wip-us.apache.org/repos/asf?p=clerezza.git"; 
target="_blank">Source Repository</a>
+                        </li>
+                    </ul>
+                </li>
+                <li class="top-nav-entry">
+                    <div class="title">Sponsorship</div>
+                    <ul class="nav-entries">
+                        <li>
+                            <a href="/thanks/">Thanks</a>
+                        </li>
+                        <li>
+                            <a 
href="http://www.apache.org/foundation/sponsorship.html"; target="_blank">Become 
a Sponsor</a>
+                        </li>
+                        <li>
+                            <a 
href="http://www.apache.org/foundation/buy_stuff.html"; target="_blank">Buy 
Stuff</a>
+                        </li>
+                    </ul>
+                </li>
+            </ul>
+        </div>
+        <div class="zz-content">
+            <h1>Tutorial 02 - Import Triples from a File into a Simple 
Graph</h1>
+            <div class='tx-content'>
+                <div>
+                    <div xmlns="http://www.w3.org/1999/xhtml"; class="column 
one-column">
+                        <p>
+                               In this tutorial we are going to import triples 
stored in a file into a graph.
+                        </p>
+                        <h2>Problem Definition</h2>
+                        <p>
+                               Given a file containing a set of triples in <a 
href="https://www.w3.org/TR/turtle/";>Turtle</a> serialization format 
(text/turtle), an RDF Graph should be created and filled with the triples. 
Assuming the content of the file is as follows, the program should log the 
corresponding triples.
+                        </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml"; 
class="tx-blockcode">
+@prefix ex: &lt;http://clerezza.apache.org/2017/01/example#&gt; .
+_:a ex:hasFirstName "Hasan" .
+_:a ex:isA ex:ClerezzaUser .
+                        </div>
+                        <h2>Solution</h2>
+                        <p>
+                               Apache Clerezza provides a Parser that can be 
used to read files containing triples in various serialization format. The 
Parser makes use of ParsingProvider services which implement the functionality 
to parse files of specific data format. We are going to use a ParsingProvider 
based on Jena Parser.
+                       </p>
+                        <p>
+                               The programme listed below reads the file 
example02.ttl, parses its content and stores the triples into a Graph. Then it 
reads the newly created graph and logs the triples within the graph.
+                        </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml"; 
class="tx-blockcode">
+     1 package org.apache.clerezza.tutorial;
+     2 
+     3 import org.apache.clerezza.commons.rdf.Graph;
+     4 import org.apache.clerezza.commons.rdf.Triple;
+     5 import org.apache.clerezza.rdf.core.serializedform.Parser;
+     6 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+     7 import 
org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
+     8 import org.slf4j.Logger;
+     9 import org.slf4j.LoggerFactory;
+    10 
+    11 import java.io.InputStream;
+    12 import java.util.Iterator;
+    13 
+    14 public class Example02 {
+    15 
+    16     private static final Logger logger = 
LoggerFactory.getLogger(Example02.class);
+    17 
+    18     public static void main(String[] args) {
+    19         InputStream inputStream = 
Example02.class.getResourceAsStream("example02.ttl");
+    20         Parser parser = Parser.getInstance();
+    21 
+    22         try {
+    23             Graph graph = parser.parse(inputStream, 
SupportedFormat.TURTLE);
+    24 
+    25             Iterator&lt;Triple&gt; iterator = 
graph.filter(null,null,null);
+    26             Triple triple;
+    27 
+    28             while (iterator.hasNext()) {
+    29                 triple = iterator.next();
+    30                 logger.info(String.format("%s %s %s",
+    31                         triple.getSubject().toString(),
+    32                         triple.getPredicate().toString(),
+    33                         triple.getObject().toString()
+    34                 ));
+    35             }
+    36         } catch (UnsupportedFormatException $ex) {
+    37             logger.warn(String.format("%s is not supported by the used 
parser", SupportedFormat.TURTLE));
+    38         }
+    39     }
+    40 }
+                        </div>
+                        <p>
+                               We will use maven for building the program. The 
required POM file is as follows:
+                       </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml"; 
class="tx-blockcode">
+     1 &lt;project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+     2   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd"&gt;
+     3   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
+     4   &lt;groupId&gt;org.apache.clerezza.tutorial&lt;/groupId&gt;
+     5   &lt;artifactId&gt;Example-02&lt;/artifactId&gt;
+     6   &lt;packaging&gt;jar&lt;/packaging&gt;
+     7   &lt;version&gt;1.0&lt;/version&gt;
+     8   &lt;build&gt;
+     9     &lt;plugins&gt;
+    10       &lt;plugin&gt;
+    11         &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
+    12         &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
+    13         &lt;version&gt;3.7.0&lt;/version&gt;
+    14         &lt;configuration&gt;
+    15           &lt;source&gt;1.8&lt;/source&gt;
+    16           &lt;target&gt;1.8&lt;/target&gt;
+    17         &lt;/configuration&gt;
+    18       &lt;/plugin&gt;
+    19       &lt;plugin&gt;
+    20         &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
+    21         &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
+    22         &lt;version&gt;1.6.0&lt;/version&gt;
+    23         &lt;executions&gt;
+    24           &lt;execution&gt;
+    25             &lt;goals&gt;
+    26               &lt;goal&gt;java&lt;/goal&gt;
+    27             &lt;/goals&gt;
+    28           &lt;/execution&gt;
+    29         &lt;/executions&gt;
+    30         &lt;configuration&gt;
+    31           
&lt;mainClass&gt;org.apache.clerezza.tutorial.Example02&lt;/mainClass&gt;
+    32         &lt;/configuration&gt;
+    33       &lt;/plugin&gt;
+    34     &lt;/plugins&gt;
+    35   &lt;/build&gt;
+    36   &lt;name&gt;Example-02&lt;/name&gt;
+    37   &lt;url&gt;http://maven.apache.org&lt;/url&gt;
+    38   &lt;dependencies&gt;
+    39     &lt;dependency&gt;
+    40       &lt;groupId&gt;org.apache.clerezza&lt;/groupId&gt;
+    41       &lt;artifactId&gt;rdf.core&lt;/artifactId&gt;
+    42       &lt;version&gt;1.0.1&lt;/version&gt;
+    43     &lt;/dependency&gt;
+    44     &lt;dependency&gt;
+    45       &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
+    46       &lt;artifactId&gt;slf4j-simple&lt;/artifactId&gt;
+    47       &lt;version&gt;1.7.25&lt;/version&gt;
+    48     &lt;/dependency&gt;
+    49     &lt;dependency&gt;
+    50       &lt;groupId&gt;org.apache.clerezza&lt;/groupId&gt;
+    51       &lt;artifactId&gt;rdf.jena.parser&lt;/artifactId&gt;
+    52       &lt;version&gt;1.1.1&lt;/version&gt;
+    53     &lt;/dependency&gt;
+    54   &lt;/dependencies&gt;
+    55 &lt;/project&gt;
+                        </div>
+                           <p>
+                               The directory structure is simple as shown 
below:
+                               </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml"; 
class="tx-blockcode">
+    pom.xml
+    src/main/java/org/apache/clerezza/tutorial/Example02.java
+    src/main/resources/org/apache/clerezza/tutorial/example02.ttl
+                           </div>
+                           <p>
+                               To build the jar, we should invoke:
+                           </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml"; 
class="tx-blockcode">
+    mvn package
+                           </div>
+                           <p>
+                               Running the programme can be done by invoking
+                           </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml"; 
class="tx-blockcode">
+    mvn exec:java
+                           </div>
+                           <p>
+                               The result of the programme execution shows the 
log messages as expected.
+                           </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml"; 
class="tx-blockcode">
+[INFO] Scanning for projects...
+[INFO]                                                                         
+[INFO] ------------------------------------------------------------------------
+[INFO] Building Example-02 1.0
+[INFO] ------------------------------------------------------------------------
+[INFO] 
+[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ Example-02 ---
+SLF4J: Class path contains multiple SLF4J bindings.
+SLF4J: Found binding in 
[jar:file:/home/hasan/.m2/repository/org/slf4j/slf4j-simple/1.7.25/slf4j-simple-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
+SLF4J: Found binding in 
[jar:file:/home/hasan/.m2/repository/org/slf4j/slf4j-log4j12/1.7.6/slf4j-log4j12-1.7.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
+SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an 
explanation.
+SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
+[org.apache.clerezza.tutorial.Example02.main()] INFO 
org.apache.clerezza.rdf.core.serializedform.Parser - constructing Parser
+[org.apache.clerezza.tutorial.Example02.main()] INFO 
org.apache.clerezza.tutorial.Example02 - 
<b>org.apache.clerezza.rdf.jena.commons.JenaBNodeWrapper@78d47560 
&lt;http://clerezza.apache.org/2017/01/example#hasFirstName&gt; 
"Hasan"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;</b>
+[org.apache.clerezza.tutorial.Example02.main()] INFO 
org.apache.clerezza.tutorial.Example02 - 
<b>org.apache.clerezza.rdf.jena.commons.JenaBNodeWrapper@78d47560 
&lt;http://clerezza.apache.org/2017/01/example#isA&gt; 
&lt;http://clerezza.apache.org/2017/01/example#ClerezzaUser&gt;</b>
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 0.928 s
+[INFO] Finished at: 2017-11-11T15:53:32+01:00
+[INFO] Final Memory: 9M/216M
+[INFO] ------------------------------------------------------------------------
+                        </div>
+                        <h2>Discussion</h2>
+                        <p>
+                               The maven POM file shows three libraries on 
which the programme directly depends:
+                       </p>
+                       <ul>
+                               <li>
+                                       org.apache.clerezza.rdf.core: contains 
implementation of the Apache Clerezza Parser
+                               </li>
+                               <li>
+                                       org.apache.clerezza.rdf.jena.parser: 
contains ParsingProvider service based on Jena Parser
+                               </li>
+                               <li>
+                                       org.slf4j.slf4j-simple: contains 
implementation of the logger
+                               </li>
+                       </ul>
+                        <p>
+                               The core of the programme lies at line 20 
(Parser instantiation) and 23 (parsing a stream of triples into a graph).
+                        </p>
+                        <p>
+                        Note: Any comments and suggestions for improvements 
are welcome. Please send your feedback to <a 
href="mailto:[email protected]";>[email protected]</a>
+                        </p>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="footer">
+            <div class="logos">
+                <img src="/images/feather.png"/>
+                <img src="/images/sw-vert-w3c.png"/>
+                <img src="/images/footer-logo.png"/>
+            </div>
+            <div class="divider"></div>
+            <div class="dark">
+                <div class="sitemap">
+                    <div class="sitemap-title">Sitemap</div>
+                    <div class="sitemap-content">
+                        <div class="sitemap-column">
+                            <div class="title">Documentation</div>
+                            <ul>
+                                <li>
+                                    <a href="/getting-started/">Getting 
Started</a>
+                                </li>
+                                <li>
+                                    <a href="/architecture/">The Apache 
Clerezza Stack</a>
+                                </li>
+                                <li>
+                                    <a 
href="http://clerezza,apache.org/apidocs/"; target="_blank">API docs</a>
+                                </li>
+                                <li>
+                                    <a href="/faq/">FAQ</a>
+                                </li>
+                            </ul>
+                        </div>
+                        <div class="sitemap-column">
+                            <div class="title">Project Infos</div>
+                            <ul>
+                                <li>
+                                    <a href="/downloads/">Downloads</a>
+                                </li>
+                                <li>
+                                    <a href="/contributing/">Contributing</a>
+                                </li>
+                                <li>
+                                    <a href="http://www.apache.org/licenses/"; 
target="_blank">License</a>
+                                </li>
+                                <li>
+                                    <a href="mailinglists/">Mailing lists</a>
+                                </li>
+                                <li>
+                                    <a 
href="http://issues.apache.org/jira/browse/CLEREZZA"; target="_blank">Issue 
Tracker</a>
+                                </li>
+                                <li>
+                                    <a 
href="https://git-wip-us.apache.org/repos/asf?p=clerezza.git"; 
target="_blank">Source Repository</a>
+                                </li>
+                            </ul>
+                        </div>
+                        <div class="sitemap-column">
+                            <div class="title">Sponsorship</div>
+                            <ul>
+                                <li>
+                                    <a href="/thanks/">Thanks</a>
+                                </li>
+                                <li>
+                                    <a 
href="http://www.apache.org/foundation/sponsorship.html"; target="_blank">Become 
a Sponsor</a>
+                                </li>
+                                <li>
+                                    <a 
href="http://www.apache.org/foundation/buy_stuff.html"; target="_blank">Buy 
Stuff</a>
+                                </li>
+                            </ul>
+                        </div>
+                    </div>
+                </div>
+                <div class="copyright">Apache Clerezza, Clerezza, Apache, the 
Apache feather logo, and the Apache Clerezza project logo are trademarks of The 
Apache Software Foundation.
+                    <br></br>© 2011 The Apache Software Foundation.
+                </div>
+            </div>
+        </div>
+    </body>
+</html>
\ No newline at end of file


Reply via email to